Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Can anybody correct my mistake? Thanksmy $arrayref =\@array; my @arraynew; foreach $key_pos(keys(%conwithposition)) { #print "KEYLOOP::(@{$conwithposition{$key_pos}}[1],@{$conwithposit +ion{$key_pos}}[2])\n";#,$line[@{$conwithposition{$key_pos}}[0]])\n"; $i=0; #print "ARR:@arraynew\n"; file:for (@$arrayref) { my $match = 0; my @line = split /\t/; #print "Line:::@$arrayref\n"; my @tmp; my ($op, $arg1, $arg2) = (@{$conwithposition{$key_pos}}[1],@{$ +conwithposition{$key_pos}}[2],$line[@{$conwithposition{$key_pos}}[0]] +); $match = is_match($op,$arg2, $arg1); if ($match){ push @tmp,@line[@sorted_cols]; print "@tmp\n"; } push @arraynew,[@tmp]; $i++; } $arrayref = \@arraynew; } print "Result: @tmp\n"; sub is_match{ my ($operator,$valuesrc,$inputval_ref)=@_; my $i; if (ref $inputval_ref eq 'SCALAR'){ return 1 if ($valuesrc eq $$inputval_ref); } if (ref ($inputval_ref) eq 'ARRAY'){ my @valuetomatch=@$inputval_ref; for $i(0 .. $#valuetomatch){ return 1 if ($valuesrc eq $valuetomatch[$i]); } } return 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looping array sequence
by Corion (Patriarch) on Dec 08, 2006 at 10:53 UTC | |
| |
|
Re: Looping array sequence
by swampyankee (Parson) on Dec 08, 2006 at 18:23 UTC | |
|
Re: Looping array sequence
by tinita (Parson) on Dec 09, 2006 at 11:33 UTC | |
|
Re: Looping array sequence
by Util (Priest) on Dec 10, 2006 at 04:13 UTC |