Perl script does not work
- From: "CSUIDL PROGRAMMEr" <syedamjad_a@xxxxxxxxx>
- Date: 29 Apr 2006 10:54:07 -0700
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";
}
.
- Follow-Ups:
- Re: Perl script does not work
- From: A. Sinan Unur
- Re: Perl script does not work
- From: Gunnar Hjalmarsson
- Re: Perl script does not work
- From: Matt Garrish
- Re: Perl script does not work
- Prev by Date: Re: Using =~ to Include and Omit in same line
- Next by Date: Re: chomp hash keys?
- Previous by thread: Multi-process Win32 HTTP Daemon
- Next by thread: Re: Perl script does not work
- Index(es):
Relevant Pages
|