Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: Re: Re: Re: "bareword found near www" in oneliner

by Anomynous Monk (Scribe)
on Feb 09, 2004 at 15:53 UTC ( #327648=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: "bareword found near www" in oneliner
in thread "bareword found near www" in oneliner

I think you completely misunderstand "support" here. Windows's cmd.exe "supports" single quotes, just like it supports a, b, 3, 7, 9, and =. They are just ordinary characters. A double quote has an entirely different kind of support. It will allow having spaces or other special characters as part of a command argument instead of their normal interpretation (where a space, for instance, would mean a break between arguments) and doesn't itself become part of the argument.

C:\windows\system32>c:/perl/bin/perl -we'print "Hello World\n"' Can't find string terminator "'" anywhere before EOF at -e line 1.
Here, perl is getting as it's first argument "-we'print". It interprets the -w and -e switches, and finds that the code supplied for -e is the beginning of a single-quoted perl string, but with no end-quote, causing the error, just as if you had a perl program file consisting of just:
'print
If you add -leBEGIN{for(@ARGV){print$_}} before the -we, you can see that the space causes what comes after to become a separate argument to perl:
C:\windows\system32>c:/perl/bin/perl -leBEGIN{for(@ARGV){print$_}} -we +'print "Hello World\n"' Hello World\n' Can't find string terminator "'" anywhere before EOF at -e line 2.
If you think cmd.exe does something special with single quotes, show an example.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: "bareword found near www" in oneliner
by Anneq (Vicar) on Feb 09, 2004 at 17:10 UTC
    It's entirely possible that I'm missing something here, but I thought I answered the OP's requirement. The original command line code was:
    perl -MURI::Escape -MLWP::Simple -e "$t = get "http://www.cgiscript.ne +t/encrypt_index.htm"; print uri_unescape $t;"

    Since his double quoted string (the URL) doesn't have any escaped characters in it, he should be able to get away with using single quotes around it.

    The following works at the command line:

    $perl -we"print 'http://somewhere.com'"

    If I'm missing something, please excuse my newness at this.

    Regards,
    Anne
      Sorry for giving you a hard time. In:
      perl -we"print 'http://somewhere.com'"
      perl is supporting the ' as a special character (that quotes a non-interpolating string), not Windows.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://327648]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2022-06-25 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (81 votes). Check out past polls.

    Notices?