in reply to Repeat match
you want a hash output asjsdlkjalsd same_text = 1, jhhj, jhjk = 256, iuqoi, uereoiu, sjksdh, s +ame_text = 2, lkkj, lksj = 6287 uwie same_text = 2, sdaj, jsdgd, sksd
If I am correct then you can use the below perl code.For the key "1" the value should be "jhhj, jhjk" For the key "2" the value should be "lkkj, lksj , sdaj, jsdgd"
use Data::Dumper; open(FH,"x.txt") or die("Can't open the file: $!"); $/=EOF; my $var = <FH>; my %hash=(); while ($var =~ /(same_text\s=\s\d),((\s\S+){1,2})/gi) { my ($junk,$ky)=split(/=/,$1); push(@{$hash{$ky}},$2); } map { print "$_ -- @{$hash{$_}} \n "; } keys %hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Repeat match
by Anonymous Monk on Jan 30, 2007 at 13:16 UTC |