[ale] perl regexp question de'jour ;-)

JK jknapka at kneuro.net
Fri Jul 7 17:48:51 EDT 2006


Jim Popovitch wrote:

>My problem is this:  Perl regexp matching seems to not be flexible (or 
>my understanding of perl and/or regexp matching isn't broad enough) in 
>that it doesn't allow me to specify a match condition for more 
>parameters than actually exist.  The above code will work as long as 
>there are at least 2 params following the keyword "alert".  If I use the 
>following code, then option lines with less than 3 parameters are skipped.
>
>    ------------------------
>    }
>    elsif ($ln =~ /^alert\s(\S+)\s(\S+)\s(\S+)/i) {
>       my $email = $1
>       my $interval = $2
>       my $priority = $3
>       ....
>    }
>    ------------------------
>
>Any examples on how to use perl regexp matching against a variable 
>number of parameters?
>  
>
If they're always going to be whitespace-delimited, I'd just
use split, instead of messing with regexps.

-- JK




More information about the Ale mailing list