This JAPH signature highlights a seldom-used feature of perl, the -s option:
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball) perl -e '$$_ == 1 && print for sort keys %main:: ' -s -- -' Just' -' another ' -'Perl ' -'hacker, ' http://linguist.dartmouth.edu/~rjk/ [rjk@linguist.dartmouth.edu]

Replies are listed 'Best First'.
Re: Before getopts...
by a (Friar) on Jan 04, 2001 at 10:42 UTC
    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

      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

      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, '