A
Adam Funk
I had some very large RDF-XML files that had been incorrectly
generated with the prolog
<?xml version='1.0' encoding='UTF8'?>
which I wanted to change to
<?xml version='1.0' encoding='UTF-8'?>
so I used the following command.
perl -pi.bak -e 's!^(<\?xml version=.1\.0. encoding=.)UTF8(.\?\>)!\1UTF-8\2!' *.rdf
It worked, but I have three questions about doing it better.
1. Is there any way to specify single quotes (') in the pattern? (I
realize this is at least as much of a shell problem as a Perl
problem; this is in bash on GNU/Linux.)
2. Is it possible to tell the command to look at the first line of
each file only? (These were very large files.)
3. Is it possible to make a perl -i command print to STDOUT the
changes it makes (and only the changed lines)?
Thanks,
Adam
generated with the prolog
<?xml version='1.0' encoding='UTF8'?>
which I wanted to change to
<?xml version='1.0' encoding='UTF-8'?>
so I used the following command.
perl -pi.bak -e 's!^(<\?xml version=.1\.0. encoding=.)UTF8(.\?\>)!\1UTF-8\2!' *.rdf
It worked, but I have three questions about doing it better.
1. Is there any way to specify single quotes (') in the pattern? (I
realize this is at least as much of a shell problem as a Perl
problem; this is in bash on GNU/Linux.)
2. Is it possible to tell the command to look at the first line of
each file only? (These were very large files.)
3. Is it possible to make a perl -i command print to STDOUT the
changes it makes (and only the changed lines)?
Thanks,
Adam