G'day ferbio,

Welcome to the Monastery.

The most likely cause is your shebang line: '#!/usr/bin/perl'. On one computer, perl is installed in /usr/bin/; on another computer, it's installed elsewhere.

You need to tell us which OSes you're using and show all output. It seems odd that you get no output at all: perhaps no "Hello, World...", but were there any other messages. Here's what I get when I try to run perl from both an existing and non-existing location:

$ /usr/bin/perl -e 'print "Hello, world!\n"' Hello, world! $ /usr/not_bin/perl -e 'print "Hello, world!\n"' -bash: /usr/not_bin/perl: No such file or directory

Putting your posted code — but using an invalid path to perl in the shebang line — into a script and running:

$ cat crap.pl #!/usr/not_bin/perl use strict; use warnings; print "Hello, World...\n"; $ ./crap.pl -bash: ./crap.pl: /usr/not_bin/perl: bad interpreter: No such file or +directory

Take a look at perlintro for a gentle introduction of this concept; perlrun has a more detailed discussion.

[Note: Please put all code, data and program output within <code>...</code> tags. Doing so will mean that HTML rendering (e.g. converting a sequence of whitespace characters into a single space) will not affect what you post. It also allows us to access a verbatim copy. See "How do I post a question effectively?" and "Writeup Formatting Tips".]

— Ken


In reply to Re: Print hello world not working by kcott
in thread Print hello world not working by ferbio

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.