Hi I use a very basic program to maintain a database of the songs I have on my site at http://www.tlclive.com. I am trying to add a counter, so the script displays the total number of songs in the archive. I took the little knowledge I have and tried to apply it and I changed: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

open(FILE, "$datafile"); { local $/; $cnter1 = <FILE>; } close(FILE); </pre><HR></BLOCKQUOTE> and saved it to a variable ($cnter1) Then I used the split to break apart that file (now stored in $cnter1): <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

@line = split(/\n/,$cnter1); foreach $line (@line) { $cnter = $cnter + 1; } </pre><HR></BLOCKQUOTE> It works! Magically delicous. If you wanna see the simple thing I was trying to do go to http://www.tlclive.com/newsite/sounds.shtml

I always find that to be an enlightening and gratifying thing to do, and hopefully you did too, but I do have some pointers ...

$cnter = $cnter + 1; can be abbreviated to $cnter += 1; or -- even more succinctly -- $cnter++;.

Second, there's no need to read in the entire file for counting purposes. It's a waste of resources for starters and there are better ways including making use of the special variable $. ( dollar-period ) which tells you the current line number ...

Hey thanks! Im still learning here. I knew there was an abbreviated way but I wasnt sure exactly how. Now Im working on a similar case but a bit more complicated. The same page has a search option but the search is sent to another script (for visual reasons). Either way, I would like a way to count the number of searches, and its jut BOGGLING my mind!. No matter where I put the counter code it is either 0 or non existant. If anyone wants to take a look I can email the script to you but I dont want to post the entire thing to the board Its a little lengthy for a post.