in reply to Before getopts...

I was not able to get this to work on win32 but I'm not surprised, as win32 (and me) have had bad luck w/ -e for a long time. I guess its not obfust. enough, I almost get it. Well, after looking up -s ... ;->

a

Replies are listed 'Best First'.
(tye)Re: Before getopts...
by tye (Sage) on Jan 04, 2001 at 22:41 UTC

    This works on Win32:

    perl -e "$$_==1 && print for sort keys %main::" -s -- -" Just" -" anot +her " -"Perl " -"hacker,"
    Note the two quirks: 1) using " instead of ' and 2) cmd.exe always adds an extra newline for you.

            - tye (but my friends call me "Tye")
      and no '-s' which was part of the fun. Actually, -le gives me:
      Just
      Another
      Perl
      Hacker

      and -se gets (just like -e alone):
      Just Another Perl Hacker

      Guess I'll be looking up -l now ... Oh, sets $\ to $/ so that makes sense.

      a

        But there is a -s in tye's one-liner... It wouldn't work otherwise.
Re: Re: Before getopts...
by chipmunk (Parson) on Jan 04, 2001 at 19:29 UTC
    This one requires a bash-like shell, that allows quoted strings to continue across line endings. Here's a one-liner version: perl -le 'print sort grep $$_ eq 1, keys %main::' -s -- -' Just' -' another ' -'Perl ' -'hacker, '