[sf-perl] help with matching?

David Alban extasia at extasia.org
Mon Jul 12 11:30:21 PDT 2010


greetings,

i'm trying to capture the ip address and the two fully qualified hostnames.

this is my output.  the three lines citing "use of uninitialized
values" are fine.  i printed more captured variables than i figured
were captured.

what i can't figure out is why $9 captured the domain ('.srwd15.com')
rather than the fully qualified hostname ('srwd15hst001.srwd15.com').
the fact that $9 has the same value as $8 makes me think a portion of
the match failed, but i can't see which portion, if that's the case.

Use of uninitialized value in concatenation (.) or string at junk.perl
line 66, <$FH> line 1073.
Use of uninitialized value in concatenation (.) or string at junk.perl
line 66, <$FH> line 1073.
Use of uninitialized value in concatenation (.) or string at junk.perl
line 66, <$FH> line 1073.
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] vhosts_line =>
'10.80.15.14     srwd15abx001.srwd15.com   srwd15hst001.srwd15.com  '
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 1 => '10.80.15.14'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 2 => '10'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 3 => '80'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 4 => '15'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 5 => '14'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 6 =>
'srwd15abx001.srwd15.com'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 7 => 'srwd15abx001'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 8 => '.srwd15.com'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 9 => '.srwd15.com'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 10 => 'srwd15hst001'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 11 => '.srwd15.com'
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 12 => ''
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 13 => ''
2010-07-12 17:46:21 +0000 srwd00reg001 junk.perl[356] 14 => ''
$VAR1 = qr/(?msx-i: \A \s* (?x-ism: ( ( \d{1,3} ) [.] ( \d{1,3} ) [.]
( \d{1,3} ) [.] ( \d{1,3} ) ) ) \s+ (?x-ism: ( ( \w+ ) ( [.] \w+ [.]
\w+ )? ) ) \s+ (?x-ism: ( ( \w+ ) ( [.] \w+ [.] \w+ )? ) ) \s* \z )/;

here is the line to parse (excluding the single quotes):

'10.80.15.14     srwd15abx001.srwd15.com   srwd15hst001.srwd15.com  '

here is my attempt to make the regex more human readable [edited above
line by hand--best viewed with non-proportional font:]

qr/
  (?msx-i:
    \A
      \s*
        (?x-ism: (
                       ( \d{1,3} )
                   [.] ( \d{1,3} )
                   [.] ( \d{1,3} )
                   [.] ( \d{1,3} )
                 )
        )
        \s+
        (?x-ism: (
                   ( \w+ )
                   (
                     [.] \w+ [.] \w+
                   )?
                 )
        )
        \s+
        (?x-ism: (
                   ( \w+ )
                   (
                     [.] \w+ [.] \w+
                   )?
                 )
        )
      \s*
    \z
  )
/;

what am i missing?

thanks,
david
-- 
Live in a world of your own, but always welcome visitors.


More information about the SanFrancisco-pm mailing list