[Kc] perl -e syntax Win32

Shlomi Fish shlomif at iglu.org.il
Sat May 26 04:16:46 PDT 2007


Hi djgoku!

On Friday 25 May 2007, djgoku wrote:
> So I was trying to create my first one liner today on a Windows Box:
>
> Code:
>
> C:\>perl -wT -e 'print "hello world";'
> Can't find string terminator "'" anywhere before EOF at -e line 1.
>
> I at first thought it was due to " or ' around "hello world" so I try
> both ways still same error. Secondly, I thought if I change the outer
> single quotes to double that might work? Well it did work.
>

The Windows CMD.EXE does not support single quotes as delimiter. It is one of 
his many failings that date back to its heritage as the MS-DOS command.com 
excuse-for-a-shell.

Do yourself a favour and download cygwin and its bash or zsh, or alterantively 
zsh for Windows - 

http://unxutils.sourceforge.net/

Else, please don't use one-liners from the CMD.EXE command line. It's painful 
at best and dangerous at worst.

Regards,

	Shlomi Fish

P.S: and stay away from csh or tcsh. They are horrible shells. Completely 
unsuitable for scripting, and not much better (and often much worse) than bas 
or zsh for interactive use.

> So I started to write the one-liner!
>
> C:\> program_output | perl -wT -e "$_ = /\"(\w+)\"/; print $1;"
>
> program_output outputs a string like test: "blah1232" and all I want
> is blah1232.
>
> After figuring out the single/double quote problem I found this:
>
> http://tinyurl.com/25gpxz
> _______________________________________________
> kc mailing list
> kc at pm.org
> http://mail.pm.org/mailman/listinfo/kc



-- 

---------------------------------------------------------------------
Shlomi Fish      shlomif at iglu.org.il
Homepage:        http://www.shlomifish.org/

If it's not in my E-mail it doesn't happen. And if my E-mail is saying
one thing, and everything else says something else - E-mail will conquer.
    -- An Israeli Linuxer


More information about the kc mailing list