Doin' thumbnails, eh? How about a control break?

use strict; my @files = <DATA>; my %filehash = (); #put the split data into a hash keyed by the filename foreach (@files) { chomp; my @data = split /:/; $filehash{@data[2]} = [@data]; } my ($key, $last, $temp, $infoline, @value); #sort the hash by key for $key (sort keys %filehash) { #determine the first letter of the key $temp = substr($key, 0, 1); #here's the control break... #if we haven't seen the first letter of the key before, #"break" control, do something special, and carry on... if ($last ne $temp) { $last = $temp; print "\n<H1>$last</H1>\n"; } @value = @{$filehash{$key}}; $infoline = qq(<a href="@value[0]/@value[2]"><img src="images/@val +ue[3]" width="128" height="128" alt="@value[4]"></a><p>); print "\t$infoline\n"; } __DATA__ /path:jpg:mfile.jpg:stuff:stuff /path:jpg:afile.jpg:stuff:stuff /path:jpg:anotherfile.jpg:stuff:stuff /path:jpg:bfile:stuff.jpg:stuff /path:jpg:cfile:stuff.jpg:stuff /path:jpg:nfile:stuff.jpg:stuff /path:jpg:dfile:stuff.jpg:stuff /path:jpg:efile:stuff.jpg:stuff /path:jpg:ffile:stuff.jpg:stuff /path:jpg:gfile:stuff.jpg:stuff /path:jpg:hfile:stuff.jpg:stuff /path:jpg:ofile:stuff.jpg:stuff /path:jpg:stillanotherfile.jpg:stuff:stuff /path:jpg:ifile:stuff.jpg:stuff /path:jpg:jfile:stuff.jpg:stuff /path:jpg:kfile:stuff.jpg:stuff /path:jpg:lfile:stuff.jpg:stuff /path:jpg:pfile:stuff.jpg:stuff /path:jpg:qfile:stuff.jpg:stuff /path:jpg:rfile:stuff.jpg:stuff /path:jpg:sfile:stuff.jpg:stuff


In reply to Re: Help to improving my code please? by cciulla
in thread Help to improving my code please? by spacey

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.