my @data;
while (<>) {
my @fields = split ' ';
for my $row (0..$#fields) {
push @{$data[$row]}, $fields[$row];
}
}
use Data::Dumper;
print Dumper \@data;
17:12:41 0 0 0 100
17:12:42 0 1 0 99
17:12:43 0 0 0 100
>perl script.pl data
$VAR1 = [
[
'17:12:41',
'17:12:42',
'17:12:43'
],
[
'0',
'0',
'0'
],
[
'0',
'1',
'0'
],
[
'0',
'0',
'0'
],
[
'100',
'99',
'100'
]
];
PS — Please don't post links to a specific PerlMonks domain. There are more than one and most people are usually only logged in to one of them. Following that link would log them out. Using [id://643792] (How to swap rows with columns?) would be best.
|