:> Due to odd quoting rules, I suggest using "" on Windows, and '' on 
UNIX. Choose to use qq() or q() instead of escaping for either.

Well, not trying to inflame the winx v *nix wars soYMMV but I've always 
had troubles getting command line scripts to run in cmd.exe
C:\Documents and Settings\andy>perl -e 'print("Hello world.\n");'

C:\Documents and Settings\andy>
C:\Documents and Settings\andy>perl -e "print(\"Hello world.\n\");"
Hello world.

C:\Documents and Settings\andy>perl -e "print qq(Hello world.\n);"
Hello world.

Cutnpasted all 3 there produce the appropriate result on linux.
On *nix you can actually do multi-line programs from the command line, 
as a <Enter> inside of surrounding quotes doesn't end the command
# perl -e 'print "hello world\n";
print "goodbye quotes\n";
print "even in the
\tquote\n";
'
hello world
goodbye quotes
even in the
        quote
#

A different issue on *nix is '$' interpolation.  This works on winx 
(note dbl quotes script surrounders):
perl -e "$hi = qq(Hello world.\n); print $hi"

but fails in linux as '$hi' gets replaced by whatever's in the shell's 
'$hi' env var, probably nothing:
# perl -e "$hi = qq(Hello world.\n); print $hi"
syntax error at -e line 1, near "="
Execution of -e aborted due to compilation errors.

perl see's a script like:
= qq(Hello world.\n); print

You need to use single quotes to protect the program from being interpolated
# perl -e '$hi = qq(Hello world.\n); print $hi'
Hello world.

That one gets a different error on winx
C:\Documents and Settings\andy>perl -e '$hi = qq(Hello world.\n); print $hi'
Can't find string terminator "'" anywhere before EOF at -e line 1.

I think the semicolon acts as a line ending or comment, maybe?  But this 
is the sort of error that made me give up on winx cmd lines scripting.

a
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to