Accessing files with perl

Hello i am new to Perl and i have a question.

I am trying to read a file that has the following format:

14/4/2008 8:42:03 |10800|306973223399|4917622951117|1||1259|1|126|492|433||19774859454$
14/4/2008 9:13:08 |10800|306973223399|306970097423|1||1264|1|126|492|878||19774859762$
14/4/2008 9:15:38 |10800|306973223399|E-MAIL|1||1270|1|126|492|903||19774859792$
14/4/2008 9:05:50 |10800|306973223399|306973223323|1|34||0|133|2530|816|4139063897|19775160876$
14/4/2008 8:15:57 |10800|306973223399|306974439999|1|0||1|3|500|878|019D096290|19775241815$
$

I read the first line and i add the line to an array using the following code;

sub parse_csv {
    my $text = shift;
    my @new  = ();
    push( @new, $+ ) while $text =~ m{
       "([^\"\\]*(?:\\.[^\"\\]*)*)",?
           |  ([^|]+),?
           | ,
       }gx;
    push( @new, undef ) if substr( $text, -1, 1 ) eq ',';
    return @new;

The problem is that when in the file (for example line 2) two "||" exists the null value is not added to the array. So in the array less fields exist. How can i modify the code above in order for the null values to be addede in the array as well.

Thank you very much fo your help!

Don't use a regex; just split on the separator character.

@new = split ("\|");

Looks like he tried to hack a CSV parsers to parse a pipe delimited file. I agree with era, just use split();