diff options
author | Brad Gilbert <b2gills@gmail.com> | 2012-09-16 15:23:36 -0500 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-09-25 14:35:12 -0700 |
commit | 7b29226f59fa6ba0679496494a3cc111aa82a513 (patch) | |
tree | 8529411a4b91c575d8ae4264401447645de323e4 /t/test.pl | |
parent | a087e8153f95d3e52d52a6d8ce91cd2f671e4649 (diff) | |
download | perl-7b29226f59fa6ba0679496494a3cc111aa82a513.tar.gz |
Rework tempfile() in t/test.pl to use _num_to_alpha()
Diffstat (limited to 't/test.pl')
-rw-r--r-- | t/test.pl | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -807,24 +807,23 @@ END { unlink_all keys %tmpfiles } $::tempfile_regexp = 'tmp\d+[A-Z][A-Z]?'; # Avoid ++, avoid ranges, avoid split // +my $tempfile_count = 0; sub tempfile { - my $count = 0; - do { - my $temp = $count; + while(1){ my $try = "tmp$$"; - do { - $try = $try . $letters[$temp % 26]; - $temp = int ($temp / 26); - } while $temp; + my $alpha = _num_to_alpha($tempfile_count,2); + last unless defined $alpha; + $try = $try . $alpha; + $tempfile_count = $tempfile_count + 1; + # Need to note all the file names we allocated, as a second request may # come before the first is created. - if (!-e $try && !$tmpfiles{$try}) { + if (!$tmpfiles{$try} && !-e $try) { # We have a winner $tmpfiles{$try} = 1; return $try; } - $count = $count + 1; - } while $count < 26 * 26; + } die "Can't find temporary file name starting 'tmp$$'"; } |