isn't particularly useful since you're assigning a scalar list reference to an array (meaning that you'll always end up with a single-element array.) Something like this would make more sense:my @data = [1,5,7,8,9,10,11,3,3,5,5,5,7,2,2];
I'm going to make some assumptions here about what you're trying to do; please feel free to correct any false ones. If you're trying to read a file that is composed of lines with comma-separated values, and where each line should be read in as a list reference of the above type, then something like this should be useful:my $data = [1,5,7,8,9,10,11,3,3,5,5,5,7,2,2];
Each of the elements of @data will be a reference to a list containing the values on each line.use strict; open my $fh, '<', 'file' or die "file: $!\n"; my @data; while (<$fh>){ chomp; push @data, [split /,/]; }
In reply to Re: How to get data to an array?
by flightdm
in thread How to get data to an array?
by buchi2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |