Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > File Name Checking

Reply
Thread Tools

File Name Checking

 
 
Rich Bogle
Guest
Posts: n/a
 
      04-22-2004
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


 
Reply With Quote
 
 
 
 
Rich Bogle
Guest
Posts: n/a
 
      04-22-2004
Just thought that I should mention the email goes straight to a junk account
so all replies should be posted in the group.
Thanks.


"Rich Bogle" <(E-Mail Removed)> wrote in message
news:c68vrd$qld$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Jim Gibson
Guest
Posts: n/a
 
      04-22-2004
In article <c68vrd$qld$(E-Mail Removed)>, Rich Bogle
<(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking for a valid file name m Java 2 08-08-2007 10:02 PM
adding a variable name to a hash to name is part of the variable name Bobby Chamness Perl 2 04-22-2007 09:54 PM
print("my name is {name}, and {age}-year old {gender}", name, age, gender); =?iso-8859-1?B?bW9vcJk=?= Java 7 01-02-2006 04:39 PM
name = name.substring(0, name.lastIndexOf('.')); Help please Jack-2 Javascript 3 12-24-2003 04:39 PM
Re: Urgent! how to get object name, method name and attribute name based on the strings? ding feng C++ 2 06-25-2003 01:18 PM



Advertisments