[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: pidgen perl (was: WWWBoard and MacPerl)



On Tue, Aug 25, 1998, at 14:00, Vicki Brown wrote:
>At 14:32 -0500 98/08/25, Marcel Brown wrote:
>> it looks like I'll be fine except for one thing I'm not sure of. In the
>> variable definition section, it has this line:
>>
>> $date_command = "/bin/date";
>
>A lot of Unix people who are new to perl tend to write what amount to Unix
>shell scripts in a funny sort of pidgin perl.  That is, they still use
>date, echo, rm, mv, ... when they could (should :-) use the Perl functions.
>
>(This is even bad pidgin code; better pidgin code would have exploited the
>fact that the date command is on the search path under Unix.  The /bin/
>part is unnecessary and makes the script less portable even to other Unix
>environments!)
>-- End of excerpt from Vicki Brown (vlb@cfcl.com)

Actually, it appears that it may be _good_ pidgen code.  If you are writing
a script to be run by other people, it is generally considered bad form to
depend on the search path because your script could be broken or subverted by
a sufficiently perverse path.  Thus, if you want your script to be reliable,
you use absolute command paths rather than depending on the search path
(unless, of course, you set the path yourself).  To reduce the cost of porting
such a script to a new platform, one approach is to put the absolute path
information in variables near the beginning of the program instead of at
the point it is used.  This program appears to be doing exactly that.

Having said all that, it is better still if you can avoid using external
commands, so the thrust of Vicki's suggestions (although not all of the
details) is correct.

-- 
Kurt W. Hirchert     hirchert@ncsa.uiuc.edu
National Center for Supercomputing Applications