in reply to Spliting a TSV file on the basis of CRLF

You can set the line delimiter to CRLF like this:
$/ = "\r\n";
or more readably like this:
use English '-no_match_vars'; $INPUT_RECORD_SEPARATOR = "\r\n";
You can also use $RS as a synonym for $/. See perlvar for the details.

Replies are listed 'Best First'.
Re^2: Spliting a TSV file on the basis of CRLF
by harsha.reddy (Acolyte) on Jan 02, 2008 at 07:55 UTC
    This is yummy!! Thanks a lot :)
      oops, My effort went in vain :(
      
      use strict; use warnings; use English '-no_match_vars'; local($INPUT_RECORD_SEPARATOR) = "\r\n"; open my $fh, "./MyTsv.txt" or die $!; while(<$fh>) { print;}
      
      prints this:
      
      define  HOSTNAME        indpdsol3
      
      define  DBPATH  /ccmdb/basedb
      
      TestCaseID      Prefix  Command Postfix Wait    MatchString     MatchOnly
      LineCount       StatusCode
      TC001   cd ~/   ccm start       cd ~/ccm_wa     0       "This
      this
      and
      this"   1       4       0
      _LINE_BREAK_MARKER_
      
      
      
      When I open the same file in a editor I see CRLF like this:
      
      
      
      
      define  HOSTNAME        indpdsol3 <CRLF>
      define  DBPATH  /ccmdb/basedb <CRLF>
      <CRLF>
      TestCaseID      Prefix  Command Postfix Wait    MatchString     MatchOnly
      LineCount       StatusCode<CRLF>
      TC001   cd ~/   ccm start       cd ~/ccm_wa     0       "This<LF>
      this<LF>
      and<LF>
      this"   1       4       0<CRLF>
      
      
        When I open the same file in a editor I see CRLF like this:

        How did you create that file? Did you redirect it? $/ or $INPUT_RECORD_SEPARATOR characters or still there until you chomp.

        If you wish to remove the CR/LF before the print then TMTOWTDI. You can chomp before you print, but then print "$_\n";. Or you could s/\r//;.