This is a sub routine part of my code to process a zip file. It works, but the part I am having problems with is that inside of this zip file I have image files and a XML file that will have account numbers in it. I need to match the account numbers found inside of this XML file with the file name of these image files, the account number is part of the name on the image files - (account number=12345 - image file=12345_0223.jpg); and send results to this other sub routine to finish some other stuff. If you look at the code here I have the file name off the first foreach loop and I am pulling the account numbers from the second foreach loop from the XML tags"<account>(.*?)<\/account>". I am having a brain freeze trying to figure it out how to check if these values mach and how to send them to the next subroutine, I am stuck, any help would be great!
Thanks for looking!!!!
sub zip { my $zip_file = shift; return unless ($zip_file); my $zip = Archive::Zip->new( $zip_dir . $zip_file ) || die; my $file_name = $zip->read(); # read file xml foreach my $member ($zip->members()) { # print file information my $member_file_name = $member->fileName(); push @members_name, $member_file_name; # here I ahve the file na +me example: bunch of file names like: 12345_0223.jpg 77664_0223.jpg . +.. } my @xml_files = $zip->membersMatching( '.*\.XML' ); foreach (@xml_files) { my $xml = $_->xml(); open my $xml_fh, '<', \$xml or die "Can't open scalar filehandle: $!"; my $first_line = <$xml_fh>; while (<$xml_fh>) { chomp; if(/<account>(.*?)<\/account>/gi){ my $accountnumber = $1; print "Test - $accountnumber\n"; # here I have the account n +umbers from he xml file, like: 12345 77664 ... # now here I would like to match the account number, if its +part of a file name in @members_name # and send results to the other sub with corresponded values +. if () { to_sub( $zip, $accountnumber, $members_name[] ); } } } } }

In reply to Match file names in a Zip file help by Anonymous Monk

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.