Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have read extensively on perl in the past week... sounds AWESOME... finally figured the obligatory "Hello World" needed to do it's thing. Copied it WORD FOR WORD from "Learning Perl", named it "hw.pl" (no quotes), chmod'd it to 755, and typed the file name. Nothing. Changed quotes in file to single quotes, NOPE. Put purposeful error in it to see if ANYTHING was happening, yes got compile error. Found "perl" is symlinked to "perl5", which is in turn symlinked to "perl5.6.0", and didn't think this would be the problem. Tried running "/usr/bin/perl hw.pl", and nothing.

Just so you have no questions:

#!usr/bin/perl print "Hello World/n";

is it. I'm running Mandrake Linux 8.0, shell = bash. Believe me, I've tried everything before sending this. There's just no "print", no warnings, just an empty prompt.

Please, flame with understanding... you MAY have once been this stupid.

Paul

2002-06-11 Edit by Corion : Changed title, added formatting

  • Comment on Help with Hello World Program (was: I lower my head in awe and shame... mainly shame.)
  • Download Code

Replies are listed 'Best First'.
Re: I lower my head in awe and shame... mainly shame.
by dws (Chancellor) on Jun 11, 2002 at 17:52 UTC
    Most Linux distributions come with Perl installed. I'm not familiar with Mandrake, though. The quick way to check is to type   % perl -v at a shell prompt. If that works, find out where Perl is installed by typing   % which perl The path to the perl executable is liable to be either /usr/bin/perl or /usr/local/bin/perl, though it might be elsewhere. Wherever it is, you'll need to include that path in the "shebang" line at the top of your Perl file. E.g.,
    #!/usr/bin/perl use strict; print "Hello World\n";
    The "shebang" line is how Linux (or, more generally, Unixes), know what program to run to interpret the script.

Re: Help with Hello World Program (was: I lower my head in awe and shame... mainly shame.)
by insensate (Hermit) on Jun 11, 2002 at 18:53 UTC
    You are missing the first "/" from your shebang line. Change #!usr/bin/perl to #!/usr/bin/perl.
    Hope this helps, Jason
Re: I lower my head in awe and shame... mainly shame.
by robobunny (Friar) on Jun 11, 2002 at 17:47 UTC
    well, one problem is that you should be using a backlash instead of a slash in the print statement:
    print "Hello World\n";
    although it should still print something, you just won't have a newline at the end (it will appear in front of your shell prompt).
      Ummm... the backslash was it. OK, my career in debugging is over {Head lowered to ankles in shame, and appreciation of non-flames is quite high} Thanks for tolerance, Paul
        Hmmm... now in scanning the other answers, I guess I AM wondering why it didn't print: "Hello World/n" {error and all}, or prepend my prompt with something. It's not ABSOLUTELY vital I know the answer to this, but now just curious... trying to rebuild debugging career and all. Thx, paul P.S. You probably WERE NEVER THIS dumb!
Re: I lower my head in awe and shame... mainly shame.
by dsheroh (Monsignor) on Jun 11, 2002 at 17:48 UTC
    Could just be a typo in your submission, but if you're printing "Hello World/n" instead of "Hello World\n" (note the direction of the \), that could cause some problems. Depending on how Mandrake builds things, this could cause your next prompt to have "Hello World/n" prepended to it (e.g., "Hello World/nesper@monastery$") or prevent anything from printing.