On Sun, 26 Oct 2003 01:35:47 -0800, perl wrote:
> Is this a standard/normal/ok way to pass and use array by reference?

Almost, I would say.

> #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";
> }

The 'showIt()' should rather be something like this:

  sub showIt {
      my $a = shift;
      my $b = shift;

      print 'a[0]: ' . $a->[0] . "\n";
      print 'b[0]: ' . $b->[0] . "\n";
  }

As I _hope_ you can see, $a->[n] is easier to read than $$a[n].  Don't you
agree?


-- 
Tore Aursand <[EMAIL PROTECTED]>


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

Reply via email to