Simple solutions are probably just a regular expression:
$varalias =~ s/=.*//; # Delete everything(.*) from the equals on $vartarget =~ s/"$//; # Delete the quote at the end($)
As a note, your regular expression scares the willies out of me, a strong case for Death to Dot Star!. You probably mean to do something like this:
# If able to delete the stuff(.*) between the beginning # of the line(^) and the word 'alias' and one-or-more spaces(\s+) # found after that ... if (s/^.*?alias\s+//) { # Extract the 1st, 5th and 7th "words" my ($varalias, $varsource, $vartarget) = (split(' '))[1,5,7]; # Then whatever... }
Here's a few general tips which can help you simplify your program.

Your print to OUT just screams out for a "here document" style approach, where you can put a whole bunch of stuff right in your program and save yourself having to quote it properly. As a bonus, you don't have to "escape" your quote marks, like you have done:
print OUT <<END_HTML; <FOO> <FOO>$varsource <FOO> <FOO>$vartarget <FOO> <FOO> END_HTML
Also, you can increment a variable with the ++ operator, like so: $i++ and that is the same as $i = $i + 1 but is much shorter.

Don't forget to indent, either. Not indenting is a major Faux Pas, kind of like arrivng at work without a shirt on. You can do it, but people look at you funny. Whenever you open braces, kick it in a tab stop. Some editors can do this for you automatically, if you're feeling Lazy. Example:
if ($something) { some_code(); if ($something_else) { some_other_code(); } }

In reply to Re: parsing out alias string better in perl to .htm by tadman
in thread 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.