[EMAIL PROTECTED] (Steven Benveniste) writes:

> I have been looking for a putback fuction when reading
> from a file but cannot find it.

I've used an array for this kind of thing.  In fact, I think
I posted an answer recently that relied on it -- look if you
want another example.

Here's the basic idea.  Get a line, either from the stack or
from the diamond operator.  Inside the loop, consume it or
push it back for another iteration to use.  You can even
push stuff onto the stack that didn't come in from from the
input file.

I've only needed this trick for a 1-level pushback, but it
generalizes to as deep as you need.


while (my $line = (pop @pushback || <>)) {
    ...    
    push @pushback, $line if (your_conditions_may_vary);
    ...
}


-- 
Michael R. Wolf
    All mammals learn by playing!
        [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to