I'm working on a script that will allow authorized users to upload files to the web server(it's mostly done & does work) but to avoid possible problems I want to remove any white space from the names of the files being uploaded. i.e. Foo Bar.txt would upload as FooBar.txt. A friend suggesed tr/// but I can't find too much on how I'd use that in this particular instance.
I'd appreciate any suggestions, comments, etc.
Thanks!
[url=http://www.perldoc.com/perl5.8.0/pod/func/tr.html]tr[/url]/searchlist/replacementlist/modifiers; and [url=http://www.perldoc.com/perl5.8.0/pod/func/y.html]y[/url]/searchlist/replacementlist/modifiers; will replace all occurrences of the characters found in the search list with the corresponding character in the replacement list. They do not support RE character classes like \s, \w, or \d. So
[url=http://www.perldoc.com/perl5.8.0/pod/func/s.html]s[/url]{Aaron}{Carter}g; is fundamentally different from [url=http://www.perldoc.com/perl5.8.0/pod/func/y.html]y[/url]{Aaron}{Carter};. The former will replace Aaron with Carter while the latter will replace A with C, a with a, r with r, o with t, and n with e. To achieve the same thing as with the RE in my above post you would need to list all whitespace you want to delete like so:
tr{\t\r\f\n }{}d;. Andreas
Thatīs exactly the same as the RE posted in message #2.
s{\s+}{}g; will replace...
>>$File_name =~ s/" "//g;
This will delete all occurances of " " from the string contained in $File_name. Given a string of Aaron Carter it would not be altered by this RE since it does not contain " ". To delete all spaces the RE would need to look like this:
s/ //g;
s{ }{}g;
I hope that clears things up a bit.
Andreas