Perl problems

Alf-Ivar Holm alfh at student.matnat.uio.no
Fri May 13 11:09:59 UTC 2005


"ZIYAD A. M. AL-BATLY" <zamb at saudi.net.sa> writes:

>      5. When the others said do "sh secede2.p name.txt", what really
>         happend is that you run/execute the "sh" and pass to it
>         "secede2.pl name.txt" as variables.  

Correct so far.

>      "sh", in turn, will check the first line of "secede2.pl" and
>      see the "#!/usr/bin/perl" and will execute that application and
>      pass to it "name.txt" as variable.  

When sh¹ is started with a file name as argument, it tries to parse
the file as shell commands.  It does _not_ look for magic strings (!#
in this case) in the file, it just try to execute each line, where the
first line will be taken for a comment in sh.

>      This why you don't need "secede2.pl" to be executable in this
>      case, and you don't need to till "sh" it's as "sh", by default,
>      will search *only* in the current directory.

Indeed, the executable bit is not important in this case, but the
command "sh secede2.pl" will most probably fail big time, since Perl
commands are given to a shell interpreter.  "perl secede2.pl" on the
other hand, is the correct way of a non-magic run of the perl program.

	Affi

¹) For Ubuntu, sh is actually a link to bash(1) and not Bourne Shell,
which is what sh usually designates.




More information about the ubuntu-users mailing list