* Hunter Marshall ([EMAIL PROTECTED]) wrote: > I am a long time debian and perl user. But obviously long enough! > Forgive the slight misuse of the list, but can anyone shed light > on what I'm doing wrong in this attempt to find \n\n in a text file > with perl? I'm sure I've done this before. > > Thanks > > hunter > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > [EMAIL PROTECTED]:/tmp > -> cat junk > hi > > > > > > > [EMAIL PROTECTED]:/tmp > -> od -x junk > 0000000 6968 0a0a 0a0a 0a0a 000a > 0000011 > [EMAIL PROTECTED]:/tmp > -> perl -n -e 'print "yup\n" if /\x0a/;' junk > yup > yup > yup > yup > yup > yup > yup > [EMAIL PROTECTED]:/tmp > -> perl -n -e 'print "yup\n" if /\x0a\x0a/;' junk
I'm not sure what you want the result to be but here are my two assumptions: 1.) You want perl to print yup 4 times ie. 0a0a is 1 unit, there are four yup; so here is how i did it: perl -ne 'print "yup\n" if /(\x0a)$1/;' junk result: yup yup yup yup 2.) You just want one yup meaning yes there is an x0a in there: perl -ne 'print "yup\n"; last, if /\x0a/;' junk result: yup I hope this helps. Juan Fuentes