Doniv has asked for the wisdom of the Perl Monks concerning the following question:
I have gone through many other forums and have been directed to this place. I hope somebody will help me on this question.
Cheers
I have split my question into 2 for easier reading.
Part 1
I am replacing the below of piece of code
instead ofperl -pi -e 's/[ ]*\~\t\~[ ]*/~/g' a.dat"); perl -pi -e 's\/^[ ]*\/\/g' a.dat"); perl -pi -e 's/\:000[A,P]M//g' a.dat"); perl -pi -e 's/99991231//g' a.dat"); perl -pi -e 's/Jan 1 1900 12:00:00//g' a.dat");
The data filesize is huge.while (<IN_FILE>) { s/^[ ]*//g; s/[ ]*$//g; s/\:000[A,P]M//g; s/99991231//g; s/Jan 1 1900 12:00:00//g; s/[ ]*\~\t\~[ ]*/~/g; }
Part B
I am trying to date fields contain SUN then replace with blanks and using the below code.
Bascially I want to optimise the below piece of code with includes part A. Altogether it takes 35min.
Appreciate a reply from you guys.
Thanks
while (<IN_FILE>) { s/^[ ]*//g; s/[ ]*$//g; s/\:000[A,P]M//g; s/99991231//g; s/Jan 1 1900 12:00:00//g; s/[ ]*\~\t\~[ ]*/~/g; @INPUT_FIELDS = split /~/, $_; for ($i=0; $i<=$#PROC_FIELDS; $i++) { $MY_INDEX = $PROC_FIELDS[$i] - 1; if ( $INPUT_FIELDS[$MY_INDEX] =~/SUN/ ) { $INPUT_FIELDS[$MY_INDEX] = ""; } } $MYLINE = join "~", @INPUT_FIELDS; print OUT_FILE $MYLINE; } close(IN_FILE); close(OUT_FILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Search and Replace.
by Roy Johnson (Monsignor) on Jun 08, 2005 at 12:54 UTC | |
|
Re: Search and Replace.
by ikegami (Patriarch) on Jun 08, 2005 at 14:24 UTC | |
|
Re: Search and Replace.
by Random_Walk (Prior) on Jun 08, 2005 at 12:42 UTC | |
|
Re: Search and Replace.
by radiantmatrix (Parson) on Jun 08, 2005 at 14:17 UTC | |
by ikegami (Patriarch) on Jun 08, 2005 at 14:31 UTC | |
|
Re: Search and Replace.
by QM (Parson) on Jun 08, 2005 at 15:38 UTC | |
|
Re: Search and Replace.
by hv (Prior) on Jun 08, 2005 at 15:48 UTC | |
|
Re: Search and Replace.
by TedPride (Priest) on Jun 08, 2005 at 16:52 UTC | |
by QM (Parson) on Jun 08, 2005 at 19:49 UTC | |
|
Re: Search and Replace.
by TheStudent (Scribe) on Jun 08, 2005 at 11:59 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |