in reply to Conditional split?

( Please put code in <c>...</c> tags. )

( Please don't lie by saying your code outputs one thing when it doesn't even compile. Post the code you actually ran. )

The splitting occurs because "=====" is indeed not equal to "==.*". It's one character longer, for starters. Fix:

while (<>) { chomp; my @a; @a = split if !/^==/; print "@a\n"; }

But it makes no sense to process @a if you didn't put anything in it. Maybe you want

while (<>) { chomp; next if /^==/; my @a = split; print "@a\n"; }

Replies are listed 'Best First'.
Re^2: Conditional split?
by chiragmp (Initiate) on Apr 07, 2009 at 23:10 UTC
    ( Please put code in ... tags. ) I have done that now. ( Please don't lie by saying your code outputs one thing when it doesn't even compile. Post the code you actually ran. ) Sir/madam..."Lie" is a pretty strong accusation! I agree I was missing ";" at the end of  @a = split if ($_ ne "==.*") which was causing the abort but that wasn't intentional. You may see that this was my first post and I came here thinking I would get some good advise; I most certainly do not need someone calling me names!
      very nice human being!!!
Re^2: Conditional split?
by chiragmp (Initiate) on Apr 07, 2009 at 22:51 UTC
    Thanks ikegami. The "next" approach is what I was looking for. With @a = split if !/^==/; I got the next line printed twice.