That "pesky line" is called a shebang line and you've almost certainly mistyped it: I expect it should be "#!/usr/bin/perl".

I can't see how you're "struggling just to get hello world up and running": you say your code works with it and without it - what problem are you struggling with?

You're no doubt running some perl.exe program (from ActivePerl, Strawberry Perl, or wherever) with hello.pl as an argument - you're possibly achieving that by clicking on an icon. I expect perl.exe is treating the shebang line as a comment because it starts with a "#". Someone with more in-depth knowledge might be able to provide a better (possibly different) answer but, at the end of the day, you can safely ignore it.

I used to run Perl programs from a WinXP box where I had Strawberry Perl and Cygwin. I would leave the shebang line pointing to whatever Perl I had on Cygwin: this allowed me to run the same script without changes from both a Cygwin command line and the WinXP GUI.

I don't have Windows 7 but the following may help explain what's going on. Perhaps you can recreate this session on your system.

  1. Create a Hello world script with a bogus shebang line:
    $ cat > fred.pl #!/usr/bin/not_perl print "Hello, world!\n";
  2. Check that there really isn't a not_perl program:
    $ ls -l /usr/bin/not_perl ls: /usr/bin/not_perl: No such file or directory
  3. Make fred.pl executable:
    $ chmod +x fred.pl
  4. Execute it:
    $ fred.pl -bash: ./fred.pl: /usr/bin/not_perl: bad interpreter: No such file or +directory
  5. Now use a real perl program to run fred.pl (noting that the shebang line is ignored and there's no error messages):
    $ perl fred.pl Hello, world!

There's also some documentation about simulating shebang lines which may be of interest. See perlrun: #! and quoting on non-Unix systems.

-- Ken


In reply to Re: Issue with #!usr/bin/perl by kcott
in thread Issue with #!usr/bin/perl by Anonymous Monk

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.