Hi!
i have multiple accouts with account number (right now upto 3 digits) in coulmn 1 and different entries separated by single space and ending with the .ca1
the number of entries differ for each account and i dont know before hand how many there would be per account.
i want to change the array format as shown below. so far, i have tried 2 different ways, one using regular expression and the other using hash. but both scripts needs improvement.
can any body help.
thanks in advance
Input
Account10 L6_VI_TI0S000007796.ca1 L5_VI_TI0S0000077912.ca1 L4_VI_TI0S00000779.ca1
Account1 L6_VI_TI0S000007793.ca1 VIT_S0_S0_0000779.ca1
Account120 VITIS0S00000779234.ca1 VITIS0S000007792.ca1
expected Output
Account10 L6_VI_TI0S000007796.ca1
Account10 L5_VI_TI0S0000077912.ca1
Account10 L4_VI_TI0S00000779.ca1
Account1 L6_VI_TI0S000007793.ca1
Account1 VIT_S0_S0_0000779.ca1
so far.....
#!/usr/bin/perl-w
open(DATA, "<into.txt");
while (<DATA>){
chomp;
/(Account\d{1,3})\s(.*.ca1)/;
print "$1\n$2\n\n";
}
and.......
#!/usr/bin/perl-w
open(DATA, "<into.txt");
while (<DATA>){
chomp;
($Account, $grade) = /(Account\d{1,3})\s(.*.ca1)/;
$entries{$Account} .= $grade . ab1; }
foreach $Account (sort keys %entries) {
print "$Account\n$entries\n\n";
}
i have multiple accouts with account number (right now upto 3 digits) in coulmn 1 and different entries separated by single space and ending with the .ca1
the number of entries differ for each account and i dont know before hand how many there would be per account.
i want to change the array format as shown below. so far, i have tried 2 different ways, one using regular expression and the other using hash. but both scripts needs improvement.
can any body help.
thanks in advance
Input
Account10 L6_VI_TI0S000007796.ca1 L5_VI_TI0S0000077912.ca1 L4_VI_TI0S00000779.ca1
Account1 L6_VI_TI0S000007793.ca1 VIT_S0_S0_0000779.ca1
Account120 VITIS0S00000779234.ca1 VITIS0S000007792.ca1
expected Output
Account10 L6_VI_TI0S000007796.ca1
Account10 L5_VI_TI0S0000077912.ca1
Account10 L4_VI_TI0S00000779.ca1
Account1 L6_VI_TI0S000007793.ca1
Account1 VIT_S0_S0_0000779.ca1
so far.....
#!/usr/bin/perl-w
open(DATA, "<into.txt");
while (<DATA>){
chomp;
/(Account\d{1,3})\s(.*.ca1)/;
print "$1\n$2\n\n";
}
and.......
#!/usr/bin/perl-w
open(DATA, "<into.txt");
while (<DATA>){
chomp;
($Account, $grade) = /(Account\d{1,3})\s(.*.ca1)/;
$entries{$Account} .= $grade . ab1; }
foreach $Account (sort keys %entries) {
print "$Account\n$entries\n\n";
}