You are using the default binding to $_ for the substitution without setting it. Also, the \Q\E pair in the replacement string are unwanted. Finally, the @pairs get overwritten with each iteration, which may or may not be OK depending on which string you want to modify. Assuming you want the replacement to be in @emotes,
#!/usr/bin/perl -w use strict; my $images_url = '/images'; my @emotes = <DATA>; foreach my $entry (@emotes) { chomp $entry; my @pairs = split(/#####/, $entry); $entry =~ s/\Q$pairs[0]\E/<img src=\"$images_url\/emote_$pairs[1]. +gif\">/g; } print "@emotes",$/; __DATA__ oX#####skullandbones <;#####pie (o)#####goatse (~)#####ninja
I also arranged for the image url to be quoted.
After Compline,
Zaxo
In reply to Re: Search and replace with special characters
by Zaxo
in thread [untitled node, ID 202198]
by Samn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |