in reply to Parse tags into an array
I suppose you mean "associative" array, that is a "hash" in Perl.
Instead of relying on nifty regexes to process whole records in one string I'd rather prefer using a flip-flop like demonstrated here: Re: Parsing file and joining content into string to read al tags from TAGSTART through TAGEND
in the if part do something like
@tag = split ' ', $line, 2; $field{ $tag[0] } = $tag[1];
and in the else part
$bill{ $field{ACCOUNT} } = $field{BILLAMOUNT} if %field; %field = ();
IMHO this is a more robust and better maintainable approach.
UPDATE:
For instance if you ever need to retrieve all data per account just do
$bill{ $field{ACCOUNT} } = { %field } if %field; %field = ();
Cheers Rolf
|
|---|