This is a little fragile, to say the least. But then again, regexp approaches to parsing always are.

use strict; use warnings; my $page = join '', <DATA>; my( @raw_groups ) = split /src\s*=\s*['"]/, $page; my( @images, @texts ); foreach my $raw ( @raw_groups ) { my( $image, $text ); next unless ( $image, $text ) = $raw =~ m/^ (http:.+?) # Capture the file URL ['"].+?> # Anchors (.+?) # Capture the text <\/td # Final anchor /isx; print "$image => $text\n"; push @images, $image; push @texts, $text; } __DATA__ </a><br><br><table width="100%" cellpadding="2" cellspacing="0" border +="0"><tr><td align="left" valign="bottom"><img src='http://images.tek +-tips.com/items/image001.gif' alt='Image001' width='40' height='40' b +order='0'> Description of image here</td><td align="right" valign="bo +ttom"></td> </tr><tr><td align="left" valign="bottom"><img src='http://images.tek- +tips.com/items/image002.gif' alt='Image002' width='40' height='40' bo +rder='0'> Description of image here</td><td align="right" valign="bot +tom"></td>

Dave


In reply to Re: Pulling all instances of a regex out by davido
in thread Pulling all instances of a regex out by coldfingertips

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.