in reply to global vars and one liners

$ echo "foo bar baz qux foo foo bar baz qux" | perl -lne'@i{/\w+/g}=()}{print for keys%i' bar baz qux foo

Replies are listed 'Best First'.
Re^2: global vars and one liners
by AnomalousMonk (Archbishop) on Sep 15, 2009 at 14:36 UTC
    >perl -wMstrict -lne "@::i{ /\w+/g } = () }{ print for keys %::i" words2.txt bar baz qux foo
    OK, it works (Windose)! Now c'mon, how's it work? What's that strange  }{ thingy in the middle of it all? Can you give a documentation ref. for more info on that?

      It is so called eskimo operator: }{

      see perldoc perlrun about -n switch
      and compare output of the following two commands

      perl -MO=Deparse -ne "$a + $b" perl -MO=Deparse -ne "$a }{ $b"
      Note: double quotes because of Windows. Linux requires single quotes for the code given