Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: perl and linux

by mandog (Curate)
on Oct 26, 2003 at 19:47 UTC ( #302251=note: print w/ replies, xml ) Need Help??


in reply to perl and linux

A couple other things you might consider:

  • You also need a shbang line
  • You might not want to change your path to include the '.'

The shbaing line tells Linux and your shell where to find perl so it can run your script. Somethingn like this:

'#!/usr/bin/perl -w '

...as the very first line of your script. Don't include the quotes, but do include the space after the -w

The -w and the space are not strictly necessary but they are useful.

The -w will give you helpful extra error messages. For more details see: perldoc perlrun

The space will help prevent problems FTPing files from a MS WIndows machine to a UNIX machine. MSW ends lines with an invisible pair of charactors \r\n (or return newline). Unix doesn't see a \r as very special. It is like an 'z' or 'p' If you create the file on WIndows, UNIX will see the shbang line as:

#!/usr/bin/perl -w\r

give you an error message and refuse to run. The reason is that -w\r is not a valid argument to perl like -w However if you put a space (but no quotes) after the -w Perl & UNIX will treat the \r like whitespace and ignore it.

You might not want to put the '.' into your path to avoid other peoples evil programs. If the directory you are currently in is first in your path, programs in your path. Suppose you do this:

cd ~buddy ls

suppose your friend has a script like this:

#!/bin/sh rm ~/* -rf echo ha ha ha

You may be better off running programs in the current directory explicitly:

 ./myscript.pl


Comment on Re: perl and linux
Select or Download Code
Re: Re: perl and linux
by Anonymous Monk on Oct 27, 2003 at 21:30 UTC
    Thanx for everyone's suggestions. I did have one more question along the same lines. Following the tutorial as recommended in the beginning, I should have put "LIB=~/lib" in as an modifier for the makefile.pl instruction the first time I ran MCPAN and it asked me for all of the system values etc. I did not, how do I get it to reask me all those questions?

    -Kevin

      How do I get CPAN to ask me the configuration questions

      locate CPAN/Config.pm $EDITOR /path/to/CPAN/Config.pm

      if updatedb hasb't run, you'll have to use find

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://302251]
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: (4)
As of 2014-09-02 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (18 votes), past polls