dbrock has asked for the wisdom of the Perl Monks concerning the following question:
My attempt: '-B $logfile'; evedently does not tell me the difference between UTF16 or UTF8... Since I only want to process the UTF-16 .xml files i need help with the syntax to identify the UTF-8 files and skip them... I know that I could use XML::simple or XML::parser, but I am attempting to use regex to accomplish this... This IF statement will basically be updating functionallity to existing script with out writing a whole new one...if( $logfile =~ /.+\.xml/){ next unless '-B $logfile'; open(XMLFILE, '<:encoding(utf16)', $logfile)or die "Can't Open:$!"; while(<XMLFILE>) { $_ =~ s/^.*(<.*>)//g; $_ =~ s/\r//g; $_ =~ s/^\s//g; push @txtfile,$_; close(XMLFILE); }# While XML loop }#if XML loop print @txtfile;#for debug only
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how do I check encoding before opening FILEHANDLE
by gaal (Parson) on Feb 17, 2005 at 20:10 UTC | |
by PodMaster (Abbot) on Feb 17, 2005 at 21:37 UTC | |
by gaal (Parson) on Feb 18, 2005 at 08:41 UTC | |
|
Re: how do I check encoding before opening FILEHANDLE
by cowboy (Friar) on Feb 17, 2005 at 20:25 UTC | |
by dbrock (Sexton) on Feb 17, 2005 at 21:10 UTC | |
|
Re: how do I check encoding before opening FILEHANDLE
by graff (Chancellor) on Feb 18, 2005 at 08:45 UTC | |
by dbrock (Sexton) on Feb 18, 2005 at 20:31 UTC |