nanohurtz has asked for the wisdom of the Perl Monks concerning the following question:
Kind monks, I've written a script that will read an 8 part string that starts with the word -alias-. It extracts the 2nd, 6th and 8th variable and prints it out to htm with count in a table format.
example: http://www.graffece.com/dev/prevplanout.htm
I have 3 problems
One. I would like to further isolate the actual alias word by eliminating the characters starting with the (equal) character in the $varalias string.
Two. I'd also like to be able to parse out the " (quotation) characters in the $vartarget string. The end result would look something like the following example
example: http://www.graffece.com/dev/prevplanmod.htm
This way I can use the $varsource and $vartarget variable in other file and directory sub routines
Three. The trickiest, there are times when the input file may contain carriage returns between my wanted strings. Is there a way I can filter them out within the same perl routine?
example: alias tt_clms_copy="/usr/cmvc/cmtools/bin/cm_move.sh -e /cmtest/appsmore/27/hpux/text/cmexports -t /cmtest/appsmore/27/hpux -s /prod1/uat_stage/clmstux/ap_clms"
Attached is the code.
open(IN, "< prevplanin.txt"); open(OUT, "> prevplanout.htm"); my ($varalias, $varsource, $vartarget); print OUT "<html><head><title>PLAN VERIFICATION</title></head><body bg +color=\"\#FFFFFF\" text=\"\#000000\">"; $i = 1; while(<IN>) { chomp; if (m/(alias) (.*) (.*) (.*) (.*) (.*) (.*) (.*)$/) { $varalias=$2, $varsource=$6, $vartarget=$8; print OUT "<table width=\"37%\" border=\"0\" cellspacing=\"1\" cellpad +ding=\"0\"><tr bgcolor=\"\#0099CC\"><td colspan=\"2\"><font face=\"Ge +neva, Arial, Helvetica, san-serif\" size=\"2\"><b>"; print OUT "<font color=\"\#FFFFFF\">alias retrieved</font></b></font>< +/td></tr><tr><td width=\"11%\" bgcolor=\"\#CCCCCC\"><font face=\"Gene +va, Arial, Helvetica, san-serif\" size=\"2\"><b>"; print OUT "alias</b></font></td><td width=\"89%\" bgcolor=\"\#FFCC99\" +><font face=\"Geneva, Arial, Helvetica, san-serif\" size=\"2\">$varal +ias</font></td></tr><tr><td width=\"11%\" bgcolor=\"\#CCCCCC\">"; print OUT "<font face=\"Geneva, Arial, Helvetica, san-serif\" size=\"2 +\"><b>source</b>"; print OUT "</font></td><td width=\"89%\" bgcolor=\"\#FFCC99\"><font fa +ce=\"Geneva, Arial, Helvetica, san-serif\" size=\"2\">$varsource</fon +t></td></tr><tr><td width=\"11%\" bgcolor=\"\#CCCCCC\">"; print OUT "<font face=\"Geneva, Arial, Helvetica, san-serif\" size=\"2 +\"><b>target</b></font></td><td width=\"89%\" bgcolor=\"\#FFCC99\"><f +ont face=\"Geneva, Arial, Helvetica, san-serif\" size=\"2\">$vartarge +t</font></td></tr><tr><td colspan=\"2\" bgcolor=\"\#0099CC\">"; print OUT "<font face=\"Geneva, Arial, Helvetica, san-serif\" size=\"2 +\"><b><font color=\"\#FFFFFF\">$i</font></b></font></td></tr></table> +<p></p>"; $i = $i + 1; } print OUT "</body></html>" } close(IN); close(OUT);
Any help from this established and world renouned monastary is greatly appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: parsing out alias string better in perl to .htm
by tadman (Prior) on May 31, 2002 at 05:37 UTC | |
|
Re: parsing out alias string better in perl to .htm
by particle (Vicar) on May 31, 2002 at 12:26 UTC | |
|
Many Thanks
by nanohurtz (Initiate) on May 31, 2002 at 14:26 UTC |