[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Using Expect.pm
- Subject: [ale] Using Expect.pm
- From: fletch at phydeaux.org (Fletch)
- Date: Tue Aug 3 12:52:36 2004
- In-reply-to: <[email protected]> (Christopher Fowler's message of "03 Aug 2004 12:24:21 -0400")
- References: <[email protected]>
>>>>> "Christopher" == Christopher Fowler <cfowler at outpostsentinel.com> writes:
[...]
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