NT v. unix (was Re: LPM: Happy ...)

David Hempy hempy at ket.org
Mon Jan 3 10:33:31 CST 2000


At 09:55 AM 1/1/2000 -0500, Rich wrote:
>> perl -e '@time = localtime; print $time[5], "\n"' ;
>100
>

Hmm... Trying to figure out why this didn't work on my machine:

>D:\src>perl -e '@time = localtime; print $time[5], "\n"' ;
>Can't find string terminator "'" anywhere before EOF at -e line 1.
>
>

While on unix:

>cooper 1$ perl -e '@time = localtime; print $time[5], "\n"' ;
>100
>cooper 2$
>

So, a little playing around on WinNT finally finds a working solution:

>D:\src>perl -e '@time = localtime; print $time[5], "\n"' ;
>Can't find string terminator "'" anywhere before EOF at -e line 1.
>
>D:\src>perl -e '@time = localtime; print $time[5]; '
>Can't find string terminator "'" anywhere before EOF at -e line 1.
>
>D:\src>perl -e '@time = localtime; print $time[5], "\n"; '
>Can't find string terminator "'" anywhere before EOF at -e line 1.
>
>D:\src>perl -e "@time = localtime; print $time[5], '\n'; "
>100\n
>D:\src>perl -e "@time = localtime; print $time[5], \"\n\"; "
>100
>
>D:\src>
>

I'm not exactly clear where the breakdown is.  Something to do with the
treating of the ' (single quote) quoting, I suspect by the command
interpreter.  It appears that (at least) one of the single quotes is making
it to perl.  Is this the expected behavior under unix?  I would have
expected the entire string to come in as a single element of @ARGV, with
the quotes already stripped.  This is just a hunch, and clearly not the
case on NT, anyway.

Illumination, anyone?

Also, the final, working version I have for NT doesn't work on unix:

>cooper 3$ perl -e "@time = localtime; print $time[5], \"\n\"; "
>Unmatched "
>cooper 4$ 

Flailing about a bunch of escapes doesn't seem to help:
>cooper 7$ perl -e "@time = localtime; print $time[5], \\\"\\\n\\\"; "
>Unmatched "
>cooper 8$ perl -e "@time = localtime; print $time[5], \\"\\n\\"; "
>time - Undefined variable
>cooper 9$ 


Can anyone show me a platform-independent version of this command line script?

-dave


--
David Hempy
Internet Database Administrator
Kentucky Educational Television




More information about the Lexington-pm mailing list