Jennifer Garner <mailto:[EMAIL PROTECTED]> wrote: : open (FILE,$file) or die "$!"; : while(<FILE>) : { : next if /unknown/o; : next if /^192\.168\./o; : chomp; : my ($ip,$num) = split/:/,$_; : if ($ip = ~ /^(\d+\.\d+\.\d+\.)(\d+)/o){ : my ($net,$bit) = ($1,$2); : $total{$net}{low}{$bit} = 1 if $bit < 128; : $total{$net}{high}{$bit} = 1 if $bit >=128 and : $bit < 255; : $total{$net}{total}{$bit} = 1; : } : }
On the file reading side: We could get rid of those /o modifiers on the regexes. IIRC, they're for variables in regexes. You can also eliminate the chomp() since we are throwing away that part of the line. We can remove the lexical variables which are slowing things down each time they are declared. And finally, we can eliminate the split(). while( <FILE> ) { next if /unknown/; next if /^192\.168\./; next unless /^(\d+\.\d+\.\d+\.)(\d+):/; $total{$1}{low}{$2} = 1 if $2 < 128; $total{$1}{high}{$2} = 1 if $2 >=128 and $2 < 255; $total{$1}{total}{$2} = 1; } : close FILE; HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 . . . With Liberty and Justice for all (heterosexuals). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>