Hi Perlmonks!, you just helped me out very fine in an old post, but now there is a change which leads me to a new question. I found out that replacing of a single word or word combinations sometimes does not work although I mark them for not beeing interpreted. In this case I have a txt document which includes '+#' . Perl is not able to replace this two signs by '$coin22'. With other signs it just works fine. How can I improve my program to not interpret the strings he wants to read in at all? Here my skript:
Thank you very much in advance! Best regards#!/usr/bin/perl -w #use strict; my $SCU = 'C:/Users/user/Desktop/a.txt'; open (FILE, '<', $SCU) or die "$SCU File not found : $!"; my @lines = <FILE>; close (FILE); my $A= '+#'; my $B= '$coin22'; my @newlines; push @newlines, s/$A/$B/rg for @lines; open (FILE, '>', $SCU) or die "Could not open file $SCU: $!"; print FILE @newlines; close (FILE);
In reply to seek and replace for exceptional characters by semipro
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |