Thread: perl

  1. #1
    ___
    Join Date
    Jun 2003
    Posts
    806

    perl

    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?
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    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.
    My best code is written with the delete key.

  3. #3
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    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

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >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.
    My best code is written with the delete key.

  5. #5
    junior member mix0matt's Avatar
    Join Date
    Aug 2001
    Posts
    144
    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.
    THIS IS NOT JUST A CHRONICLING OF THINGS WE HAVE DONE IN THE PAST BUT OUR RISE TO POWER.

  6. #6
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    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...

  7. #7
    ___
    Join Date
    Jun 2003
    Posts
    806
    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.

    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 think I'm doing this right, but I'm not too sure. Thanks for the help.
    Last edited by ZakkWylde969; 12-24-2003 at 11:34 AM.
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  8. #8
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    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")

  9. #9
    junior member mix0matt's Avatar
    Join Date
    Aug 2001
    Posts
    144
    Code:
    #!/usr/bin/env python
    while raw_input ('What is the password?') <> 'abc123':
        continue
    print 'Correct password.'
    There you go.

    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";
    THIS IS NOT JUST A CHRONICLING OF THINGS WE HAVE DONE IN THE PAST BUT OUR RISE TO POWER.

  10. #10
    ___
    Join Date
    Jun 2003
    Posts
    806
    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.
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  11. #11
    junior member mix0matt's Avatar
    Join Date
    Aug 2001
    Posts
    144
    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).

    Code:
    while ($pass ne 'abc123') 
    {
         print "What is the password? \n";
         $pass=<STDIN>;
         chop ($pass);
    }
    print "Correct password.\n";
    THIS IS NOT JUST A CHRONICLING OF THINGS WE HAVE DONE IN THE PAST BUT OUR RISE TO POWER.

  12. #12
    ___
    Join Date
    Jun 2003
    Posts
    806
    Thanks ya's. I might check out python later on
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  13. #13
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    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

    Code:
    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.
    Last edited by eth0; 01-02-2004 at 01:39 PM.

  14. #14
    Registered User
    Join Date
    Nov 2002
    Posts
    82
    Umm...

    I think you need to change

    #!/bin/bash/perl

    to this

    #!/bin/perl

    or this

    #!/usr/bin/perl

  15. #15
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    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
    Last edited by eth0; 01-03-2004 at 01:45 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C structure in perl typemap
    By rotis23 in forum Linux Programming
    Replies: 1
    Last Post: 07-16-2003, 11:13 AM
  2. de facto perl book
    By rotis23 in forum Linux Programming
    Replies: 1
    Last Post: 05-22-2003, 04:43 AM
  3. perl program question
    By newbie2c in forum Tech Board
    Replies: 2
    Last Post: 02-03-2003, 10:19 AM
  4. From Perl to C
    By Heavenstrash in forum C Programming
    Replies: 4
    Last Post: 06-19-2002, 01:22 AM
  5. perl need help pls.....
    By magnum38 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 12-12-2001, 10:35 PM