#!/usr/bin/perl #use strict; #use warnings; use Data::Dumper; my @array; my $line=""; my @data; my @list; my $maps_dir=""; my $dir=""; my $part_no=""; my $chg_lvl=""; my $int_lock=""; my $t_spec=""; my $file=""; my $FILE; my $i=0; my $num_of_columns; my $x; my $y; my $temp="No"; my $temp1; my $temp2; if ($#ARGV == -1) { print("Enter a part number file name:\n"); chomp($file=<>); } else { $file=$ARGV[0]; } if(!-e $file) { print "File:$file does not exist"; } open ($FILE,"<$file"); while(<$FILE>) { $i++; chomp; @data=split/\s+/; push @list, [split/\s+/]; $num_of_columns=@data; } #print Dumper( @list ), "\n\n"; #print "Number of rows is $i\n"; #print "Number of columns is $num_of_columns\n"; for($x=0;$x<=$i;$x++) { for($y=0;$y<=$num_of_columns;$y++) { if(!$list[$x][$y]) { $temp1=$x; $temp2=$y; } } } print $temp1;----->Here it prints the last row instead of the index wh +ere there is no data #print $list[1][5], "\n"; # print close($FILE);
In reply to Re^2: Reading a file as an multi dimensional array Please help
by sas429s
in thread Reading a file as an multi dimensional array Please help
by sas429s
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |