Can't create 2d array in Perl
- From: gps@xxxxxxxxxxx (Gregg Allen)
- Date: Tue, 29 Aug 2006 18:01:33 -0600
Hi:
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. The $i and $j, along with the print statement, are only for debugging purposes.
It prints:
Can't use string ("") as an ARRAY ref while "strict refs" in use at file_vars.pl line 30, <FH> line 2.
Gregg Allen
*********************************************************
#!/usr/bin/perl -w
use strict;
my @arr ;
my $i = $ARGV[0];
my $j = $ARGV[1];
print $i . " \t" . $j . "\n";
open(FH,"<0817L.txt") or die "cannot open !$\n";
while(<FH>)
{
push @arr , split /\t/ ;
}
print $arr[$i][$j];
.
- Follow-Ups:
- Re: Can't create 2d array in Perl
- From: Klaus
- Re: Can't create 2d array in Perl
- From: Mumia W.
- Re: Can't create 2d array in Perl
- Prev by Date: Re: called too early?
- Next by Date: Re: Switch, Ranges and Memory
- Previous by thread: Switch, Ranges and Memory
- Next by thread: Re: Can't create 2d array in Perl
- Index(es):
Relevant Pages
|