update I started on a unix OS and ended up switching to windows halfway through development. I missed the glob as it hadn't caused an issue before. Thanks everyone!

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.

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 }
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.

In reply to filename flagged as Invalid argument by Mr.Churka

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.