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.


In reply to parsing out alias string better in perl to .htm by nanohurtz

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.