in reply to Re: What new tutorials would you like to see in Tutorials?
in thread What new tutorials would you like to see in Tutorials?

<plug>Iterators</plug> are one good real-world use.

-Lee

"To be civilized is to deny one's nature."
  • Comment on Re: Re: What new tutorials would you like to see in Tutorials?

Replies are listed 'Best First'.
Re(3): What new tutorials would you like to see in Tutorials?
by FoxtrotUniform (Prior) on Sep 18, 2002 at 04:51 UTC

    Hmm... iterators on anonymous functions could be fun, especially if you're doing a bunch of numerical code.

    sub get_iter { my ($subref) = @_; my $i = 0; return sub { print "f($i) is ", &$subref($i++), "\n"; } } my $iter = &get_iter(sub {shift; $_*2}); for (0..20) { &$iter; }

    I had actually thought, "well, what about iterators?", but somehow my brain turned that into "yeah, bind an array into the scope of a function, that's really useful". Thanks shotgunefx!

    --
    F o x t r o t U n i f o r m
    Found a typo in this node? /msg me
    The hell with paco, vote for Erudil!