ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Saving set of xml files
by Shailesh Shinde other posts by this author
Jun 1 2007 10:49PM messages near this date
view in the new Beta List Site
Re: Proposal: SAX filter for conditional XML | Re: Saving set of xml files
& XSLT Hello All,

 

I have a set of xml files with encoding iso-8859-1, I have to save it all
xml files in utf8 using perl script...

For the same I have done something like below, but I did not get output from
it, can you please suggest what to do?

 

Perl script: 

 

use Encode;

use File::Find;

use Cwd;

$wrkdir= getcwd;

$^I='.bk';

system "attrib -r /s";

print "Looking in $wrkdir\n";

find(\&recurse_src_path,$wrkdir);

sub recurse_src_path

{

                my $file = $File::Find::name;

                my $fname = $_;

                

                                if ( (-f $file) && ($file=~/.*\.xml$/i) )

 

                {

                print "${fname}\n";

                open(FILE, $file) || die "Cannot open $file:\n$!";

                while(<FILE> ){

                                Encode::from_to($_, "iso-8859-1", "utf8");

                                print $file $_;

                                }

                }

                close FILE;

}

 

Quag

SHAILESH SHINDE 
Localization Engineer 
Quagnito Solutions Pvt. Ltd.  
6th Floor, Windsor Manor,
S.No.2/8/1, Opp. Baner Telephone Exchange,
Baner Road, Pune 411 045, India. 

Tel: +91 20 27292039/40 Extn: 204

Mob: +91 9923075899

Resi: +91 20 27036645

Website:  <http://www.quagnito.com/>  www.quagnito.com

 
Thread:
Shailesh Shinde
Jonathan Stowe
Shailesh Shinde
Jonathan Stowe

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved