[PLUG] gawking a file

Colin Kuskie ckuskie at dalsemi.com
Thu May 15 13:25:03 UTC 2003


On Thu, May 15, 2003 at 12:51:41PM -0700, Randal L. Schwartz wrote:
> >>>>> "Colin" == Colin Kuskie <ckuskie at dalsemi.com> writes:
> 
> Colin> Here's some perl code:
> 
> Colin> LOOP: while (<>) {
> Colin>   redo LOOP if s/\\$// and $_ .= <>;
> Colin> }
> 
> while (<>) {
>   1 while s/\\\n/<>/e;
>   ...
> }

Very slick.  For a blast from the past, here's your original unmodified
from clp in 1995:

----------------------------------------------------------------

>From merlyn at stonehenge.comMon Nov 20 08:37:22 1995

I've written loops that look like:

	while (<>) {
		s/#.*//; # toss comments
		next if /^\s*$/; # skip blank lines
		redo if s/\\$// and $_ .= <>; # handle continuations
		...
		...
	}

and yes, the order of those three statements is very significant.
Work it out to see why.

----------------------------------------------------------------

I have to keep reminding myself to do an EOF check before the
end of the block so that it doesn't just keep reading and reading
and reading...

Colin




More information about the PLUG mailing list