In article <c68vrd$qld$>, Rich Bogle
<> wrote:
> Does anyone have a good module or clean method for making sure file names do
> not have special charactes / illegal characters in them before attempting to
> save the file.
>
> I have a perl script that archives data based upon information in a text
> file in each directory. The archive location is derived from that location
> and I need to make sure there are no illegal / special characters in the
> file name before creating it.
>
> Thanks
>
> Rich
>
>
Use the tr operator to replace every character except those you wish to
keep. For example, if you only want the characters (a-zA-Z0-9_-.), use:
$filename =~ tr/a-zA-Z0-9_-.//cd;
For more info, enter "perldoc perlop" and search for 'Transliterates'.
FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future.
|