uberbiskit has asked for the wisdom of the Perl Monks concerning the following question:
When I try to run the script, I get the following errors:sub readVECFile($) { my ($filename, @fileData, $line, $vectorRef, $time, $data); local *VECTOR; # Get the filename. $filename = shift(@_); # Create a new hash. $vectorRef = { 'time' => \(), 'data' => \() }; # Open the vector file. open(VECTOR, $filename) or die("Unable to open '$filename' for reading +!\n"); # Read in the raw file data. @fileData = <VECTOR>; chomp @fileData; # Parse the time and data values out of each line, creating two arrays +. foreach $line (@fileData) { my ($t, $d); ($t, $d) = split(/\t/, $line); push(@{$vectorRef->{time}}, $t); push(@{$vectorRef->{data}}, $d); } # Close the file. close(VECTOR); return $vectorRef; }
Can't use string ("data") as an ARRAY ref while "strict refs" in use
The lines it is referencing are the 'push' lines in the foreach loop. What is going on and how do I do this while using 'strict'?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with array references and 'use strict'
by Abigail-II (Bishop) on Dec 02, 2003 at 14:28 UTC | |
|
Re: Problems with array references and 'use strict'
by hanenkamp (Pilgrim) on Dec 02, 2003 at 14:35 UTC | |
|
Re: Problems with array references and 'use strict'
by Hena (Friar) on Dec 02, 2003 at 15:15 UTC | |
|
Re: Problems with array references and 'use strict'
by ambrus (Abbot) on Dec 03, 2003 at 12:43 UTC |