in reply to DOS characters

Look up the function chomp. It will do what you want.

Replies are listed 'Best First'.
Re: Re: DOS characters
by tachyon (Chancellor) on Sep 06, 2001 at 00:19 UTC

    Look up the function chomp. It will do what you want.

    Actually it won't:

    $textarea = "Line1\015\012Line3\015\012Line3\015\012"; chomp $textarea; print $textarea.'----'; print "\n"; $textarea =~ s/[\015\012]/ /g; print $textarea;

    It is better to specifically target CR and LF using their octal or hex escapes, thus the \015\012 instead of \r\n

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      I've always used /\cM\cJ\/

      -Lee

      "To be civilized is to deny one's nature."
Re: Re: DOS characters
by blakem (Monsignor) on Sep 06, 2001 at 00:11 UTC
    I think he is trying to collapse multiple lines into a single one, in which case chomp will not work.
    #!/usr/bin/perl -wT use strict; my $text = "abc\ndef\r\nghi\njkl\n"; print "1.)T='$text'\n"; chomp($text); print "2.)T='$text'\n"; $text =~ s/[\r\n]+/ /g; print "3.)T='$text'\n";

    -Blake