Helping with split - helping with split

They have: 109 posts

Joined: Apr 1999

Check the following

open(variables,"<variables.txt"); #open .txt with important variables
$line=<variables>;
close(variables);
chop($line);
($totalhits,$totaluniquehits,@uniquehits,%browsers,%referdom)=split(/:/,$line);
close(variables);

Now, Can I actually store the arrays and assoc arrays in the .txt file? if now, is there another way to keep the data in the arrays?

They have: 178 posts

Joined: Sep 1999

Try this:

open(FILE,"file.txt");
@filedata = <FILE>;
close(FILE);

($totalhits,$totaluniquehits,$uniquehits,$browsers,$referdom)=split(/:/,@filedata[0]);

Without seeing the rest of the code, I can't really tell what you are trying to do.

----------
Webmaster Resources - directory.indexfinger.com
Index Finger - indexfinger.com

They have: 178 posts

Joined: Sep 1999

I think we should have an option to turn the smiles off.

They have: 109 posts

Joined: Apr 1999

OK. So far there is not too much code, but I have begun creating a Site Statistics program.

As for the split stuff.
$totalhits------Total # of hits

$totaluniquehits-Totl # of Unique

@uniquehits-contains an array of visitors REMOTE_HOST

%browsers-an associative array of types of browsers as the keys, with values of how many people have used that browser

%referdom -An associative array of where visitors came form, and how many visitors came from there as the value.

Now, can all of this info be stored/used in the CGI program? or how else can I do this?

They have: 5,633 posts

Joined: Jan 1970

dass, let me ask a simple question: why do you want to use associative arrays at all???
if you store information like this:
file 1 = counting hits. as I interpreted your variable names, you will just need to get one number for totalhist, one for the each site the user came from.....
file 2= used browsers

you'll have no problem anymore, do you?

if this doesn't help or I misunderstood something, please tell me what kind of data you'll need for your statistics and we sure can help you more... Wink

cu
patrick

They have: 178 posts

Joined: Sep 1999

I think you should store everything in 5 files, once for each.

----------
Webmaster Resources - directory.indexfinger.com
Index Finger - indexfinger.com

They have: 109 posts

Joined: Apr 1999

I am using associative arrays because, I want the stats program to get how many people use a browser, and how many people came from the same http_refer

for example.

browsers, if the certain type of browser the visitor is not using isnt in the %associative array, than that KEY will be placed in it with a VALUE of 1. If a visitor comes using IE4, and IE4 is already in the array, than

than 1 will be added to the value for IE4.

Understand or no?

They have: 5,633 posts

Joined: Jan 1970

My dirty trick for this problem is to use Perl to generate Perl source code that defines the associative array. You print that code in a file and you can simply require it to get the info.

----------
Malte Ubl - Germany
http://goKewl.com/

They have: 109 posts

Joined: Apr 1999

The main problem is how will I collect all the values and keys inside the %associative arrays when im calling up the .txt and getting all the data?

They have: 109 posts

Joined: Apr 1999

Thanks!
Should have thought of that!

How would I open it though? or would it open "prepared"?

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.