Strip newline chars





5
Date Submitted Fri. Nov. 3rd, 2006 12:07 PM
Revision 1 of 1
Helper jarfil
Tags "Command Line" | Perl
Comments 2 comments
I've found it kind of complicated to strip newline chars from a file with just the commandline. This tiny piece of code does just that.

I've found it especially useful when extracting tabulated data from a grabbed site where each cell is on a different html line. This way I can pre-filter the html, remove the newlines, and insert them again at register boundaries (row end in this case), so that with just a couple more replacement from within a regex enabled text editor I can copy&paste it directly to a database.

@in = <>;
foreach (@in) {
        $_ =~ s/\n//;
        $_ =~ s/\r//;
        print;
}
 

Jaroslaw Filiochowski

blog.jarfil.net

Comments

Comments Too many letters :)
Fri. Nov. 3rd, 2006 1:47 PM    Scripter SCoon
Comments perhaps
Thu. Nov. 16th, 2006 8:17 PM    Newbie Hameed

Voting

Votes Down