Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: map DBI results

by Aristotle (Chancellor)
on Dec 16, 2002 at 19:33 UTC ( [id://220308]=note: print w/replies, xml ) Need Help??


in reply to map DBI results

Everybody explained why map doesn't mix too well with s/// and how you want a different delimiter than the forward slash there, but what I wonder is why you're using map at that point at all? It would be far simpler to say
while (my @row = $sth->fetchrow_array()) { s!$term!"<i>$term</i>"! for @row; # ... }
You also probably want to escape pattern metacharacters in $term (s!\Q$term!"<i>$term</i>"!, perldoc -f quotemeta), and it might help to precompile the pattern:
my $rx = qr/\Q$term/; while (my @row = $sth->fetchrow_array()) { s!$rx!"<i>$term</i>"! for @row; # ... }

Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://220308]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-25 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found