View Full Version : perl
ZakkWylde969
12-23-2003, 03:01 PM
I was thinking about learning Perl as another language. What do you guys personally recommend for a ebook or online tutorial for Linux Perl programming for a complete idiot?
Prelude
12-23-2003, 03:34 PM
www.perl.com is all you need. But if you're willing to get hardcopy as well, Programming Perl, Learning Perl, and Perl Cookbook are all quite good.
linuxdude
12-23-2003, 04:07 PM
I would recommend staying away from:
Learn Perl in 21 days
That is what I learned from. It was okay until it got into more advanced topics then just didn't explain enough
Prelude
12-23-2003, 04:18 PM
>Learn Perl in 21 days
I don't think any book that claims to teach you programming in 21 days, 24 hours, 10 minutes, 58 seconds, etc. would explain enough after the bare bones basics. From what I've seen, this assumption is true.
mix0matt
12-23-2003, 08:22 PM
If you in the market for learning a powerful scripting language, look at Python and stay away from PERL.
PERL is an infection, which is slowly being cured by languages created by less hubristic personalities.
glUser3f
12-23-2003, 08:38 PM
Originally posted by mix0matt
If you in the market for learning a powerful scripting language, look at Python and stay away from PERL.
PERL is an infection, which is slowly being cured by languages created by less hubristic personalities.
yeah, start the flamewar...
ZakkWylde969
12-24-2003, 11:15 AM
I think I'm going to stick to Perl. I'll keep this question to my Perl thread since this isn't a Perl board. Anyhow after getting started, I'm trying to create a simple script in perl and can't get it to work.
#!/bin/bash/perl
# a simple password request
print "What is the password? \n";
$pass=<>;
#Ok Now time for the loop.
while ($pass ne abc123) #the error occurs here.
{
print "What is the password? \n";
$pass=<>;
}
print "Correct password.";
I think I'm doing this right, but I'm not too sure. Thanks for the help.
glUser3f
12-24-2003, 12:06 PM
I haven't done something in perl for a while, I forgot most of it, but I think <> should be <STDIN>
and shouldn't you use "s around your password?
while ($pass ne "abc123")
mix0matt
12-24-2003, 12:08 PM
#!/usr/bin/env python
while raw_input ('What is the password?') <> 'abc123':
continue
print 'Correct password.'
There you go.
#!/bin/bash/perl
# a simple password request
print "What is the password? \n";
$pass=<>;
#Ok Now time for the loop.
while ($pass != 'abc123') #the error occurs here.
{
print "What is the password? \n";
$pass=<>;
}
print "Correct password.\n";
ZakkWylde969
12-24-2003, 12:49 PM
I still isn't working. I told you I'm not doing Python so don't try to push it to me. :) It accepts anything as the correct password, and nothing as the wrong one.
mix0matt
12-24-2003, 03:02 PM
I still isn't working.Woops! i forgot that PERL has different operators for string and numerical comparison.
Also strip the newline character off of the string read from stdin. I haven't had an interest in PERL in a long time. There's a lot to remember (or forget depending on who you ask).
while ($pass ne 'abc123')
{
print "What is the password? \n";
$pass=<STDIN>;
chop ($pass);
}
print "Correct password.\n";
ZakkWylde969
12-24-2003, 03:27 PM
Thanks ya's. I might check out python later on ;)
You should really use chomp when only removing newlines. Although it makes no real difference here its better to get into good perl practise as it can cause problems, hence the reason it was included.
you will more often see the 2 parts combined
chomp($pass=<STDIN>);
*edited to say, ignore the whitespace after the '>'. There seems to be an issue with the board as it is adding it in.
Umm...
I think you need to change
#!/bin/bash/perl
to this
#!/bin/perl
or this
#!/usr/bin/perl
That all depends on where his perl executable is.
If the path is /bin/bash/perl , which I'm assuming it is else his program would not have worked (unless he had extensions like .pl, then !#/bin/bash/perl would not be needed)
However, a good point is that /bin/bash/ is not part of the Linux heirachy......so this is rather odd. Bash is an executable in the bin directory.
/usr/bin/perl is the standard location
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.