James,
 I hope this is my last question. I appreciate your
(and everyone else's that has contributed)
generousity.

I have a web site I inherited where a single page has
3000 lines of perl code. It does not use strict or
warnings. The original authors only used global
variables and never used any function arguments.

So I needed to pass arrays as function arguments (to
keep my sanity) so here is what I did (see below). It
seems to work. Since I am passing an array by
reference, I am using @$ to dereference the function
parameter. That makes sense to me.

Did I do it wrong? (see below). I'm beginning to think
so.

Why does "@$y[$i]" work here, and "foreach $i (keys
%$x)" works to fetch the keys from a reference to a
hash, but I use $$x{$i} to fetch hash reference
element values instead of %$x{$i}?

This seems very inconsistent to me.

sub print_array {
  my ($y, $n) = @_;
  for my $i ( 0 .. $#$y ) {
    print "print_array using .. y[$i] = @$y[$i]\n";
  }
}
# It was not my idea to use undeclared variables! 
# Are we creating a reference to a hash here?
$undeclared[0] = 'a';
$undeclared[2] = 'b';
$undeclared[3] = 'c';
&print_array([EMAIL PROTECTED], 3);

  Thanks,
         Siegfried

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

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

Reply via email to