View Single Post
Old Jul 12th, 2006, 10:53 AM   #1
tbohon
Newbie
 
Join Date: Mar 2006
Location: Olympia WA USA
Posts: 11
Rep Power: 0 tbohon is an unknown quantity at this point
Question Counting a single character in a string

I have a list of a directory and need to process the files depending on the number of underscore characters in the file name. For example, the files
filename_date.txt

and

file_name_date.txt
will be processed differently by the script.

I've tried

$count = ($data =~ tr/_/_/);

but it doesn't seem to work - I continue to get a zero (0) for $count.

Is there a flaw in my logic above? Is there a better way to do this?

Thanks in advance!

Tom
__________________
My mind is like a steel whatchamacallit ...
tbohon is offline   Reply With Quote