in reply to Re: Spliting a delimited string into variables
in thread Spliting a delimited string into variables
Hi,
One other simpler way to make it works is to use regex memory as follow.
my $line="371540|4/07/2011|08:03|11:03|2|Company Name (MAIN SITE)|DB P +URGE|" if ($line =~ /(\d+)\|([0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4})\|([0-9]{1,2}\: +[0-9]{2})\|([0-9]{1,2}\:[0-9]{2})\|(\d+)\|((?:\w+)\s\w+\s(?:\()?\w+\s +\w+\))\|(\w+(?:\s)?\w+)/ ) { $item1=$1; $item2=$2; ... $item7=$7 }
Note that the regexp has to be adapted.
The parentheses captures their content.
First parenthese will be memorised as $1,
Second parenthese will be memorised as $2
etc...
|
---|