N
Neil Shadrach
Why do the two 'print' lines behave differently in the following?
#!/usr/bin/perl -w
use strict;
use warnings;
$/.=$/;
while(<DATA>)
{
print "\nA:1[$1]\nA:2[$2]" if /bindings: (?
.+ => .+)\n?\s*)(?
.+ => .+\n?\s*))/;
print "\nB:1[$1]\nB:2[$2]" if /bindings: (?
.+ => .+)\n?\s*){2}/;
}
__DATA__
community: public
enterprise: 9.9.9.9.9.9.999.9.9.9.9
agent addr: 999.99.99.999
agent name: ab.cd.ef.gh
generic ID: 9
specific ID: 999
uptime: 9:99:99
bindings: 9.9.9.9.9.9.9.9.9 => Warning: /local/file has reached maximum size
9.9.9.9.9.9.999.9.9.9.9.9 => local_storage
###
!/tmp/demo.pl
A:1[9.9.9.9.9.9.9.9.9 => Warning: /local/file has reached maximum size]
A:2[9.9.9.9.9.9.999.9.9.9.9.9 => local_storage
]Use of uninitialized value in concatenation (.) at /tmp/demo.pl line 11, <DATA> chunk 1.
B:1[9.9.9.9.9.9.999.9.9.9.9.9 => local_storage]
B:2[]
#!/usr/bin/perl -w
use strict;
use warnings;
$/.=$/;
while(<DATA>)
{
print "\nA:1[$1]\nA:2[$2]" if /bindings: (?
print "\nB:1[$1]\nB:2[$2]" if /bindings: (?
}
__DATA__
community: public
enterprise: 9.9.9.9.9.9.999.9.9.9.9
agent addr: 999.99.99.999
agent name: ab.cd.ef.gh
generic ID: 9
specific ID: 999
uptime: 9:99:99
bindings: 9.9.9.9.9.9.9.9.9 => Warning: /local/file has reached maximum size
9.9.9.9.9.9.999.9.9.9.9.9 => local_storage
###
!/tmp/demo.pl
A:1[9.9.9.9.9.9.9.9.9 => Warning: /local/file has reached maximum size]
A:2[9.9.9.9.9.9.999.9.9.9.9.9 => local_storage
]Use of uninitialized value in concatenation (.) at /tmp/demo.pl line 11, <DATA> chunk 1.
B:1[9.9.9.9.9.9.999.9.9.9.9.9 => local_storage]
B:2[]