sas429s has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to read this as an multidimensional array. ALl the strings in each of the rows and columns are of fixed length. I would like to check if each of the values has a valid value. What I have come up with so far:maps_c7 190_520 3195927 00 40 0K8632 maps_c7 210_520 3195928 00 41 0K8701 maps_c7 210_620 3195929 00 42 0K8702 maps_c7 230_560 3195930 00 43 0K8635 maps_c7 230_620 3195931 00 44 0K8703 maps_c7 230_660 3195932 00 45 0K8704 maps_c7 250_660 3195933 00 46 0K8638 maps_c7 250_800 3195934 00 47 0K8705 maps_c7 275_800 3195935 00 48 0K8640 maps_c7 300_860 3195936 00 49 0K8706 maps_c7 300_860_ER 3195937 00 50 0K8642 maps_c7 330_860_ER 3195938 00 51 0K8643 maps_c7 350_860_ER 3195939 00 52 0K8707 maps_c7 300_860_RV 3195940 00 53 0K8645 maps_c7 330_860_RV 3195941 00 54 0K8646 maps_c7 350_860_RV 3195942 00 55 0K8647 maps_c7 360_925_RV 3195943 00 56 0K9048
I am unable to read the multidimensional array. Is it the correct way or am i missing something? I want to read it like this: $list[$x][$y]?? where $x is the number of rows and $y the number of columns?? Also say for instance: $list[1][2]has no value how can i validate it? Just say if($list[$x][$y])?? Thanks in advance.#!/usr/bin/perl use strict; use warnings; 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=""; open (FILE,"$file"); @data=<FILE>; while(<FILE>) { push @list, [split/s+/]; }
|
|---|