Thank you Wiggins,

and thankyou also for your help with scoping yesterday.

Colin



-----Original Message-----
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 27, 2002 13:08
To: Johnstone, Colin
Cc: '[EMAIL PROTECTED]'
Subject: Re: Passing an array to a subroutine


If it is just an array and nothing else gets passed, then you can pass 
it normally...

my $return = passArrayToMe(@array)

and your definition will go something like this:

sub passArrayToMe {
   my @array = @_;
}

but if you need to pass other variables as well then you will need to 
pass an array reference, the reference being the key here, so:

my $return = passArrayRefToMe(\@array)

and the definition being:

sub passArrayRefToMe {
   my $arrayref = shift;
}

or

my $return = passArrayRefToMe($someVar, \@array, $someOtherVar);

definition like:

sub passArrayRefToMe {
   my @args = @_;
}

where args[0] is $someVar value
where args[1] is the reference to the @array
where args[2] is $someOtherVar value

see perldoc perlreftut and perldoc perlref

http://danconia.org

Johnstone, Colin wrote:
> Hi all,
>  
> I think somebody asked this the other day.
>  
> How does one pass an array to a subroutine please
> 
> Colin Johnstone 
> 
> 
> 

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

Reply via email to