Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

About Perl 1

Status
Not open for further replies.

safra

Technical User
Jan 24, 2001
319
NL
Hi Guys,

I started to learn to program in Perl about 3 months ago. There are several other options for server side programming.

What I would like to find out is what Perl’s position is against the others. What are the strengths of Perl and what are the weaknesses. It is always said that php is faster than asp. Somehow I feel Perl has it’s own position. What is this position?

Has Perl a strong foundation to last in the future as a programming language?

It is not that I have my worries about Perl, I just want to know before I dive deeper in it.

Ron
 
my own humble opinion.....

Perl's three main strengths
1 - regex
Perl has very powerful regex capabilities. That is very useful in dealing with any kind of text manipulation and with web stuff.

2 - syntactically dense
Perl is sometimes refered to as being syntactically dense. Once you learn the basics, you can start compressing the needed functionality into less and less code. This starts slowly, but eventually saves lots of time because you get better at creating the needed functionality with a minimal amount of coding.

3 - opportunity to learn as you use....
Perl lends itself to enabling the newbie to write functional, useful code without years of experience. If you don't know another language to start with, the Camel books keep this from being obvious.

Regarding Perl's future..... The current version of Perl (5.6, I think), is very competent. The upcoming 6.0 will add lots of stuff that the OO world said were short comings.

I have to stop now.... as I type, I keep thinking of strength 4 and then 5 and then......

A few others.....
Contrary to Common Wisdom, it is relatively fast. (Faster than JAVA).
Solid web tools (lib CGI.pm and CGI_Lite)
Solid Database interaction tools (DBI/DBD)
Good and Getting better Object Oriented capabilities
A very active developer community
A large library of modules ( you can usually find that some else has already written what you need.)
etc....

HTH


keep the rudder amid ship and beware the odd typo
 
Thanks quys for the feedback,

goBoating, I quess you're quite a devoted Perl programmer!

One of the reasons I started this was because I recently did a simple Perl project for a client but it turned out that their server didn't support Perl. They responded by saying that 95%! of their clients preferred ASP above Perl then it is said that PHP is faster than ASP so where does that leave Perl?

I quess Perl is a strong and save option for the future! Any more explained confirmations are ofcourse welcome!

regards,

Ron
 
About ASP/PHP and Perl.....

Their server did not support Perl? They must be using a abacus or, they just don't want to venture into the Perl world. It sounds like they might be a Microsoft shop. If so, there are very easy download/install ports of Perl that would take about 5 minutes to get going. (
Wether to use ASP or PHP seems to me to be more of a question about what flavor shop you are running or working in. If you are already Microsoft centric, then I would stay with the Microsoft way of life. I am not Microsoft centric, I thnik. I use it where it makes sense, I hope, without any 'loyalty' either way. Sometimes VB is a much simpler solution in a Microsoft context. To use another tool just to spite MS would be a little silly. Use what works.

If all you want to do is Web stuff, then PHP may do everything you ever want. If you would like to pick up a language that will do a lot of stuff and at the same time get some solid web tools, then Perl might be a good choice. Additionally, the PHP syntax smells/looks a lot like Perl....... learning the one would probably lead into learning the other.

I guess I am a Perl fan. I do earn my living with it. I have had good success attacking a variety of programming chores with Perl quickly and effectively. 'Keeps the clients happy.

my few cents......



keep the rudder amid ship and beware the odd typo
 
Hi,

goBoating, Thanks for all your motivations. I will check that link and yes you are right about that server (windows nt). Especially for the project I did they installed an old version of Perl. Very weird and it never worked. Luckily my client was convinced to change the server.

Btw. I don't expect any help on this but maybe somebody can get me on track with it.

I downloaded Perl from and installed it. I still work on windows '98.

I have no idea where to start. I checked all the help, readme and faqs files but I couldn't find how to get started.

I can't open a Perl file anymore (directly by clicking on it) and how can do I access Perl on my system to check my scripts?

Anybody knows a clear reference for this that can clear some stuff for me (I really am not an hardcore Perl programmer)?

Regards,

Ron,

oh another one

|one|two|three|four

how can I trim this quickly to:

|one|two|three|

(there might me more or less "|" than in the example so it should always splice the part after the last "|")
 
regarding your Perl install on Win98....
that is exactly what I have at home..... actually my PC dual boots Win98 and LINUX.
About Perl on Win98..... You should have no problems. You can register the '.pl' extension to pick up the perl interpreter automatically. I can't remember how and I'm not in front of a Win98 box at the moment. I'll try to remember to look while I'm at home. Maybe someone else who is more of a Win OS person can chime in here.

Alternatively, you can START->RUN [command] to get a dos window and run your code there. Like,

C:\path\where\your\code\is_sitting> perl your_program.pl<RETURN>

On the second one.....
#!/usr/local/bin/perl

$str = '|one|two|three|four|five';
@some = split /\|/,$str;
splice @some,4;
print &quot;SPLICED - @some\n&quot;;

$new_str = join('|',@some);
print &quot;JOINED - $new_str\n&quot;;


$str = '|one|two|three|four|five';
$str =~ s/(\|\w+\|\w+\|\w+).*/$1/;
print &quot;REPLACED - $str\n&quot;;

'hope this helps...


keep the rudder amid ship and beware the odd typo
 
I checked the link:


That is convincing stuff!

I guess I'm doing something wrong as I still can't get Perl to work on my OS. In DOS mode I receive an error message after running the script the way goBoating suggested.

Thanks for the solution for that scripting problem goBoating. Is there a regex solution that trims the string the way I want it no matter how many &quot;|&quot; the string contains?

regards,

Ron
 
yes. in regex's, the '+' and '*' modifiers are greedy, that means that it matches as many times as possible, then starts looking for the next piece of the pattern backwards. (to prevent this behavior, you add a '?' after the '*', and it won't be greedy) so, assuming that the string looks exactly like the following:[tt]

'|one|two| ... |last|extra'[/tt]


you can trim off the last part with the following regex:[tt]

$str =~ m~^(\|.*\|).*$~;
$newstr = $1;[/tt]


and it will match the first '*' all the way to the end of the string, then backtrack to the last '|' before matching the rest. so $newstr will become:

[tt]'|one|two| ... |last|'[/tt] &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Thanks stillflame I will try that!

I am quite new to regex. I have several docs about it (from the Internet) but I find it hard to completely understand what certain character exactly do and how to use them. Not at the least as English isn't my native language!

So thanks for the explanation as well!

Ron
 
About that regex solution!

I played a bit with that code. If I replace the &quot;*&quot; for &quot;+&quot; there is no difference in the outcome? And why is the result returned in $1?

Ron
 
right, '*' and '+' are almost exactly the same, so it's hard to catch them acting different. '*' means 0 or more repetitions, '+' means 1 or more. and with both, putting a '?' immediately after either of them toggles whether or not it looks for the characters greedily or not(matching the most times possible or the least).

$1, and any other variable that is just a digit (not zero), are the variables that are assigned by a regex in the following manner: if the regex matches, say, in the following form:[tt]
m/(foo)bar(baz)(word)/[/tt]

the contents of each set of parentheses are then assigned a variable, depending on their order of appearance. that is, $1 will be 'foo', $2 will be 'baz' and $3 will be 'word'. that is ONLY if the regex matches.
combined with things like '.' and '*', we can get a lot into these variables, like with the following:[tt]
m/^(\|.*\|)/[/tt]

will put everything that it matches; the '|', all the characters '.*' matches, and the last '|', but no newlines ('.' doesn't catch newlines unless the regex is in multiline form.) into the $1 variable.

and don't worry, regular expressions are really hard to master no matter what your first language is, most of us still have problems with them, it's just too much thinking for one brain to do.

(well, in the area of translated manuals, english is definitely the documentation standard for perl.) &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Thanks again for the detailed explanation Stillflame.

I think this forum is exceptionally good. All of you do not only give answeres but you also take the time to give deep explanations. Compared to other forums I think this one does stand out!

Thanks all of you!

Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top