in reply to Re^2: Pipe dream
in thread Pipe dream

undef is a special value in the scheme I've proposed. All results are taken in scalar context (assigned to $_), since this is a line-piping scheme. If the grep step returns undef, the iterator goes back to the first sub to try a new line. undefs do not show up in the output stream.

You could use an empty list as your no-line-returned indicator, but it would require you evaluating the subs in list context and then turning the returned value into a scalar afterward. That would be problematic for some common pipe actions, like reading one line at a time from a file (in list context, the whole file would be read).


Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^4: Pipe dream
by diotalevi (Canon) on Sep 09, 2005 at 18:10 UTC
    Oh. I don't normally privilege undef that way. Its another value, just like other values.