At 10:21 AM 6/29/01 +1000, Sam Lander wrote: > >> At a shell prompt / command line, enter: > >> > >> perl -ne '/string/ or print' file > >> > >> where string is the string and file is the file. > > > >I prefer 'print unless /string/'. > >As if it matters. ;o] > >I wanted to do this just today. Although, I want to tidy up the resulting >line a bit by deleting everything before a colon, so I tried this: > perl -ne "/string/ && print s/.*://" file >I was surprised that I got this: > 1111111111111111111111111111111111111111111 (one '1' for each match) >A bit of playing gave me: > perl -ne "/Recipient/ && s/.*:// && print" >Which gave me what I wanted, but is rather unsatisfying (esp to the sedder >in me). >What do other people do? Shouldn't DWIM come into play here? The trouble is that WYM is likely to be different for these cases: if (s/foo/bar/) { ... } print s/foo/bar/; Perl 6 will be able to tell (easier) whether it's in a numeric or boolean context rather than a string context and maybe the designers will consider this possibility. I know that I have repeatedly had to change a map s/foo/bar, ... into a map { s/foo/bar/; $_ } ... so it's not just what YM. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com