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

This is yummy!! Thanks a lot :)
  • Comment on Re^2: Spliting a TSV file on the basis of CRLF

Replies are listed 'Best First'.
Re^3: Spliting a TSV file on the basis of CRLF
by harsha.reddy (Acolyte) on Jan 02, 2008 at 10:27 UTC
    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//;.