http://qs321.pair.com?node_id=1135015


in reply to How to handle metacharacters in input file for Perl one-liner code

Not being a windows person, I don't know if the \Q\E quotemeta that marinersk is suggesting will have problems when passed to the windows shell, but I'm fairly certain that there would be at least some risk that you might eventually need to include a character that causes some pain due to shell escaping. Thus, I beg you consider doing it the long way.

my $file = "foo.c"; rename "sample.csv", "sample.csv.bak" or die "Error backing up sample. +csv: $!"; open my $IN, "<", "sample.csv.bak" or die "Error reading sample.csv +.bak: $!"; open my $OUT, ">", "sample.csv" or die "Error writing to sample. +csv: $!"; while (defined(my $line = <$IN>)) { $line =~ s/\Q$file\E/$file,=SUM(B$x:B$y)/; print $OUT $line; }

Good Day,
    Dean