Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: sub that sets $_

by anonymized user 468275 (Curate)
on Jun 28, 2005 at 11:17 UTC ( [id://470580]=note: print w/replies, xml ) Need Help??


in reply to sub that sets $_

...by changeing the while into for?

One world, one people

Replies are listed 'Best First'.
Re^2: sub that sets $_
by Joost (Canon) on Jun 28, 2005 at 14:06 UTC
Re^2: sub that sets $_
by holli (Abbot) on Jun 28, 2005 at 12:31 UTC
    That would mean I have to read the whole file into memory, and return a list of chunks. Depending on the filesize this might turn out as a bad idea ;-)
      No - each iteration returns a chunk into $_ in the for or foreach loop.

      One world, one people

        definitly not.
        use FTest; my $test = new FTest (); print foreach $test->foo; print for $test->foo;
        Meanwhile in a module
        package FTest; sub new { return bless {}, shift; } sub foo { return 1; } 1;
        That code prints "11". I you were correct that would be an endless loop.
Re^2: sub that sets $_
by Jaap (Curate) on Jun 28, 2005 at 11:55 UTC
    or foreach.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-23 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found