semipro has asked for the wisdom of the Perl Monks concerning the following question:
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: seek and replace for exceptional characters
by toolic (Bishop) on Sep 23, 2013 at 17:20 UTC | |
|
Re: seek and replace for exceptional characters
by MidLifeXis (Monsignor) on Sep 23, 2013 at 17:45 UTC | |
by semipro (Novice) on Sep 23, 2013 at 17:53 UTC | |
|
Re: seek and replace for exceptional characters
by marinersk (Priest) on Sep 23, 2013 at 17:35 UTC | |
|
Re: seek and replace for exceptional characters
by Laurent_R (Canon) on Sep 23, 2013 at 18:00 UTC | |
by semipro (Novice) on Sep 23, 2013 at 18:18 UTC | |
by marinersk (Priest) on Sep 23, 2013 at 22:09 UTC | |
by toolic (Bishop) on Sep 23, 2013 at 18:33 UTC |