Mr.Churka has asked for the wisdom of the Perl Monks concerning the following question:
It's not pretty, but it was getting the job done prior to the ">:utf8" addition. Now I'm being informed that "Print() on closed filehandle SUMMARY at my_perl_parser.pl line 30. I tried deleting the explicit close on line 30 with no effect. Is the > prior to Item Summary no longer telling perl to create a new file to write too?#!/bin/perl use strict; use warnings; use XML::Twig; use Tie::IxHash; my %Items; tie %Items, "Tie::IxHash"; my $twig=XML::Twig->new( twig_handlers => {_all_ => sub {my $Item_master_Ancestory = $_->ancestors; my $element_match = ($_->tag); my $text = ($_->trimmed_text); my $coupled = join( ' - ' => " "x$Item_master_Ancestory, +$element_match,values %{$_->atts},$text); if (!defined $Items{$coupled}){$Items{$coupled}=1} else {$Items{$coupled}++;} my( $t, $elt)= @_; $t->purge; }, } ); $twig->parsefile( '500syncItemMaster.xml'); open(SUMMARY, ">:utf8", ">Item Summary.txt"); my @k = keys %Items; foreach my $k (@k) {print SUMMARY ("$k => $Items{$k}\n");}; + # output the twig close(SUMMARY);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Solution to unicode issue creating more problems than it solves
by Corion (Patriarch) on Nov 27, 2007 at 14:30 UTC | |
|
Re: Solution to unicode issue creating more problems than it solves
by ikegami (Patriarch) on Nov 27, 2007 at 14:54 UTC |