How do you make perl search for say today([^&]+)today, where ([^&]+) is any number, then make it a variable, for example $12345. Then change it to 123.45, and then do math to it, 123.45*.40 = 49.38 with 49.38 being what the $12345 variable is at the end??? What perl is searching is... Today: today408today Clicks: 34 Yesterday: yesterday555yesterday Clicks: 61 This Month: this11360this Clicks: 812 Last Month: last5350last Clicks: 454 where the numbers change. The closest I can get is... $id3 =~ /today(\d+)today/; my $ans = $1 * .40; $final = ($ans / 100); $id4 =~ /yesterday(\d+)yesterday/; my $ans2 = $2 * .40; $final2 = ($ans2 / 100); $id5 =~ /this(\d+)this/; my $ans3 = $3 * .40; $final3 = ($ans3 / 100); $id6 =~ /last(\d+)last/; my $ans4 = $4 * .40; $final4 = ($ans4 / 100); { print "Content-Type: text/html\n\n"; print <<EOM; $id2 <HR> Original Number: $1 - $2 - $3 - $4 <HR> After it's been converted: $ans - $ans2 - $ans3 - $ans4 After being divide by 100: $final - $final2 - $final3 - $final4 which spits out Original Number: 5350 - - - After it's been converted: 2140 - 0 - 0 - 0 After being divide by 100: 21.4 - 0 - 0 - 0 It only messes with the last5350last, even if I only have the code that should mess with today408today.

In reply to Search for abcNUMBERdef, make it a variable, then do math? by Jesse Smith

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.