the output#!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"; }
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |