Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: map DBI results

by Aristotle (Chancellor)
on Dec 16, 2002 at 19:33 UTC ( #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
Node Status?
node history
Node Type: note [id://220308]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2018-07-19 21:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (420 votes). Check out past polls.

    Notices?