indapa has asked for the wisdom of the Perl Monks concerning the following question:
Basically I'm reading files into an array, modifying them, and writing the new output to a new file. The trouble is that my new output file(s) only has one line in it (there should be 96 lines of output).@MLR_file = <MLR>; # read in file 1 data $MLR_file[2] =$MLR_file[1] = $MLR_file[0]; # modify it @MLR_file2 = <MLR2>; #read in set2 data $MLR_file2[2] =$MLR_file2[1] = $MLR_file2[0]; # modify it &printFile (@MLR_file, @MLR_file2); sub printFile { #print the contents of each array to the correct ouput file my @file = $_[0]; my @file2 = $_[1]; foreach $line(@file) { print OUT "$line"; } foreach $line(@file2) { print OUT2 "$line"; }
I tried passing the arguments as references, without really know why. When I more my ouput file(s) looked like this
Any explaination on this would be appreciated. Thank you.ARRAY(0xd3a2c) ARRAY(0xd3a98)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: passing arrays to subroutines
by Masem (Monsignor) on Apr 10, 2001 at 02:20 UTC | |
Re: passing arrays to subroutines
by ok (Beadle) on Apr 10, 2001 at 02:21 UTC | |
by indapa (Monk) on Apr 10, 2001 at 02:36 UTC |