]> git.etc.gen.nz Git - asterisk-agi-enum.git/commitdiff
Modifications to make NAPTR regex work and Asterisk resources to work.
authorAndrew Ruthven <andrew@etc.gen.nz>
Tue, 13 Jan 2009 07:58:13 +0000 (20:58 +1300)
committerAndrew Ruthven <andrew@etc.gen.nz>
Tue, 13 Jan 2009 07:58:13 +0000 (20:58 +1300)
enum.agi

index 92da2eb30c2bcd5578149f577f8bc7c61cf7c4fc..a852aa18157d45cb163435f662c31b00d507eebb 100644 (file)
--- a/enum.agi
+++ b/enum.agi
@@ -83,10 +83,12 @@ sub get_resources {
 
         $resource = $ARGV[0];
         my ( $pattern, $replacement ) = ( split '!', $rr->regexp )[ 1, 2 ];
-        print "$pattern, $replacement\n";
-        unless ( $resource =~ s/$pattern/$replacement/ ) {
-            $A->verbose( "Unable to apply regexp to $ARGV[0]", 4 );
-        }
+        $replacement =~ s/\@/\\\@/;
+        $resource    =~ s/^\+//;
+        $A->verbose( "$pattern, $replacement", 4 );
+        my $regexp = "\$resource =~ s/$pattern/$replacement/";
+        eval "$regexp";
+        $A->verbose( "new resource: $resource", 4 );
         $resource =~ s/^(\w+):/\U$1\//;
         $records{$count} =
           { preference => $rr->preference, resource => $resource };