[Omaha.pm] Burned be a one-liner

Jay Hannah jhannah at omnihotels.com
Fri Oct 20 11:40:29 PDT 2006


-laugh-

I was wondering why my report was wrong. 

Don't make this mistake. :)

j


$ cat j
A B
A B
XXX
B A
B A
$ cat j | perl -ne '/(\w) (\w)/; print "$1 $2\n";' | sort | uniq -c
      3 A B
      2 B A



----

Question:

There aren't 3 "A B" strings in my file. Why does my one-liner lie to
me?




Answer:

Because $1 and $2 are not cleared when the regex doesn't match on the
XXX line.


doh!



More information about the Omaha-pm mailing list