perlscript - perl assign variables to an array with relationship -
please advice how pass 3 variables in array relation.
@item = ($a , $b , $c); @record = push(@array, @item);
i want assign value in @array if instance should value of a,b,c.
is there way apart comma assign value in array. $a:$b:$c or $a>$b>$c need because want grep 1 record(a) , (a:b:c)
@array1 = grep(!/$a/, @array); expected output should a:b:c
thanks,
the question not clear. maybe should rephrase it. however, understand want array groups of 3 elements.
you might want utilize array references.
@item = ($a , $b , $c); push(@array, \@item);
or
$item = [$a , $b , $c]; push(@array, $item);
also, push
won't homecoming array expect. perldoc says:
returns number of elements in array next completed "push".
now if want filter these groups of 3 elements, can that:
my @output = (); l1: foreach ( @array ){ l2: foreach( @$_ ){ next l1 if $_ eq $a; } force @output, $_; }
please note if want exact match should utilize eq
operator instead of regex...
perl perlscript
No comments:
Post a Comment