On Sunday 26 October 2003 10:35, [EMAIL PROTECTED] wrote:
> Is this a standard/normal/ok way to pass and use array by reference?
>
> @alpha=("a","b","c");
> @numer=(1,2,3);
>
> #calling by reference
> showIt([EMAIL PROTECTED], [EMAIL PROTECTED]);
>
> sub showIt
> { my $a = $_[0];  #assinging by reference
>   my $b = $_[1];
>
> print "a[0]:" . $$a[0] . "\n"; #accessing by reference
> print "b[0]:" . $$b[0] . "\n";
> }
>
> Please let me know if there is anything wrong with this practice.
>
> -thanks
Hello,
you can use prototypes to pass array references. see perldoc perlsub for more 
details.
sub showIt([EMAIL PROTECTED]@);
my @alpha=("a","b","c");
my @numer=(1,2,3);
showIt(@alpha,@numer);
sub showIt([EMAIL PROTECTED]@)
{
        my($a,$b) = @_;
        print "a[0]:" . $$a[0] . "\n"; #accessing by reference
        print "b[0]:" . $$b[0] . "\n";
}
Regards
 Jakob



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

Reply via email to