[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Thingies



At 00.19 -0400 1999.04.23, jacobs@azstarnet.com wrote:
>Here's my problem: I like to give feedback ( print "Now doing X..."; ),
>so I'd like to be able to get the name of the array being looked up
>without having to have another array with the names (@testArrayNames,
>above). Doing this the way I've done it above feels very kludgey, and
>it seems like there should be a better way -- some way to deref
>$testArray[$i] to get the name of the referenced array.

Once you get a reference, you know point to the address in Perl's memory
where the array is, and the name no longer matters.  It may not even exist:

  sub foo {
    my @array = (0..9);
    return \@array;
  }

  my $arrayref = foo();

Now @array no longer even exists, but the data remains around as long as
$arrayref exists.

Now, if @array is a global/package variable instead of a lexical variable,
you could try some symbol table hackery to find out, but I wouldn't
recommend it.

--
Chris Nandor
http://www.petersons.com/
cnandor@pobox.com, chrisn@petersons.com

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org