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

Re: [MacPerl] WWWBoard and MacPerl



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!)

I suggest you translate the code to "native" perl.  Try:

  $date_command = localtime();

Note that the only difference will be that the localtime function does not
output the time zone field (as date would). Oh, and the output of `date`
comes with a newline (needs to be chomped); localtime doesn't.

% cat time.pl
#!/usr/local/bin/perl

$unix_date = `/bin/date`;
$perl_date = localtime();

print "$unix_date\n";
print "$perl_date\n";

% time.pl
Tue Aug 25 13:58:38 PDT 1998

Tue Aug 25 13:58:38 1998



---
Vicki Brown, vlb@cfcl.com        |\      _,,,---,,_
Journeyman Sourceror      ZZZzz /,`.-'`'    -.  ;-;;,_
Scripts & Philtres             |,4-  ) )-,_. ,\ (  `'-'
http://www.cfcl.com/~vlb      '---''(_/--'  `-'\_)
P.O. Box 1269 San Bruno, CA  94066

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch