C
CSUIDL PROGRAMMEr
Folk
I am trying hard to run this script on fedora 3
It changes the following pattern in xml files
<!CDATA[slaaam]]> TO
<slaaam>
But it does not work. Any reasons
The script is a as follows
#!/usr/bin/perl
use strict;
use warnings;
my $start_dir = "/home/amjad/chatTrackBot_v1.5/xml_logs";
chdir($start_dir) or die "Can't chdir $start_dir: $!";
my @files = <*.xml>;
my @errors = ();
foreach my $file ( @files ) {
open(OLD, "<$file") or push @errors, "failed to open $file: $!";
open(TEMP, ">temp.txt") or push @errors, "failed to create temp
file: $!";
while (my $line = <OLD>) {
$line =~ s/<!\[CDATA\[([^\]]*)\]\]>/$1/ig;
print TEMP $line;
}
close OLD;
close TEMP;
rename('temp.txt', $file) or push @errors, "Rename failed: $!";
}
if (@errors) {
print "$_\n" for @errors;
}
else {
print "No errors";
}
I am trying hard to run this script on fedora 3
It changes the following pattern in xml files
<!CDATA[slaaam]]> TO
<slaaam>
But it does not work. Any reasons
The script is a as follows
#!/usr/bin/perl
use strict;
use warnings;
my $start_dir = "/home/amjad/chatTrackBot_v1.5/xml_logs";
chdir($start_dir) or die "Can't chdir $start_dir: $!";
my @files = <*.xml>;
my @errors = ();
foreach my $file ( @files ) {
open(OLD, "<$file") or push @errors, "failed to open $file: $!";
open(TEMP, ">temp.txt") or push @errors, "failed to create temp
file: $!";
while (my $line = <OLD>) {
$line =~ s/<!\[CDATA\[([^\]]*)\]\]>/$1/ig;
print TEMP $line;
}
close OLD;
close TEMP;
rename('temp.txt', $file) or push @errors, "Rename failed: $!";
}
if (@errors) {
print "$_\n" for @errors;
}
else {
print "No errors";
}