That's a good start as semi-pseudocode, but your example will never compile :
  1. you're using strict, which requires variables to be declared with my. You fail to do this.
  2. 4by6 is not a valid variable name, as it starts with a number.
  3. the parameters you pass to glob are incorrect. Glob expects string values, and you've provided some freeform text that resembles an unterminated regex.
  4. sort will not change the parameters it's passed, thus requiring, e.g.,  my @screenres=sort @screenres. However, you can just as easily write  @screenres=sort glob("* screen res.tif");
  5. Where are your files being stored? Unless a path is specified, glob uses the root directory as a default (I tested this under WinMe, does this hold true for *nix?). Specify your path in glob :  my @screenres=sort glob("c:/example/images/* screen res.tif");

    Better yet, separate your path out into its own variable for maintenance purposes:

    my $imagepath= "C:/example/images/"; my @screenres=sort glob("$imagepath* screen res.tif");
You are doing some good things, which most beginners miss :
  1. using strict
  2. using diagnostics (useful for new perl coders)
  3. splitting work into subs
I hope this makes some sense.

for the first step of your request :

A) The name is changed to something like 000014b6.tif, 00001sr.jpg, and 00001tn.jpg. (and possibly 000018b10.tif)
I would recommend using an underscore between the file name and the picture type, so 00001_4b6.tif and 00001_8b10.tif, and so on. This will assist you in determining where picture names stop, and picture types begin.

Also, check out the rename command, but since you are so new to perl, please back up all your pictures before commencing with renames :

Good luck!

Update a little more experiment with glob seems to reveal its output is always sorted. Can anyone confirm this?


In reply to (boo) Re: A monk in training with a problem by boo_radley
in thread A monk in training with a problem by wiz

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.