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


in reply to $/ and DOS files

You can set the $/ to be any delimiter you want. In your case, you probably want to use $/ = "\r\n\r\n"; (or whatever happens to be your delimiter of choice)
-Syn0

Replies are listed 'Best First'.
Re: Re: $/ and DOS files
by John M. Dlugosz (Monsignor) on Jul 22, 2001 at 03:08 UTC
    Not quite.

    The normal behavior of Perl (unless you use binmode is to treat the end of line sequence as "\n" no matter what the real form on the platform is. So the input command won't see the "\r" to match it. If you were operating in binmode, you would indeed need to reset $/ to match.

    But, the empty string has a special meaning. It will match any number of consecutive lines to be the terminator. "\n\n" will blindly take two lines, even if the third or more is still blank. There is no way to set $/ to a normal (non-magic) value to accomplish the same thing, since it takes a literal string not a regex.

    Perhaps that idea is outdated. Why not allow the record seperator to be a regex or even a code ref, and eliminate the special built-in case?

    —John