in reply to simple regex question

Assuming that you want just the lines that have 1 and then whitespace after that, and then text the following code will work

if (/^1\s+/) { print FILE, "$_\n"; }
Life? What's a life?

Replies are listed 'Best First'.
Re: Re: simple regex question
by Chmrr (Vicar) on Mar 03, 2001 at 07:37 UTC
    A more general solution might be /^1\b/. Of course, the previous suggestion will almost certainly work also, but in the spirit of TIMTOWTDI, and not fully knowing the format of the data..

     
    perl -e 'print "I love $^X$\"$]!$/"#$&V"+@( NO CARRIER'

      A more general solution might be /^1\b/.

      ...or, borrowing from Tuna below: /^1\D/.

      p
      I was thinking about that too, actually
      Life? What's a life?
Re: Re: simple regex question
by Rudif (Hermit) on Mar 04, 2001 at 03:37 UTC
    Life? What's a life?
    anagram of a file? an ordered sequence ending with EOL?