in reply to Re: Re: Changing file names as they are uploaded
in thread Changing file names as they are uploaded

How about:
my $rindex = rindex($imagename,'.'); $rindex = length($imagename) if $rindex == -1; substr($imagename,0,$rindex) =~ s/\W/_/g;
It will exclude the extension from the substitution.

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;
works correctly for $files such as "me~swimming.jpg", "J.R,ewing.jpg" and "abc;;;"

-Blake