summaryrefslogtreecommitdiff
path: root/t/test.pl
diff options
context:
space:
mode:
authorBrad Gilbert <b2gills@gmail.com>2012-09-16 15:23:36 -0500
committerFather Chrysostomos <sprout@cpan.org>2012-09-25 14:35:12 -0700
commit7b29226f59fa6ba0679496494a3cc111aa82a513 (patch)
tree8529411a4b91c575d8ae4264401447645de323e4 /t/test.pl
parenta087e8153f95d3e52d52a6d8ce91cd2f671e4649 (diff)
downloadperl-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.pl19
1 files changed, 9 insertions, 10 deletions
diff --git a/t/test.pl b/t/test.pl
index 5c7d7379f5..bf9269b7f9 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -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$$'";
}