Hi John,
I was testing your code below with this array:
my @x = qw( * * A B C D );
but how come in the end it gives:
* XA * XB XC XD X
instead of
* * XA XB XC XD
--
Regards,
Edward WIJAYA
SINGAPORE
----- Original Message -----
From: "John W. Krahn" <[EMAIL PROTECTED]>
Date: Monday, August 1, 2005 11:03 am
Subject: Re: Remembering Positions in Array after processing the element
> Chris Charley wrote:
> >
> >>> perl -le'
> >> @x = qw( A B C * D );
> >> print @x . " @x";
> >> for ( reverse 0 .. $#x ) {
> >> push @y, [ $_, splice @x, $_, 1, () ] if $x[ $_ ] =~ /[^A-Z]/;
> >> }
> >
> > splice @x, $_, 1, ()
> > Are the empty parens needed here? Seemed to work ok for me
> without them.
>
> Yes, it will work with the three argument form of splice and as to
> yourother issue you can use unshift instead of push.
>
> unshift @y, [ $_, splice @x, $_, 1 ] if $x[ $_ ] =~ /[^A-Z]/;
>
>
>
> John
> --
> use Perl;
> program
> fulfillment
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>