Is it possible to use a subroutine call from inside a regex-codeblock?

This is about separating regexes from application code by storing the regexes in separate files. I have this working nicely and usefully, so far no problem.

But now I am looking to move some code out of the application, more specifically I want to call (dbi-)subroutines from within the codeblock, and pass it a regex-captured value. Here I am running into trouble...

To do database lookups straight after matching seems such a logical step, that I expect others must have progressed further in this direction. Of course I will post complete code if anyone turns out to be interested, but because it needs several files I thought better start with a small, not-running example:

What follows is such a (above-mentioned) separate regex-file.

(?{ local $genus = ''; local $dbfound = 0; }) ^ (?: ([A-Z][A-Z]+) (?{ $genus = ucfirst(lc($^N)); $dbfound = dbilookup($genus); }) ) $ (?{ # # further processing of values # (give back values to container program) })

I'd be thankful for enlightenment

TIA, Eric

In reply to regex-codeblock calling subroutines? by Anonymous Monk

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.