this should get you started, I kept it flexible so that you can adjust it.
DB<49> sub english_num { my ($pre,$num) = @_; my $eng = join "-", ma +p {(qw/zero one two three four five six seven \ eight nine/)[$_] } split //,$num; return "$pre \\$eng"} DB<50> $txt =" some text No. 345 other text No. 123 end text" DB<51> $txt =~ s/(No.) (\d{3})/english_num($1,$2)/ge DB<52> say $txt some text No. \three-four-five other text No. \one-two-three end text

edit

In case you are sure that it's always exactly 3 digits, you can also use a hardwired regex, with a lookup array

s/(No.) (\d)(\d)(\d)/$1 \\$nums[$2]-$nums[$3]-$nums[$4]/g

DB<94> $_ =" some text No. 345 other text No. 123 end text" DB<95> p some text No. 345 other text No. 123 end text DB<96> s/(No.) (\d)(\d)(\d)/$1 \\$nums[$2]-$nums[$3]-$nums[$4]/g DB<97> p some text No. \three-four-five other text No. \one-two-three end text

update

after reading the OP again, please provide an SSCCE clarifying input and expected output.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery


In reply to Re: multiple-pass search? by LanX
in thread multiple-pass search? by propellerhat

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.