You attempt to read from $data, yet never open it that file handle.
You changed the initial content of @data. (It should be empty.)
DATA shouldn't be used as an all-purpose file handle. It's a special file handle.
Fix:
#!/usr/bin/perl -w use strict; my $data_qn = 'data_file'; open($data_fh, '<', $data_qn) or die("Unable to open plot data \"$data_qn\": $!\n"); my @data; while (<$data_fh>) { my @fields = split ' '; for my $row (0..$#fields) { push @{$data[$row]}, $fields[$row]; } } use Data::Dumper; print Dumper \@data;
Update: Oops, forgot to re-add the my @data; that was removed. Fixed.
In reply to Re^3: How to swap rows with columns? - Still unresolved :(
by ikegami
in thread How to swap rows with columns? - Still unresolved :(
by perl_geek
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |