Hello Monks, I'm a total noob to perl and programing in general, and would appreciate any help to achieve what i want, and all i want is just a simple script that can be applied to any file and does two things.

first, find a matched number and replace it with a calculated value.
second, is to find a matched string and add the number of occurrence to it.

for example,

1- find the Z value and multiply it by 4:

Z=5, and to be replaced by Z=20,

2- find the XP word and add the number of occurrence to it:

Ah, so fondly I remember when I became a PerlMonks member, And in my innocence never posted purely to be an XP Whore. Happily your code I’d borrow, and back again I’d be tomorrow Though some examples left me harrowed, harrowed and synapses sore, for my ignorance was abundant and my knowledge of the language poor, But now I’m just an XP Whore.

and to be replaced with:

Ah, so fondly I remember when I became a PerlMonks member, And in my innocence never posted purely to be an XP (1) Whore. Happily your code I’d borrow, and back again I’d be tomorrow Though some examples left me harrowed, harrowed and synapses sore, for my ignorance was abundant and my knowledge of the language poor, But now I’m just an XP (2) Whore.

i did some search and that's what i found but i'm stuck and can't go any further.
$^I = '.bak'; while (<>) { s/Z=(\d+),/ what do i do here? /g; s/\bXP\b/ what do i do here? /g; print }

In reply to How to find a number and replace it with calculated value? by Lejocode

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.