Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Being impervious to an 'each' reset

by SheridanCat (Pilgrim)
on Dec 13, 2006 at 23:47 UTC ( [id://589698]=note: print w/replies, xml ) Need Help??


in reply to Being impervious to an 'each' reset

You could assign %some::...::module::food to another hash and iterate over that, in which case you'll be iterating over an entirely different hash.
use Data::Dumper; my %hash1 = ( key1 => 'hello', key2 => 'world' ); my %hash2 = %hash1; print Dumper \%hash1; print Dumper \%hash2;
However, the code you posted makes me uncomfortable. You seem to be tinkering with some guts that shouldn't be tinkered with.

Replies are listed 'Best First'.
Re^2: Being impervious to an 'each' reset
by duckyd (Hermit) on Dec 14, 2006 at 00:15 UTC
    You could avoid copying the large hash by using a reference:
    my $thingy_ref = \%Foo::Bar::Baz::thingy; foreach my $key ( keys %$thingy_ref ){ print "$key => $thingy_ref->{ $key }\n"; }

      Erm, then you'd have a reference to the same hash you're trying to avoid resetting the each iterator and the OP would be back to square one. The iterator is a property of the underlying hash, not how it's accessed.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://589698]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-23 19:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found