Passing Array as a Parameter in PERL

By ET

There are more than two ways to do it. I just put down two quick ways.

  1. using reference to array
  2. not using reference to array

Method 1:

In program:
processarray(\@array);
In sub processarray:
my $arrayref=shift;
my @array=@$arrayref;

Method 2:

In program:
processarray(@array);
In sub processarray:
my @array=@_;

Leave a Reply


BlogTimer
You are visitor number several since September 1, 2001

Copyright Xiaoquan (Michael) Zhang, 2004-2007. All rights reserved.
All trademarks property of their owners.