Hello monks, I'm writing a bit of code to dump a catalog into a MySQL 4.1 database. To check the XML for accuracy, I want to dump it into a text file to look it over before dumping it into my database. I've set a series of subs to pull out the useful information, build a hash of hashes to keep the relationships. I then dereference the hashes and print them to a text file.
Here's my code.
I've used this exact syntax to print to a file before, but this time when I used it I am receiving the following error. Could not open "Hashstructure.txt":Invalid argument at line 141. I'm not really sure what the conflict is. I've read the "Inavlid argument" threads and none of them really seem to apply. Google also fails me. Any help appreciated.use strict; use warnings; use DBI; use xml::twig; use utf8; my $dbh= connect_to_db(); our ($SKUgroupNUMBER, $smallPACKAGE, $sellingpoint1, $sellingpoint2, $ +sellingpoint3, $summarySELLING, $longSELLING, $skuGROUPimage, $skuGRO +UPaltIMAGE); my $file =<"SyncItemMaster.xml">; my $filename = <"Hashstructure.txt">; my $twig=XML::Twig->new( twig_handlers=> { 'oa:Codes[@name="Small_Package_Indicator"]'=> \&smallpack +, 'oa:Note[@status="Selling_Point_1"]'=> \&sell1, 'oa:Note[@status="Selling_Point_2"]'=> \&sell2, 'oa:Note[@status="Selling_Point_3"]'=> \&sell3, 'oa:Note[@status="Summary_Selling_Statement"]'=> \&summary +, 'oa:Note[@status="Long_Selling_Copy"]'=> \&longsell, 'us:SkuGroupImage' => \&image, 'us:SkuGroupAlternateImage' => \&altimage, 'oa:Code[@name="SKU_Group_Id"]'=> \&skuid, } ); $twig->parsefile("500SyncItemMaster.xml"); our %mirror; sub skuid{ my ($t, $node)=@_; my $prefix=$node->parent->parent->parent->first_child->nex +t_sibling->text; my $stock=$node->parent->parent->parent->first_child->next +_sibling->next_sibling->text; my $itemnumber="$prefix$stock"; my $value=$node->text; my $column="skuGROUPnumber"; $mirror{"$itemnumber"}={ $column =>"$value"}; #...lots of similar subs... open(my $fh,'>:utf8', "$filename") or die "Could not open $filename:$!"; my @k = (sort keys %mirror); foreach my $k (@k){ my $v = $mirror{$k}; my %hash = %$v; foreach my $h (keys %hash){ print $fh ("$k => \n $h => $hash{$h}\n")}; # print + the hash }
In reply to filename flagged as Invalid argument by Mr.Churka
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |