Bryan R Harris wrote:
I'm having trouble with this, and I'm sure someone out there has a really
clever solution--
I have a hash, %data, with, say, 32 elements.
From that, I need an array going from 01 to 32, i.e. 01, 02, 03, 04, etc.
But if my hash had 750 elements, I'd want it to go from 001 to 750.
I thought this should be easy, but I'm really struggling with it--
This is the best I've come up with:
@allkeys = ('0' x (length(keys(%data)) - 1) . '1' .. keys(%data));
... but it doesn't work.
Any ideas?
my $num = keys %data;
my @allkeys = map sprintf( '%0*d', length( $num ), $_ ), 1 .. $num;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>