Re: FAQ 4.63 How do I reset an each() operation part-way through?




Maybe the below one is the best choice, give it a named function:

#! /bin/perl -l

sub rhi(%) { keys %{shift} }

%hash = (a=>1, b=>2);
print join '=>', each %hash;
rhi %hash;
print join '=>', each %hash;

__END__
a=>1
a=>1

-Todd
.



Relevant Pages

  • Re: "Cant return a temporary from lvalue subroutine..."
    ... my $self = shift; $self->;} ... wrong, but then lvalue subs are still experimental, so irregularities must be expected. ... For a workaround, instead of tying the whole hash, you can tie each ... Another problem is that the STORE method of a tied scalar doesn't know ...
    (comp.lang.perl.misc)
  • Re: Self referencing hash
    ... my $class = shift; ... You should also call it something better than HASH because the % ... It's very unusual to bless an array reference for use as an object. ...
    (perl.beginners)
  • Re: Multiple Inheritance: mixed base class refs (hash, array)
    ... I've written (an event handling class, that uses the moral HASH style class container, for use with bless.) ... I noticed that IO:Select actually uses an ARRAY ref, rather than a HASH ref, to contain itself. ... my $this = shift; ...
    (comp.lang.perl.misc)
  • Re: parsing data structure
    ... I have been trying for hours, to make this data structure into hash, I need ... sub recurse { ... my $paren = shift @$tokens; ...
    (perl.beginners)
  • Re: parsing data structure
    ... I have been trying for hours, to make this data structure into hash, I need help. ... sub recurse { ... my $paren = shift @$tokens; ...
    (perl.beginners)