in reply to Re: Re: finding different linebreaks with <>
in thread finding different linebreaks with <>

You can do exactly what you asked for with File::Stream. A moderately portable regular expression to use is qr/\r\n?|\n\r?/. That should handle Unix, DOS and MacOS line endings on any of those three platforms.

Replies are listed 'Best First'.
Re: Re: Re: Re: finding different linebreaks with <>
by seaver (Pilgrim) on Apr 09, 2004 at 16:39 UTC
    Dear Tilly,

    Thanks so much for your help, I've downloaded and used File::Stream to great success. I'm using the regular expression below:

    my ($handler, $stream) = File::Stream->new(\*FILE, separator => qr{[\c +M\r\n][\cM\r\n]?});

    Does anyone see any pitfalls with this one? I wanted to make sure I got all three 'types' of characters.

    Thanks
    Sam

      That RE will incorrectly read 2 returns as just one.
        True, but empty lines are no use to me anyway.