Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

use: command not found error

by maximus (Novice)
on May 03, 2007 at 20:01 UTC ( #613466=perlquestion: print w/replies, xml ) Need Help??

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

Monks, hope all is fine. I am trying to run this relatively simple script that I wrote and I keep getting the error: use: command not found Here is line 18: # 18 is the vi line number indicator 18. use strict; Can somebody give me an idea of why this is happening? Thanks kindly and keep up the good work (BTW, I love this site it has been a great resource for me, oh yes and Perl rocks!)

Replies are listed 'Best First'.
Re: use: command not found error
by jettero (Monsignor) on May 03, 2007 at 20:07 UTC

    You're running that as a .bat batch file or a .sh shell script, use a #!/she/bang or fix your file associations. That or run perl filename.pl.

    Correct. Perl rocks. Rock on dude.

    -Paul

      Monks, thanks! ok that was stupid on my part: yes indeed perl (space) script_name.pl works. You guys are correct; the only reason it is line 18 is because of the fact that there are a whole bunch of comments before the start of the script: #!/usr/bin/perl -w 18 use strict; 19 use Date::Calc qw(Add_Delta_Days); Thanks a bunch Monks!
        Just a tip: when you quote some code, put it in beetween <code> tags. It is more readable.

        Max
Re: use: command not found error
by halley (Prior) on May 03, 2007 at 20:07 UTC
    Are you sure you're running this script with the Perl interpreter? The "command not found" is something a command script interpreter (like CMD.EXE or bash) might say.

    Rather than just giving us one line, and asking us to guess, show more code. It's odd that you get to line 18, but maybe you start with a lot of comments.

    --
    [ e d @ h a l l e y . c c ]

Re: use: command not found error
by shigetsu (Hermit) on May 03, 2007 at 20:08 UTC

    My guess at first sight of your description is that the shebang line - the line that points to the interpreter (on unixy systems most often: #!/usr/bin/perl) is either missing, wrong in its syntax, does not point to an existing Perl interpreter or has been misplaced (not as first line).

    Perhaps some more code would help us to properly diagnose the problem? Be sure to enclose your code in <code></code> tags.

      One route on unix systems for the "where is this user's perl?" is to use:
      #!/usr/bin/env perl
      which gets whatever the user would get by typing "perl" at the command line. There may be multiple perl versions in different locations, leading to strange behavior. If /usr/bin/env is not there, there are bigger problems.
        which gets whatever the user would get by typing "perl" at the command line. There may be multiple perl versions in different locations, leading to strange behavior. If /usr/bin/env is not there, there are bigger problems.

        Indeed this is often debated, and many think that env suffers from the same problem it aims at solving.

      This post worked for me from the standpoint that my shebang line was not the first line. Oh the details!!!
Re: use: command not found error
by Krambambuli (Curate) on May 03, 2007 at 21:09 UTC
    What about line #1 ?

    If I'm right, you just have the shebang wrong, something like

    #/usr/bin/perl

    instead of

    #!/usr/bin/perl

    Sigh ;)
      I got the same problem. Later I found that the #!/usr/bin/env perl -w was not in the first line. It was like this
      # comments # comments # comments #!/usr/bin/env perl -w
      Then I changed the above to
      #!/usr/bin/env perl -w # comments # comments # comments
      It worked.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://613466]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2020-11-25 21:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?