Andrew Gaffney <[EMAIL PROTECTED]> wrote:
:
: Charles K. Clarkson wrote:
: >
: > print Dumper $array1;
: >
: > @$array1 = grep ! /^!/, @$array1;
: >
: > print Dumper $array1;
:
: Well, I'm working with the data in the array at the same
: time I'm trying to remove certain elements. I need to
: process the elements that start with a '!' and then
: remove them. I process all other elements differently.
Sure. Now you tell me:
( $array1, my $array2 ) = unmerge( $array1 );
print Dumper $array1, $array2;
sub unmerge {
my( @arr1, @arr2 );
/^!/ ? push @arr1, $_ : push @arr2, $_ foreach @{ $_[0] };
return ( [EMAIL PROTECTED], [EMAIL PROTECTED] );
}
Or:
my( $array2, $array3 );
/^!/ ? push @$array2, $_ : push @$array3, $_ foreach @$array1;
print Dumper $array2, $array3;
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>