[plug] code decipher

Jon Miller jlmiller at mmtnetworks.com.au
Mon Feb 24 22:59:56 WST 2003


Thanks guys (Simon and Craig) that does help a lot.

On Mon, 2003-02-24 at 20:26, Simon Newton wrote:
> Its going to match the following:
> 
> 128.61.44.92
> 128.61.44.31
> r44h92.res.gatech.edu
> r44h92.resagatechbedu			# you probably don't want this
> r44h31.res.gatech.edu
> *.jehsom.com
> adsl-20-72-\d+.asm.bellsouth.net	# \d+ is one or more digits
> 
> I imagine its going to be used like so
> 
> # $ip holds what we're matching against
> if ( $ip =~ /$myips/ ) {
> 	# do something
> }
> 
> within the braces, $1 will be the entire match, $2 will be 92 or 31 if
> the address matched 128.31.44 and $3 will be 92 or 31 if it matched the
> r44h addresses.
> 
> This would be better rewritten as
> my $myips =
> qr'^(128\.61\.44\.(92|31)|r44h(92|31)\.res\.gatech\.edu|.*\.jehsom\.com|adsl-20-72-\d+\.asm\.bellsouth\.net)$' ;
> 
> the qr operator returns a compiled regex instead of a string in the
> previous example. Escaping the .'s in the gatech part fixes the forth
> match above.
> 
> in which case you could use it as
> 
> if ( $ip =~ $myips ) {
> 	# do something
> }
> 
> Simon N
> 
> On Mon, 2003-02-24 at 20:11, Jon Miller wrote:
> > Can anyone explain the what this statement does?  I have a piece of code I'm trying to figure out what this piece handles.
> > 
> > # A regex that will match any IPs you come from.
> > my $myips =
> > '^(128\.61\.44\.(92|31)|r44h(92|31)\.res.gatech.edu|.*\.jehsom\.com|adsl-20-72-\d+\.asm\.bellsouth\.net)$';
> > 
> > I assume it is some form of input for ip addresses, and or  domain name.  But what I'ld like to know is what the parameters are.
> > 
> > Thanks
> > 
> > Jon L. Miller, MCNE, CNS
> > Director/Sr Systems Consultant
> > MMT Networks Pty Ltd
> > http://www.mmtnetworks.com.au
> > 
> > "I don't know the key to success, but the key to failure
> >  is trying to please everybody." -Bill Cosby
> > 
> > 
> > 
> > 
> > 
> 
-- 
Jon Miller <jlmiller at mmtnetworks.com.au>
MMT Networks Pty Ltd




More information about the plug mailing list