Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Search and replace with special characters

by io (Scribe)
on Oct 02, 2002 at 13:27 UTC ( [id://202256]=note: print w/replies, xml ) Need Help??


in reply to [untitled node, ID 202198]

Why not use a hash?
#!/usr/bin/perl -w use strict; my $html = <<END_OF_HTML; Hello! oX World! <;<;<;<; Hi! Samn! (~) END_OF_HTML my %emotes = map {split /#####|\n/} <DATA>; for my $entry(keys %emotes) { $html =~ s!\Q$entry\E!<img src="$emotes{$entry}.gif">!g; } print $html; __DATA__ oX#####skullandbones <;#####pie (o)#####goatse (~)#####ninja
Note that im removing the trailing newline in the split operation, which is -ew- ugly.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-25 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found