[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



[...]


    Christopher> It no longer croaks but then no longer works.  I do
    Christopher> not get anything in $@ afterwards.  I need a way to
    Christopher> validate the regex and if it is invalid remove it
    Christopher> from the @search list.

my @re = qw( a.b cd? ?bad go{2}d );
my @valid;

for( 0..$#re ) {
  eval qq{qr/$re[$_]/};
  if( $@ ) {
    warn "Problem with re $_:\n$@"
  } else {
    push @valid, qr/$re[$_]/
  }
}


Or more succinctly (but without the warnings):

my @re = qw( a.b cd? ?bad go{2}d );
my @valid = grep eval qq{qr/$_/}, @re;

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
                      |  scary questions." -- Jules                =(___)=
                      |                                               U


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00087" href="msg00087.html">[ale] Using Expect.pm</a></strong>
<ul><li><em>From:</em> esoteric at 3times25.net (Geoffrey)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00083" href="msg00083.html">[ale] Using Expect.pm</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00083.html">[ale] Using Expect.pm</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00085.html">[ale] Network Virus?</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00083.html">[ale] Using Expect.pm</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00087.html">[ale] Using Expect.pm</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00084"><strong>Date</strong></a></li>
<li><a href="threads.html#00084"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>