Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Matts (1087)

Matts
  (email not shown publicly)

I work for MessageLabs [messagelabs.com] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Wednesday June 19, 2002
07:03 AM

Net::DNS patch

[ #5769 ]

Net::DNS makes SpamAssassin slow, because it uses $'. Here's a patch for that:

@@ -198,31 +156,28 @@
        my ($class, $rrstring, $update_type) = @_;
        my ($s, %self, $retval);
 
-       my $name     = undef;
+       my $name     = "";
        my $ttl      = 0;
        my $rrclass  = "";
        my $rrtype   = "";
        my $rdata    = "";
 
-       while ($rrstring =~ /\s*(\S+)\s*/g) {
-               $s = $1;
+  my @matches = $rrstring =~ /\s*(\S+)\s*/g;
+       while (defined($s = shift @matches)) {
 
-               if (!defined($name)) {
-                       #($name = $s) =~ s/\.+$//;
-                       $name = $s;
-                       $name =~ s/^\.+//;
-                       $name =~ s/\.+$//;
+               if (!$name) {
+                       ($name = $s) =~ s/\.+$//;
                }
                elsif ($s =~ /^\d+$/) {
                        $ttl = $s;
                }
                elsif (!$rrclass && exists $Net::DNS::classesbyname{uc($s)}) {
-                       $rrclass = uc($s);
-                       $rdata = $';  # in case this is really type=ANY
+                       $rrclass = $s;
+                       $rdata = join(' ', @matches);  # in case this is really type=ANY
                }
                elsif (exists $Net::DNS::typesbyname{uc($s)}) {
-                       $rrtype = uc($s);
-                       $rdata = $';
+                       $rrtype = $s;
+                       $rdata = join(' ', @matches);
                        last;
                }
                else {

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • (This might have gotten posted twice, I'm not sure. If it is a dup, sorry.)

    You should email me that patch, I'll put it in for the next CPAN release. (I'd grab it right off your journal, but it's not a full patch.)

    --

    --
    "Cake or Death!" .... "Cake please"
    • The patch actually broke SOA parsing. whoops. A modified version of this will be in the next CPAN release.
      --

      --
      "Cake or Death!" .... "Cake please"