G
Guy
I have a 20KB txt file of data that looks something like this: lines of
tab-separated fields.
001 jan2009 house
002 jan2008 barn
003 jun2007 trees
004 mar2006 garden
005 apr2003 lake
006 jul2001 mountain
I'd like to load the entire file in an array and be able to refer to
specific fields in specific records, such as the 1st field of the 4th item.
I tried this but it obviously doesn't work. Can anyone show me the trouble?
It would be much appreciated.
Guy
#!/usr/bin/perl
my $pfil="photos.txt";
my @records;
my $data = \@records;
my $total;
if (open(FIL, $pfil))
{
$total=0;
while (<FIL>)
{
$records[$total] = split(/\t/);
$total++;
}
close FIL;
}
print "$data->[3][0] \n";
tab-separated fields.
001 jan2009 house
002 jan2008 barn
003 jun2007 trees
004 mar2006 garden
005 apr2003 lake
006 jul2001 mountain
I'd like to load the entire file in an array and be able to refer to
specific fields in specific records, such as the 1st field of the 4th item.
I tried this but it obviously doesn't work. Can anyone show me the trouble?
It would be much appreciated.
Guy
#!/usr/bin/perl
my $pfil="photos.txt";
my @records;
my $data = \@records;
my $total;
if (open(FIL, $pfil))
{
$total=0;
while (<FIL>)
{
$records[$total] = split(/\t/);
$total++;
}
close FIL;
}
print "$data->[3][0] \n";