Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Multiple substitutions in large files

by dragonchild (Archbishop)
on May 09, 2005 at 13:46 UTC ( #455181=note: print w/replies, xml ) Need Help??

in reply to Multiple substitutions in large files

#!/usr/bin/perl -p s/^\|/\\N\|/; s/\|\s*$/\|\\N/; s/\|\s*\|/\|\\N\|/g; s/\|\.\s*\|/\|\\N\|/g; s/\|\s+/\|/g; s/\s+\|/\|/g; s/(\d{2}:\d{2}:\d{2})\.\d+/$1/g; s/(\d{5})-(?:\d{1,4}|\s+)/$1/;

Execute as so: file1 > file2

Update: ikegami is absolutely correct. I should be doing a redirect. The next 1st level response provides the -pi version.

  • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
  • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"

Replies are listed 'Best First'.
Re^2: Multiple substitutions in large files
by ikegami (Pope) on May 09, 2005 at 14:41 UTC
    Shouldn't that be -pi (or -pi.bak if a backup is desired)? With just -p, the usage would be file1 >

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://455181]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2020-09-21 13:25 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (126 votes). Check out past polls.