hello again fellow monks

ive encountered a big problem. what i need to do is

  • 1)need to know if a regex failed or not
  • 2)need to know how many matches has regex hit
  • 3)need to know what errors are in $@ if the
  • regex failed
  • 4)need the program not to stumble if the regex failed
  • 5)the matches persist in memory from the last regex applied to the string,how can one clear those out,and know if the string really matched or not
  • 6)is there any alternative to $#- to see how much matches have been found ?
  • if i want all of these it seems i need to have the regex in an eval so that the program doesnt stop if the regex fails.if i want $@ i just use it but if its in an eval there will be no $@. if i want to see if the regex failed or not i can check like if($string=~/$regex/) {#succeded} but that looses my $@ and the matches array($1,$2,...) im pretty sure i need to use eval because i need to get the $@ wich i need to tell the user errors his regex caused. and i have tried sever combinations of the questions 2),3),4) and i have achieved only partial succes. i dont know what to do because i also have this problem with persistance of memory wich it seems i cannot fix easily because the matches variables are readonly(i would clear them out to be sure ive got a thing out of the way but i cant).

    what do you suggest doing ?

    how should i approach the problem?


    In reply to regex persistence of matches by spx2

    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.