better would be a test, whether $1 is between 1-12 or 13-24 or 25-36 ...

$src            =>          $dest

files1-12       =>          file01_
files13-24      =>          file02_
files25-36      =>          file03_

If I understand your numbering scheme, you need something like this:

$newnumber = printf ("%02d",(int((($oldnumber -1)/12)+1)));

though that looks a little complex! It works in this small script:

for(@ARGV){
printf ("$_ => %02d\n",(int((($_ -1)/12)+1)));
}

when called with

perl numberscheme 1 12 13 24 25 26 36 37

it produces this result:

1 => 01
12 => 01
13 => 02
24 => 02
25 => 03
26 => 03
36 => 03
37 => 04

and Perl will even handle "01a" as 1:

perl numberscheme 01a 12 13 24 25 26 36 37
01a => 01
12 => 01
13 => 02
24 => 02
25 => 03
26 => 03
36 => 03
37 => 04

the best way might be to make a subroutine using that calculation.

Reply via email to