in reply to split problem when emptiness is a valid element
How about
@fields = /([^|]*)\|?/g;
Update: You can even do:
my ( $f1, $f2, $f3, $f4, @v ) = /([^|]*)\|?/g;
defined will tell whether a field was provided or not.
length will tell whether a field was left blank or not.
|
|---|