Previous 1 2 Next 17 Replies Latest reply: Jan 26, 2013 1:19 PM by Frank Caggiano
wwplyr Level 1 Level 1 (0 points)

where is perl located on OS 10.6.8?  I am learning the language and don't know where it is stored so I can use it for my tutorials.  The book suggests "usr/bin/perl" but I think that's for Windows.


iMac, Mac OS X (10.6.8)
  • Frank Caggiano Level 7 Level 7 (25,715 points)

    Should be in /usr/bin/perl on the Mac also.

  • wwplyr Level 1 Level 1 (0 points)

    Thanks.  Further reading got me to "which perl" to show where it was located.  Now I have a problem with using a file to store the perl commands.  When I type in the one-liner for "Hello, World", it works fine.  When I put the same command into a file and then try to get it to execute, (chmod +x filename then perl filename) I get a long string of errors in the Terminal window:

     

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 1, near "rtf1\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 1, near "ansi\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 1, near "ansicpg1252\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 1, near "cocoartf1038\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 2, near "fonttbl\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 2, near "f0\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 2, near "fswiss\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 3, near "red255\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 3, near "green255\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 4, near "margl1440\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 4, near "margr1440\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 4, near "vieww9000\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 4, near "viewh8400\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "viewkind0

    \"

        (Missing semicolon on previous line?)

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "pard\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx720\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx1440\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx2160\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx2880\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx3600\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx4320\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx5040\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx5760\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx6480\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx7200\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx7920\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "tx8640\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "ql\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 5, near "qnatural\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 7, near "pardirnatural

     

    \"

        (Missing semicolon on previous line?)

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 7, near "f0\"

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 7, near "fs24 \"

        (Do you need to predeclare fs24?)

    syntax error at /Users/patnonadmin/Desktop/hello1.pl line 1, near "rtf1\"

    syntax error at /Users/patnonadmin/Desktop/hello1.pl line 3, near "red255\"

    syntax error at /Users/patnonadmin/Desktop/hello1.pl line 4, near "margl1440\"

    "use" not allowed in expression at /Users/patnonadmin/Desktop/hello1.pl line 8, at end of line

    "use" not allowed in expression at /Users/patnonadmin/Desktop/hello1.pl line 9, at end of line

    syntax error at /Users/patnonadmin/Desktop/hello1.pl line 11, near ";}"

    Execution of /Users/patnonadmin/Desktop/hello1.pl aborted due to compilation errors.

     

    Most of this doesn't even seem to apply to my simple, two-line program!  What is going on?

  • Frank Caggiano Level 7 Level 7 (25,715 points)

    If you're chmod'd it into an executable yuu don;t have to run

     

    perl filename.pl

     

    ./filename.pl

     

    will work as long as the top of the file has the line

     

    #!/usr/bin/perl

     

    Post the file maybe somehting will show up

  • steve359 Level 6 Level 6 (12,275 points)

    Perl is similar to Java ... imcompatible even with itself (at least previous versions of itself).  There s a book by O'Reilly press, "Programming Perl", with a camel on the front.  I started reading "Learning Perl" with a llama on the front, and read the disclaimer that it teaches the "20% of the language you will use 80% of the time".  But after reading ProgrammingPerl I believe that is dead wrong.  That other 80% of the language is where the trickery lies.  In short ... using LearningPerl and then trying to actually use Perl is like sending soldiers into nuclear war with a cap gun.  In my humble opinion ... other may disagree.

     

    Programming Perl is 1000 pages,but starts slow enough to learn the basic from the ground up.  I *STRONGLY* recommend that book.

     

    Now ... to versions.  ProgrammingPerl (I will shorten it to PP) highlights features that do not exist "prior to Perl 5.x" (many different versions).  SL (OSX 10.6.x) comes with Perl 5.10.0, which is old now.  Perl 5.17 is out there (PP only covers through 5.14 though), and many of the features that are in use by companies come in versions 5.12 at least, if not 5.14 and higher.

     

    I used this command to load "perlbrew", an environment that will add new verions of perl to your system WITHOUT deleting the system default ... and you shoud not mess with system default lest you break something.  www.perlbrew.pl is the site.  The command is simple ... "curl -kL http://install.perlbrew.pl | bash" (between the ".pl" and "bash" is the "vertical bar" symbol, or you can just cut&paste).

  • wwplyr Level 1 Level 1 (0 points)

    Steve359:  You're assuming I know what you're talking about!  I've only read the first 20 pages of the book!  Where would I put the "curl -kL http://install.perlbrew.pl | bash" command?  I'm using the X11 Terminal supplied on my iMac.

     

    Frank C: I still get an error:  I typed "chmod +x filename" then "./filename" and got this:

     

    -bash: ./Users/patnonadmin/Desktop/hello1.pl: No such file or directory

     

    At least it's only one line this time!  Any more suggestions?  Thanks.

  • wwplyr Level 1 Level 1 (0 points)

    Steve359:  I tried to read Frank Wall's book  "Programming PERL" and only made it halfway through the first chapter.  He's way beyond what I want to know.  My head was spinning and I didn't even know half of what he was saying -- just gobbley-gook to me! 

     

    I just want to know how to handle the information from my forms, not all of the philosophy and machine thinking on how it works. 

     

    It's probably a very good programming system, but I'm not really wanting to program beyond getting the info as I indicated.

  • Frank Caggiano Level 7 Level 7 (25,715 points)

    (Don;t worry I'vebeen doing this for a long time I didn't understand it either )

     

    Frank C: I still get an error:  I typed "chmod +x filename" then "./filename" and got this:

     

     

    Was filename above hello1.pl as below?

    -bash: ./Users/patnonadmin/Desktop/hello1.pl: No such file or directory

     

    At least it's only one line this time!  Any more suggestions?  Thanks.

    You need to post the script.

  • steve359 Level 6 Level 6 (12,275 points)

    I have programmmed in Fortran and C and Java and C# and C++ and Perl.  All languages have quirks.  Sometimes are incompatible with previous version of themselves.  Java and Perl are worst for this, in my experience, of that set.  C and C++ does not change much over time (C will always be simple, C++ will always be bloated).

     

    When you do not understand the pitfalls you will have issues.

     

    One example is that a variable name can be used for an array and for a hash and for a scalar.  You can have "$list" and "@list" and "%list".  And the two assignment statements "@list = ("one", "two", "three");" and "$list = ("one", "two", "three");" have different results.  Perl allows many combinations you can randomly/accidentally type but will have silently-incorrect results.

     

    The "curl" command is to load perlbrew onto your system allowing you to make any version you want of Perl active, allowing 5.10, 5.12, 5.14, 6.16 and5.17 to all be available to you when/if you want them.

     

    Good luck to you.

  • Frank Caggiano Level 7 Level 7 (25,715 points)

    Steve,

     

    What you say has truth in it but was way over technical for the situation. We have a user who is brand new with perl and is trying to get a Hello World script to run.

     

    To borrow a thought from your post this was like bringing a nuclear warhead to a paintball fight.

     

    regards

  • wwplyr Level 1 Level 1 (0 points)

    Here's the program inside the file:

     

    #!/usr/bin/perl

    use strict;

    use warning;

     

    print "Hello, World!\n";

     

    As I said, only two lines...or so.

  • etresoft Level 7 Level 7 (26,425 points)

    You are using TextEdit to write your Perl script. That is creating an RTF file, hence the:

    Backslash found where operator expected at /Users/patnonadmin/Desktop/hello1.pl line 1, near "rtf1\"

    errors.

     

    Get yourself a decent text editor like TextWrangler or, even better, use vi in the Terminal.

  • wwplyr Level 1 Level 1 (0 points)

    The book said that TextEdit was fine to use.  Oh, well.  Where is the "vi" in the Terminal?

  • Frank Caggiano Level 7 Level 7 (25,715 points)

    TextEdit will work if you go into preferences and turn on plain text mode.

     

    But as etresoft wrote you'll be much happier if you plan on doing this long term with a more programmer friendly editor.

     

    TextWrangler is really very good for a range of system functions and is free,

     

    Learning an editor like vi is a good move also as it will almost always be available on any Unix like system you are on. Of course if you really want to play with the big boys you'll need to learn ed

  • wwplyr Level 1 Level 1 (0 points)

    Okay, I downloaded TextWrangler and re-did the file under its auspices.  Here's the error message:

     

    Can't locate warning.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at /Users/patnonadmin/Desktop/hello2.pl line 3.

    BEGIN failed--compilation aborted at /Users/patnonadmin/Desktop/hello2.pl line 3.

     

    Ugh!  This is getting very frustrating!

Previous 1 2 Next