It's really basic and straightforward but a least you immediately know what's going on.my $str =" [India] Captain1 = Dhoni Batsman1 = Sachin Bowler1 = Zaheer [Aussie] Captain = Ponting Batsman = Clarke Bowler = Warne [Aussie] Captain = Hussey Batsman = Waugh Bowler = Mcgrath"; my @l = split "\n", $str ; my $key ; my %rez ; for my $it (@l) { next if $it =~ m /^$/ ; if ($it =~ m/^\[(.*)\]/) { $key = $1 } else { my @t = split "=", $it ; $rez{$key}{ $t[0] } = $t[1] } } use Data::Dumper ; print Dumper \%rez ;
edit : did not see that the aussie section was duped, you could always if define $rez{$key} etc ...
In reply to Re: String split problem
by ZlR
in thread String split problem
by santosh_vjit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |