valavanp has asked for the wisdom of the Perl Monks concerning the following question:
Output CSV file should be:– &dash
I converted the xls file into xml. Than i used the below code to do the task:'ߝ' => '‐'
I think the above code is not efficient. Can anyone suggest me efficient one to do that. Thanks all monks for your suggestion.use strict; use warnings; use XML::Twig; #open(FH, "conv.xml"); my $file="C:/conv.xml"; my $tmp; $tmp = XML::Twig->new(); $tmp->parsefile($file); my $root = $tmp->root; my $hex_value; my $entity_value; my $real_value; #while (<FH>){ open(FH, ">records.txt"); foreach my $record ($root->children('record')){ if ($record->first_child_text('hex_value') eq '') { $hex_value=''; }else{ $hex_value = $record->first_child_text('hex_value'); $hex_value=~s/^\s*//g; } if ($record->first_child_text('entity_value') eq '') { $entity_value=''; }else{ $entity_value = $record->first_child_text('entity_value'); $entity_value=~s/\s*$//g; } if ($record->first_child_text('real_value') eq '') { $real_value=$entity_value.";"; } #print "$real_value\n"; #print FH "Hexadecimal Value \t Entity Value \t Real_value"; print FH "\'$real_value\' => \'$hex_value\' +,\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Efficient solution needed for this program
by Corion (Patriarch) on Apr 03, 2007 at 13:33 UTC | |
|
Re: Efficient solution needed for this program
by Limbic~Region (Chancellor) on Apr 03, 2007 at 13:36 UTC | |
|
Re: Efficient solution needed for this program
by friedo (Prior) on Apr 03, 2007 at 16:21 UTC |