Hi,
I have a file which has the output as shown below:
Code:
Teams | matches |Goals | YC | RC
------------------------------------------------------------------------------
Liverpool: | | | |
Gerrard | 97 | 100 | 41665 | 1342
Torres | 75 | 90 | 1929 | 630
Babel | 86 | 80 | 10621 | 1666
carregher | 93 | 40 | 1901 | 146
| | | |
Chelsea: | | | |
Lampard | 40 | 459 | 172 | 264
Terry | 22 | 459 | 96 | 341
Cole | 52 | 459 | 223 | 213
| | | |
Manutd: | | | |
Roooney | 85 | 59 | 48 | 8.6
Berba | 44 | 67 | 28 | 36
Giggs | 35 | 130 | 43 | 81
Scholes | 33 | 917 | 281 | 591
I need to extract the Info from the RC column for the first 4 players of liverpool.
The test code i have does the same,but can anyone show me a better way of doing it.I could do it easily with gawk -F"|" and print the respective column,but i need to do this in perl.. Its just a test code and the naming convention sucks. Thanks a bunch
Code:
#!/usr/bin/perl
use strict;
use warnings;
open (FH,'<','/local/a/tmp/disk.log') ;
my @x=<FH>;
my $i=1;
my @arr;
my @newarr;
# Reading the lines,where the 4 pool players occur.
foreach (@x) {
$i++;
next if ($i ~~ [1..4]);
push (@arr,$_) if ($i<='8');
}
my $count=0;
while ($arr[$count]) {
my @lol=split(/ /,$arr[$count]);
push(@newarr,(join("","$lol[-4]","$lol[-5]")));
$count++
}
Output: