Jack Jack wrote:
> 
> Hi All,

Hello,

> I have two arrays @a and @b,
> each of the arrays have lotz of elements.
> what i want is  the first element of @a should be assigned the first element of 
> array @b.

If you want to replace the first element of @a with the first element of
@b:

$a[ 0 ] = $b[ 0 ];


If you want to insert the first element of @b without changing @a:

unshift @a, $b[ 0 ];


If you also want to remove the first element of @b:

$a[ 0 ] = shift @b;

Or:

unshift @a, shift @b;


> The result should be combined in one array @c, so that i can  send the @c  mail.
> I have a rough idea that we can in HASH, but not sure.
> can sombody help me  out

@c = ( $b[ 0 ], @a[ 1 .. $#a ] );

Or:

@c = ( $b[ 0 ], @a );

Or:

@c = ( shift @b, @a );

Or:

@c = ( shift @b, splice( @a, 1 ) )


It depends on what you want to do.   :-)


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