legLess has asked for the wisdom of the Perl Monks concerning the following question:
My CGI script is going to accept uploaded files and then put them somewhere. I don't want to overload one directory, so I'm using a three-level structure: "a/aa/aaa" to "z/zz/zzz". This way no directory has over 26 sub directories, no directory has more than $MAX (constant) files, and there are 26^3 possible directories.
It works as expected, with two caveats:my( $p1, $p2, $p3 ); # path parts, each one character, from database my( $count ); # number of directory items, from database if( $count > $DIR_MAX_ENTRIES ) { if( $p3 eq 'z' ) { $p3 = 'a'; if( $p2 eq 'z' ) { $p2 = 'a'; $p1 = chr( ord( $p1) + 1 ); } else { $p2 = chr( ord( $p2) + 1 ); } } else { $p3 = chr( ord( $p3) + 1 ); } }
Any advice from the monks? Thanks!
--
man with no legs, inc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Incrementing characters
by davorg (Chancellor) on Sep 06, 2001 at 20:15 UTC | |
|
Re: Incrementing characters
by bbfu (Curate) on Sep 06, 2001 at 20:16 UTC | |
|
Re: Incrementing characters
by andye (Curate) on Sep 06, 2001 at 20:56 UTC | |
|
Re: Incrementing characters
by George_Sherston (Vicar) on Sep 06, 2001 at 21:13 UTC | |
|
Re: Incrementing characters
by John M. Dlugosz (Monsignor) on Sep 07, 2001 at 03:35 UTC |