Pandey Rajeev-A19514 wrote:
> 
> Hi,

Hello,

> I am new to perl and need some help.
> 
> How do we pass array of scalars to a subroutine.
> I need something like this

Perl creates a list of all the arguments of the sub and makes them
available in the @_ array inside the sub.


> ***************************************
> sub ABC {
>  my(@buffer) shift;

I think you meant:

my @buffer = shift;

But that only gets you the first element of @_ and stores it in
$buffer[0].  You want to do this instead:

my @buffer = @_;


>  print @buffer;
> }
> 
> I want to call this subroutine from some other code like.
> 
> ABC( @this_buffer );
> *****************************************
> 
> Shift  works for scalars, but does it work for Array of Scalars ?

shift() only returns one scalar.  If you want more than one use a slice
or the splice() function.

perldoc perlsub
perldoc perldata


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to