Hello!
Help greatly appreciated.
I have the following code:
sub extractData { my @projects; push( @projects, [readOnly("$proj Data.txt"), "A"] ); unless( $pointerProj eq "NONE" ) { push( @projects, [readOnly("$pointerProj Data.txt"), "B"] ); } for( @projects ) { my @data = @{ $_[0] }; my $key = $_[1]; ... } } sub readOnly { my @contents; my $filePath; my $file; my $errMsg; $filePath = "$path\\" . $_[0]; $errMsg = "Unable to read $filePath: $!"; open $file, '<', $filePath or die $errMsg; @contents = <$file>; close $file; return @contents; }
My problem is that I'm not correctly passing the resultant array from readOnly() through the anon array pushed in to @projects to ultimately store and use it as @data inside the for-loop.
The error message I'm getting is "Can't use an undefined value as an ARRAY reference at (the first line inside the for-loop)".
If someone could provide me with the correct syntax and the rationale behind it I would be much obliged.
Thanks!
In reply to Passing Along Arrays by Perl_Ally
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |