Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
...code here #Random Number my $n_range = 100000; my $n_minimum = 1; my $random_num = int(rand($n_range)) + $n_minimum; #@ext will have my valid extension, I am looking for .pdf my $file_in = param('manual'); # This parameter is from the upload for +m. if ($file_in){ foreach $ext (@ext){ if (grep /$ext$/i,$file_in){ $match=1; } } if ($match){ opendir(DIRCHCK, $dir) or die $!; while ($check_file = readdir(DIRCHCK)) { #chomp $check_file; $check_file=~ s/\s+$//; # Only files next unless (-f "$dir$check_file"); # Find files ending in .pdf next unless ($check_file =~ m/\.pdf$/); $file_in =~ s/.*[\/\\](.*)/$1/; if($check_file=~/\b$file_in\b/gi){ rename "$file_in", "$random_num"."$file_in" or warn " +Couldn't rename file: $!\n"; } } #end while closedir(DIRCHCK); #call upload &upload; }else { &go_bk; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Rename Uploaded File
by pc88mxer (Vicar) on Feb 12, 2008 at 19:32 UTC | |
by Anonymous Monk on Feb 12, 2008 at 20:33 UTC | |
by Anonymous Monk on Feb 12, 2008 at 19:56 UTC |