Guys,

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

perl -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");
instead of
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; }
The data filesize is huge.
Both of these take almost the same time (25min). Is there a way I can reduce this time.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.