in reply to Including special characters in a search and replace

Use an index for your array of fields, combined with the /g modifier. This one works:

#!/usr/bin/perl -w use strict; my $line = "00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,01,00,00,00," ."02,00,01,00,39,00,39,00,39,00,39,00,30,00,30,00,30,00,30,00," ."00,00,00,00,00,00,00,00,00,00,"; my @fields = (100, 101, 102, 103); my $index =0; $line =~ s/\b39\b/$fields[$index++]/g; print $line; __END__ output: 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,01,00,00,\ 00,02,00,01,00,100,00,101,00,102,00,103,00,30,00,30,00,30, \ 00,30,00,00,00,00,00,00,00,00,00,00,00,

See perlre for an explanation of the modifiers I have used here.