2010/12/9 Tim Peiffer <peif...@umn.edu>: > > I am trying to use mysql table lookups to extract connector and contact > information to provide look aside for handling various correlator. Can > I assign and dereference perl arrays in the eval minicode? How do I > pass parameters from the regexp as quoted strings to the SELECT ?
Inside Perl code executed with 'eval' action, you can do also manipulate arrays and hashes, since 'eval' action is just a wrapper around Perl's native eval() function. If you are using match variables inside Perl code, they are substituted as-is wihtout any additional processing, and therefore all quoting must be written explicitly into Perl code. kind regards, risto > > type=Single > desc=Database and DBI load > continue=TakeNext > ptype=SubStr > pattern=SEC_STARTUP > context=[SEC_INTERNAL_EVENT] > action=assign %b 0; \ > eval %b (use DBI; \ > my $dbh = > DBI->connect("DBI:mysql:database=ISP;host=localhost", \ > "root", "mypw"); \ > $dbh->{RaiseError} = 1; \ > $dbh->{AutoCommit} = 1; \ > 1; );\ > eval %b (exit(1) unless %a); \ > logonly %a; > > type=Single > desc=Peer Lookup > continue=TakeNext > ptype=RegExp > pattern=Peer (\d+\.\d+\.\d+\.\d+) > action= eval %type ( \ > $sth=$dbh->query("SELECT type from peering where ip=$1"); \ > while (@record = $sth->fetchrow() ) { \ > $type=$record[0]; \ > }; \ > $type; \ > ); \ > logonly %2 ip=$1 type=%type > > Evaluating code '$sth=$dbh->query("SELECT type from peering where > ip=1.1.1.1") while (@record = $sth->fetchrow() ) { > $type=$record[0]; }; $type; ' and setting > variable '%type' > Error evaluating code '$sth=$dbh->query("SELECT type from peering where > ip=1.1.1.1") while (@record = $sth->fetchrow() ) { > $type=$record[0]; }; $type; ': syntax error at > (eval 15) line 1, near ") {" > Peer Lookup ip=1.1.1.1 type=%type > > Please advise, > Tim Peiffer > > -- > Tim Peiffer > Network Support Engineer > Office of Information Technology > University of Minnesota/NorthernLights GigaPOP > > +1 612 626-7884 (desk) > > > ------------------------------------------------------------------------------ > _______________________________________________ > Simple-evcorr-users mailing list > Simple-evcorr-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users > ------------------------------------------------------------------------------ _______________________________________________ Simple-evcorr-users mailing list Simple-evcorr-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users