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);
In reply to Search and Replace. by Doniv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |