On Jul 18, Groove Salad said:
>Thanks for the quick response. I think what you've described is a bit
>over my head. But, I'll try it and see what happens.
>
>The files will always be, env-yyyymmdd-nn and will get rotated at months
>end. However, your solution much more flexible.
Since they'll always be two digits, you can simplify my code a bit:
>> sub normalize {
>> my $file = shift;
>> $file =~ s/^env-//;
>> $file =~ s/-(\d+)/sprintf "%02d", $1/;
>> return $file;
>> }
>>
>> sub retrieve {
>> my $num = shift;
>> $num =~ s/(\d\d)$//;
>> (my $minor = $1) =~ s/^0//;
>> return "env-$num-$minor";
>> }
In retrospect, my regex needn't have been so complex. We wanted to remove
the leading 0's, but not ALL of them -- only one or two, but not three.
s/^0{1,2}//;
# or
s/^00?//;
That said, my regex is now far simpler.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]