1
2
3
4
5
for my $file (@files)
{
my $XML = XMLin($xmldir.'/'.$file, ForceArray => 1);
push(@EVENTS,$XML);
}
1
2
3
my $regex = $EVENTS[$A]{Alarm}[$B]{RegExpMapping}[0];
$regex =~ s/\\\\/\\/g;
$EVENTS[$A]{Alarm}[$B]{RegExpMapping}[0] = $regex;
1 2 3 4 5 6 7 8 9
#!/usr/bin/perl use strict; use warnings; my $string = '\\w'; $string =~ s/(\\)+/\\/g; print $string;
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $string = '\\w'; print $string; print "\n"; print Dumper $string;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $string = '\\w';
$string =~ s/(\\)+/\\/g;
print "PRINT: $string\n";
print Dumper "DUMPER: ".$string;
Ergebnis:
PRINT: \w
$VAR1 = 'DUMPER: \\w';
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $string = '\\w'; print "PRINT vor subst: $string\n"; print Dumper "DUMPER vor subst: ".$string; print "Length vor subst: " . length($string) . "\n\n"; $string =~ s/(\\)+/\\/g; print "PRINT nach subst: $string\n"; print Dumper "DUMPER nach subst: ".$string; print "Length nach subst: " . length($string) . "\n"; __END__ Output: PRINT vor subst: \w $VAR1 = 'DUMPER vor subst: \\w'; Length vor subst: 2 PRINT nach subst: \w $VAR1 = 'DUMPER nach subst: \\w'; Length nach subst: 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $old_s = <DATA>; chomp($old_s); my $new_s = $old_s; $new_s=~ s/\\\\/\\/g; print "PRINT:\n$old_s\n$new_s\n"; print "DUMPER:\n".Dumper $old_s, $new_s; __DATA__ \\w