[ale] Using Expect.pm

Fletch fletch at phydeaux.org
Tue Aug 3 12:52:36 EDT 2004


>>>>> "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



More information about the Ale mailing list