Re: Perl script does not work
- From: "Matt Garrish" <matthew.garrish@xxxxxxxxxxxx>
- Date: Sat, 29 Apr 2006 14:07:35 -0400
"CSUIDL PROGRAMMEr" <syedamjad_a@xxxxxxxxx> wrote in message
news:1146333247.131872.286590@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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
How does it not work? What you want it to do is half the equation. What it's
actually doing is also required for people to have any way of helping you.
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;
You're reading the file line-by-line here, so the assumption is the CDATA
block is all on one line. I wouldn't think that's a safe assumption to make.
You might want to consider using a real XML parser.
Matt
.
- References:
- Perl script does not work
- From: CSUIDL PROGRAMMEr
- Perl script does not work
- Prev by Date: Re: chomp hash keys?
- Next by Date: Re: Perl script does not work
- Previous by thread: Perl script does not work
- Next by thread: Re: Perl script does not work
- Index(es):
Relevant Pages
|