P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
While the OP mentions fetching the first field, you'll notice the OP used $fields[1], not $fields[0]. I believe that means he's using split to parse a single-quoted string. That's not what I'd call an appropriate use of split. So in this case, the optimal split would be
Using split requires matching twice, creating three variables and copying the entire string.
Using the match operator requires matching once, creating one variable and copying only the field. Actual performance aside, it's definitely a cleaner process. Finally, split will be very bad at handling escaping when the OP discovers the need for it.
An operand doesn't know what the caller will do with the returned list, so your "maybe" doesn't apply. If it behaves as you think, the following snippet will result in $c being assigned 2 when it should be assigned 3.
In reply to Re^3: how to speed lookups?
by ikegami
|
|