Abhisek has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/bin/perl -w for (my $x1 = 0; $x1 <= $#RAM1; $x1++) { for (my $y1 = 0; $y1 <= $#{$RAM1[$x1]}; $y1++) { if(($RAM[$x1][$y1]) eq ($RAM1[$x1][$y1])) { if($x1==0){ } #print "DO NOTHING\n"; } else{ push(@shyam,$y1); I wanted to know what actualy is getting stored in @shyam ,Is it the c +olumn that are mismatched. print "Mismatches \$y1=$y1 and $RAM[$x1][$y1] and $RAM1[$x1][$ +y1]\n"; my $lenfirst=length($RAM[$x1][$y1]); $lenfinal=35-$lenfirst; my $spacelen=" " x "$lenfinal"; In this particular code are we storing Array of hash with $Key as What + ????? (i.e.) Here according to this particular program, what is actu +ally geeting stored in $y1 ???? push(@inde,{"$y1" => "$RAM[$x1][$y1]"."$spacelen"."\|$RAM1[$x1 +][$y1]"}); } } }
foreach $item (@pos) { unless ($seen{$item}) { # if we get here we have not seen it before $seen{$item} = 1; push (@uniq, $item); } }

Replies are listed 'Best First'.
Re: Pattern Mismatch
by hipowls (Curate) on Feb 13, 2008 at 12:48 UTC

    To see what data you have use either Data::Dumper or YAML. Both will work well in this case.

    use Data::Dumper; print Dumper(\@inde);
    or
    use YAML; print Dump(\@inde);
    YAML I find easier to read but Data::Dumper's output is well formatted perl code. Experiment and see which you find most useful for your needs. It is much easier to work with complex data structures if you know what they are.

Re: Pattern Mismatch
by planetscape (Chancellor) on Feb 13, 2008 at 18:23 UTC

    Please also see How can I visualize my complex data structure?, which contains some options for the more visually inclined. The best thing for you to do, IMHO, at this stage in learning, is to create very small test cases and include lots of print statements to make sure you know exactly what all your variables look like so you understand what's happening. Good luck!

    HTH,

    planetscape