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

[MacPerl] tidbit



I was just playing with Data::Dumper and %ENV, which you may notice in
MacPerl 5.1.5r4 is quite special (you can add anything to %ENV in your
preferences).

Because %ENV is so special, it does not work with the while (($k, $v) =
each %ENV) {} construct.  You need to use foreach $k (keys %ENV) {} or the
like.

Data::Dumper uses each(), because it is better with memory, and since data
structures passed to Data::Dumper can be aribtrarily large, that is a good
idea.  But that makes it so C<print Dumper \%ENV> does not work.

Anyway, in order to get at the contents of %ENV with Data::Dumper or the
like, you simply need to, instead of taking a reference to the hash, take a
reference to an anonymous hash:

        print Dumper \%ENV;  # a reference to %ENV, does not work
        print Dumper {%ENV}; # a reference to an anonymous array
                             # that has the *contents* of %ENV, works

Just an FYI for y'all.

--
Chris Nandor               pudge@pobox.com           http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==                    MacPerl: Power and Ease                     ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch