The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 02-20-2007
matrixmadhan matrixmadhan is offline
Technorati Master
 

Join Date: Mar 2005
Location: k-tier distributed caching
Posts: 2,736
What have you tried so far ?

Code:
#! /opt/third-party/bin/perl

my($data);

open ( FILE, "< inputfile " ) || die "Unable to open file 'inputfile' <$!> \n";
open ( OUTFILE, "> outputfile " ) || die "Unable to open file 'outputfile' <$!> \n";

while ( read(FILE, $data, 1) == 1 ) {
  if( $data eq "\\" ) {
    if( read(FILE, $data, 1) == 1 ) {
      if( $data eq "n" ) {
        print OUTFILE "\n";
        next;
      }
      else {
        print OUTFILE "\\$data";
        next;
      }
    }
    else {
      last;
    }
  }
  print OUTFILE "$data";
}

close (FILE);
close (OUTFILE);

exit 0
Reply With Quote