Re: Can't create 2d array in Perl
- From: "Klaus" <klaus03@xxxxxxxxx>
- Date: 29 Aug 2006 17:46:32 -0700
Gregg Allen wrote:
I would like to read a tab delimited text file created in Excel into
a 2d array. I don't understand why the following doesn't work.
It prints:
Can't use string ("") as an ARRAY ref while "strict refs" in use at
file_vars.pl line 30, <FH> line 2.
[snip]
while(<FH>)
{
push @arr , split /\t/ ;
You just need a pair of "[" ... "]" around "split /\t/", that's all:
push @arr, [ split /\t/ ];
(for reference --> see perldoc perldsc)
}
print $arr[$i][$j];
.
- References:
- Can't create 2d array in Perl
- From: Gregg Allen
- Can't create 2d array in Perl
- Prev by Date: Re: Can't create 2d array in Perl
- Next by Date: Re: splitting strings
- Previous by thread: Re: Can't create 2d array in Perl
- Next by thread: Re: Can't create 2d array in Perl
- Index(es):
Relevant Pages
|
|