tobold.org

correct • elegant • free

△ comp.lang.perl △

◅ How to execute UNIX commands

How do I retrieve all the items that occur in one list but not in another ? ▻

How to handle escaped newlines????

In article <315BC815.7A0B@heidelbg.ibm.com>,
Karsten Riede  <riede@heidelbg.ibm.com> wrote:
>How can I tell perl in an easy way that a newline preceded by a backslash is NOT \
>a newline?

How about this?

    while (<STDIN>) {
            while (/\\$/) {
                    # Remove the newline and the backwhack.
                    chop; chop;
                    # Add the next line; complain if there isn't one.
                    $_ .= (<STDIN> || die "unexpected end of file");
            }
            print; # Or whatever...
    }

Tim.
--
Tim Goodwin   | "continuous witter about large metal wanking
Cambridge, UK | machines" -- Robin Fairbairns, about uk.transport.

Original headers:

From: tim@pipex.net (Tim Goodwin)
Newsgroups: comp.lang.perl.misc
Subject: Re: How to handle escaped newlines????
Date: 29 Mar 1996 17:18:36 GMT
Organization: Unipalm PIPEX
Message-ID: <4jh61c$3q8@wave.news.pipex.net>
References: <315BC815.7A0B@heidelbg.ibm.com>

△ comp.lang.perl △

◅ How to execute UNIX commands

How do I retrieve all the items that occur in one list but not in another ? ▻