1 package SL::SessionFile::Random;
4 use parent qw(SL::SessionFile);
6 my @CHARS = ('A'..'Z', 'a'..'z', 0..9, '_');
7 my $template = 'X' x 10;
8 use constant MAX_TRIES => 1000;
11 my ($class, %params) = @_;
15 $filename = _get_file() while $tries++ < MAX_TRIES && (!$filename || -e $filename);
17 $class->SUPER::new($filename, %params);
21 my $filename = $template;
22 $filename =~ s/X(?=X*\z)/$CHARS[ int( rand( @CHARS ) ) ]/ge;
34 SL::SessionFile::Random - SessionFile with a random name
38 use SL::SessionFile::Random;
40 # Create a session file named "customer.csv" (relative names only)
41 my $sfile = SL::SessionFile::Random->new("w");
42 $sfile->fh->print("col1;col2;col3\n" .
43 "value1;value2;value3\n");
48 This modules gives you a random file in the current session cache that is guaranteed to be unique
52 same as SL::SessioNFile
60 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>