SPUG: No such file?

William Julien moonbeam at catmanor.com
Fri Jan 28 19:48:41 CST 2000

>What is going on here?
>When I run this program with "#!/usr/bin/perl -w" as the first line, I get
>this spew:
>bash-2.03$ app.pl
>Name "main::hash" used only once: possible typo at ./apptrieve.pl line 1137.
>Unquoted string "adm" may clash with future reserved word at (eval 1) line
>26, <CONFIG> chunk 36.
>Unquoted string "dev" may clash with future reserved word at (eval 1) line
>27, <CONFIG> chunk 36.
>Unquoted string "other" may clash with future reserved word at (eval 1) line
>29, <CONFIG> chunk 36.
>Okay, that's fine, I can deal with it.  But if I remove the "-w", I get
>bash-2.03$ app.pl
>bash: ./app.pl: No such file or directory

Let me guess. Was the program was written on a winbox and uploaded to a unix
server in binary mode? So, the unix shell sees the dos line end character
on the header. In a "real man's editor"... like uh, ... vi!; you would see:
"/usr/bin/perl^M".  Guess what... there is "No such file or directory"
by that name!

You may ask, but, why does this act differently when the "-w" parameter
is inserted on the shell header? The syntax for the normal unix getopt
processing allows for the grouping of parameters (-x -y == -xy). So,
perl parses the paramters of "-w^M" as "-w -^M".  This is why you saw the
normal warnings with the perl diagnostic checking enabled. I'm a little
surprised that perl didn't give an error on the invalid "-^M" parameter.
Perl 5.005_03 will abort on an invalid parameter error.

Moral: use ascii transfer for text files.

This is not as easy as it sounds. Some win9x ftp clients decide "for you",
because they run on the assumption that you are an idiot and you don't
know what you are doing. They use the extension to determine the transfer
method and they default to binary. There are a lot of windows programmers
who have never heard of perl.

Second Moral: Friends don't let friends use dos.
        _,'|            _.-''``-...___..--';
       /, \'.      _..-' ,      ,--...--'''
      < \   .`--'''      `     /| William Julien moonbeam at catmanor.com
       `-,;'              ;   ; ; http://www.catmanor.com/moonbeam/
 __...--''     __...--_..'  .;.'  vi is my shepherd; i shall not font.
(,__....----'''      (,..--''     
perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address

More information about the spug-list mailing list