Can't create 2d array in Perl



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];

.



Relevant Pages

  • Re: Cant create 2d array in Perl
    ... I would like to read a tab delimited text file created in Excel into a 2d array. ... use strict; ... use warnings; ...
    (perl.beginners)
  • Re: I believe Ive found an Access bug...can anyone confirm?
    ... Set objXL = CreateObject ... and use the Excel function from Access. ... Dim IRRValues() As Variant ' Set up array. ...
    (microsoft.public.access.modulesdaovba)
  • Re: How to calculate frequency of lottery numbers?
    ... Microsoft MVP Excel ... I downloaded the previous 100 PowerBall games ... array K1:K59. ... histogram to visually display the frequencies ...
    (microsoft.public.excel.newusers)
  • Re: creating Excel Application Object in C#?
    ... This article demonstrates how to automate Microsoft Excel by using ... you can retrieve a two-dimensional array of values for ... errorMessage = String.Concat(errorMessage, ...
    (microsoft.public.excel.programming)
  • Re: Excel find row data in every column
    ... Since that you already have the data in Excel I really think you ought to ... 'Find the value strname in the range set ... Set objSearch = cols.Find ... Can I create an array and then search that array for values contained ...
    (microsoft.public.scripting.vbscript)