Edward WIJAYA wrote:
> Hi,

Hello,

> 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]/;
    }
print @x . "  @x";
@x = map "X$_", @x;
print @x . "  @x";
for ( @y ) {
    splice @x, $_->[0], 0, $_->[1];
    }
print @x . "  @x";
'
5  A B C * D
4  A B C D
4  XA XB XC XD
5  XA XB XC * XD



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>


Reply via email to