Chris Charley wrote: > > ----- Original Message ----- From: "John W. Krahn" <[EMAIL PROTECTED]> > >> Edward WIJAYA wrote: >> >>> I wanted to append two subsequent characters (non *) in >>> an array and then storing them into new array. >>> But then I also want to restore the '*' string in its >>> initial position in the new array result. >> >> Perhaps this will give you some ideas: >> >>> 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 your other 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>