in reply to Re: Changing file names as they are uploadedin thread Changing file names as they are uploaded
my $rindex = rindex($imagename,'.'); $rindex = length($imagename) if $rindex == -1; substr($imagename,0,$rindex) =~ s/\W/_/g; [download]
Update: Fixed bug for filenames w/o extensions that end in a nonword char.
Update2: Thought I'd golf this one a bit:
substr($file,0,rindex($file,'.')%length"a$file") =~ s/\W/_/g; [download]
-Blake