Difficult to explain perhaps.

I am using www::mech to fill out a form. There's an @array that holds a dynamic amount of content that needs to be filled in.

The form has 6 upload fields per page and I'm uploading every file from one of my directories into the page (looping over each set of 6 from the array until it submitted them all).

My question is, how do I submit the form for every 6 files while making sure the last set ONLY submits the number of remaining in case it's not an even set? I'm not really sure where to start the loop whether because I assume it has to follow $mech->submit_form( and before it submits.

The form allows 6 upload sets, each set has it's own upload file name and file category field (pic_file0-5 and pic_category0-5 respectively.). The username and email address only get passed once though.

I apologize if this sounds confusing but I have no idea where to begin the loop or how to have it submit every 6 files.

my @files = (); # assume there are files in here use WWW::Mechanize; my $mech = WWW::Mechanize->new(agent=>"Bot 1.0"); $mech->get( $url ); $mech->submit_form( $form_number => 1, fields => { # the image name and category here for each @files submitter_name => $username, submitter_email => $email, });

2006-03-14 Retitled by planetscape, as per Monastery guidelines
Original title: 'using mech with loops'


In reply to using WWW::Mechanize with loops 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.