http://qs321.pair.com?node_id=676071


in reply to Re^2: do {$i++} until vs. $i++ until
in thread do {$i++} until vs. $i++ until

Those two snippets aren't equivalent. Aside from the fact that the latter also exits if <STDIN> returned undef, you reversed the order of the loop body (...) and the exit condition (last INPUT if $line eq ".\n";)

Replies are listed 'Best First'.
Re^4: do {$i++} until vs. $i++ until
by hipowls (Curate) on Mar 25, 2008 at 09:17 UTC

    True they are not functionally equivalent but I didn't care to replicate the bug of looping on a closed file descriptor;-) It works properly when used in a command pipeline.

    As far as last INPUT if $line eq ".\n" goes it is probably correct to put it at the top of the loop since ".\n" is being used as an equivalent to EOF. Whatever is done with ".\n" most likely requires special handling of some sort, for example a sendmail equivalent wouldn't include it in the message and would treat it the same as EOF.