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?
Printable View
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?
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.
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
>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.
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...Quote:
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.
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.
I think I'm doing this right, but I'm not too sure. Thanks for the help.Code:#!/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 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?
Code:while ($pass ne "abc123")
There you go.Code:#!/usr/bin/env python
while raw_input ('What is the password?') <> 'abc123':
continue
print 'Correct password.'
Code:#!/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";
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.
Woops! i forgot that PERL has different operators for string and numerical comparison.Quote:
I still isn't working.
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).
Code:while ($pass ne 'abc123')
{
print "What is the password? \n";
$pass=<STDIN>;
chop ($pass);
}
print "Correct password.\n";
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
*edited to say, ignore the whitespace after the '>'. There seems to be an issue with the board as it is adding it in.Code:chomp($pass=<STDIN>);
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