in reply to storing a qr// compiled regexp in a database?
Your "precompilation" won't gain you anything, but it's easily possible:
my $compiled_regex = qr/$regex/; my $sth = $dbh->prepare("insert into regexes name,value (?,?)"); $sth->execute("ready_to_eat", $compiled_regex); # later my $sth = $dbh->prepare("select value from regexes where name = ?"); my $rc = $sth->execute("ready_to_eat"); my @values = map { $_->value } $sth->fetchrow_array({}); # or somethin +g, look in the DBI docs # convert back to compiled regex for (@values) { $_ = qr/$_/; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: storing a qr// compiled regexp in a database?
by ManFromNeptune (Scribe) on Sep 17, 2005 at 21:16 UTC | |
by Corion (Patriarch) on Sep 17, 2005 at 21:18 UTC | |
by ManFromNeptune (Scribe) on Sep 17, 2005 at 21:52 UTC | |
by traveler (Parson) on Sep 18, 2005 at 17:55 UTC |