The array $times is previously populated with text (Wednesday Night, Thursday, Thursday Night, ect.). I am guessing that it has something to do with creating an array for $imagen with ImageMagick, but I'm not quite sure how else to do this right now.

Hi, it's a little known fact-of-life that IM maintains a global stack of images that it uses for its own purposes, so you need to clear out the IM object after every run thru the loop. Whenever you read an image, it gets pushed into an internal array for storage. This useful sometimes, as in certain IM methods, all images can be processed by going thru this array. Of course, it also can get in the way sometimes, as you have seen. What you you probably need to do is undef @$my_IM_object, as shown here:

my $image = Image::Magick->new; foreach my $pic (@pics){ my $ok; $ok = $image->Read($pic) and warn ($ok); $image->Scale(geometry => '100x100'); $ok = $image->Write($thumb) and warn ($ok); # this is the key line undef @$image; #needed if $image is created outside loop
You can also read perldoc -q clear and read the first section "How do I clear out a package?".

Of course, this is just my top-of-the-morning guess at your problem, because your code dosn't even look like it will run correctly with things like my $imagen($i) =. That dosn't match any data structure commonly used in Perl.


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re: Loop array with ImageMagick by zentara
in thread Loop array with ImageMagick by johnfl68

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.