Hello, I'm trying to parse multiple xml files but i'm a bit stuck with something. The  $twig->parsefile("output_1.xml"); section of the below script work fine in parsing the file stated. However, I would like to parse all of the .xml files in the direcotry. I have tried writing each file into the code like so:  $twig->parsefile("output_1.xml" "output_2.xml" "output_3.xml"); And i've also tried using a wildcard like I would in bash like so :  $twig->parsefile("*.xml"); But none of these attempts work. How can I change the script so that all of the .xml files in the directory are parsed by the script? I appologise fr my lack of knowledge, i've only just started using Perl.
#!/bin/perl -w use strict; use XML::Twig; my $twig = XML::Twig->new( twig_handlers => {item => \&acct} ); $twig->parsefile("output_1.xml"); sub acct { my ($t, $elt) = @_; for my $tag (qw(itemId title viewItemURL convertedCurrentPri +ce)) { print $elt->field($tag), "\n"; } print "\n"; print "\n"; }

In reply to Code to 'wildcard' multiple files or another suggestion? by bms9nmh

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.