Thanks, Tom!
Tom's comment poses an interesting question: when to hack it or use a
module?
"For educational or experimental reasons, I hope, since you're writing
your own low-level code instead of using a module."
I find that perl is wonderful - it has thousands upon thousands of
modules all waiting for perl -MCPAN but I find that if I have a one time
simple task that could be done in a few lines I can usually do it
without having to search for the appropriate module, install the module,
learn how to use the module then apply it to my task. And in this case,
hacking it did further my education a little on regular expressions!
I am facing that delima now, hack the output of nmap or use Nmap::Scanner:
perl -MCPAN just gave me the dreaded "Out of memory" and I have only a
simple
scan to perform and parse - at the moment I am leaning towards hacking it!
Tom Phoenix wrote:
On 9/10/06, John Ackley <[EMAIL PROTECTED]> wrote:
Trying to split class C IPs into network and host parts.
For educational or experimental reasons, I hope, since you're writing
your own low-level code instead of using a module.
this works but I expected the host part in $2:
print "<$bu>\n" if $debug;
if( $bu =~ /^((\d+\.){3})(\d+)$/ ) {
print "$1 $2 $3\n" if $debug;
}
output:
<172.19.252.130>
172.19.252. 252. 130
where did my thinking jump the tract?
I do see three sets of ()
but the inner () was simply to group for the {3} count
When a memory-parentheses section of a pattern repeats, the memory
holds the match from the "last time through". The last time through
for the second set of parentheses matched "252.". Is that what you
were wondering?
If you don't want the grouping parentheses to trigger memory,
non-memory parentheses are also available.
Cheers!
--Tom Phoenix
Stonehenge Perl Training
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>