Ronan wrote:
> I have a log file which will throw out the following
> 
> aa:bb cc:dd ee:"ff gg hh" ii:jj
> 
> ie pairs of text, colon seperated
> 2nd half is in quotes if there are spaces in it
> 
> I want to be able to read them into an array/table and work on them
> 
> how do i get it so I can have the pairs deined as
> 
> eg a two column table
> 
> aa   bb
> cc   dd
> ee   ff gg hh
> ii     jj

Is each colon-delimited pair on its own line to begin with?

If so...

my @table = ();

open(LOG, "/path/to/log/file") or die("Could not open log file:\n$!");
my @lines = <LOG>;
close(LOG);

for my $line (@lines)
{
        chomp($line);
        next unless $line =~ /^(.*?):"?(.*?)"?$/;

        push @table, [ $1, $2 ];
}

for my $row (@table)
{
        $bitbeforecolon = $row->[0];
        $bitaftercolon = $row->[1];

        dosomething_with($bitbeforecolon, $bitaftercolon);
}

-- 
Matthew.van.Eerde (at) hbinc.com               805.964.4554 x902
Hispanic Business Inc./HireDiversity.com       Software Engineer

Reply via email to