in reply to Advantage of while(<>){while()}?

That would make the two roughly equivalent, right?

Again, it can result in drastically different matches. Consider a poor man's CSV parser, «$regex = qr/[^,]*/;». A file with lines foo,far and boo,bar has four fields (over two lines) using one and three fields using the other.

Replies are listed 'Best First'.
Re^2: Advantage of while(<>){while()}?
by Argel (Prior) on May 18, 2011 at 22:21 UTC
    Even if I'm slurping the entire file in in both cases (local $/)?

    Elda Taluta; Sarks Sark; Ark Arks

      Oh, I didn't notice that you added local $/; to the first snippet too!

      local $/; while (<>) provides error checking (empty file, read error) that local $/; $_ = <>; doesn't.

        My fault for leaving the $/ part out originally! Been looking at this code for too long. :(

        Elda Taluta; Sarks Sark; Ark Arks