List Info

Thread: Re: What am I doing wrong here?




Re: What am I doing wrong here?
country flaguser name
United States
2007-08-31 22:19:34

:> 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 Settingsandy>perl -e 'print("Hello world.n");'

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

C:Documents and Settingsandy>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&gt; inside of surrounding quotes doesn't end the command
# perl -e 'print "hello worldn&quot;;
print "goodbye quotesn&quot;;
print "even in the
tquoten";
'
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 "=&quot;
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 Settingsandy>perl -e '$hi = qq(Hello world.n); print $hi'
Can't find string terminator "'&quot; 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

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )