#!usr/local/bin/perl $filename = "input.txt"; open (FILE,"<$filename"); @fileinput=<FILE>; close(FILE); foreach $line(@fileinput) { # Capitalieze first letter of each word found after marker AU: and add + written by: $line=~s/AU:\s\b(\w+)\s\b(\w+)|AU:\s\b(\w+.)|AU: ([\s\w\s\b]+)/AU +: Written by: \u$1 \u$2\u$3/g; #extract numeric id in () if($line=~/\(\d{6}\)/) {$line=~s/$&//; print "$&\n"; }
the output
489459 635436 DD: 11/09/2009 AU: Written by: Jas Dimaano PP: Employee ID list PP: () Jas = DS16 -> with SPi since 2005/04/04 AND with ECO ever since PP: Sam = FT35 -> resigned last 09-03-2008 PP: Evan = AT89 -> transferred last 20070605 to Journals PP: there's more... === DD: july 11, 2009 AU: Written by: Jr S. Tolentino, -editor PG: page 9 PP: Earn points now! PP: Yes! You heard it right! () PP: Finish your exercise before the deadline and you'll receive additi +onal points. PP: Even if you're early by 10, 5 or even 1 minute, we'll give away th +e corresponding points! PP: So hurry now and ensure that you'll be able to finish ASAP! END PP: === DD: 10-09-2009 AU: Written by: Mr. Henderson de la cruz (h.delacruz@yahoo.com) VL: volume IV. PG: page 19 PP: This is only a test document. PP: Did you know that this is just a test doc? See if you're end outpu +t (if you'll be able to produce 1) will be the same as the required o +ne. PP: Don't build you're house on a sandy land. And not too near the sho +re as well. PP: Perhaps you'll earn more than 10-50k of money! Why not?! This does +n't make any sense. Right? So I better end this now. PP: This is the end of this test document. ===

But the AU: Written by: Mr. Henderson de la cruz (h.delacruz@yahoo.com) should output -> AU: Written by: Mr. Henderson De La Cruz, why the code still not working. Question how will I place and display the numeric id in ID: tag(that will also be added) before each AU: tag?


In reply to Display the extracted ID in ID: tag before AU: tag and problem in capitalizing first letter in each word by allison

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, 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, 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.