[Za-pm] Script

Nico Coetzee nico at itfirms.co.za
Thu Jun 5 12:32:32 CDT 2003


Ahh - I think I misunderstood the original question. In stead of:

$usercounter{ $email } = $usercounter{ $email } + $counter;

Just do:

$usercounter{ $email }++;

You also want to store the e-mails, rather then the names, so comment out:

if ( not $usernames{ $email } ) { $usernames{ $email } = $user; }

And change:

if ( $name ) { print "$name = $count\n"; }
else { print "unknown = $count\n"; }

to read:

print "$key=$count\n";

I will have something on variables in the comming article. If I get around to 
do it, it might be up by the end of the weekend.


Cheers

On Thursday 05 June 2003 08:36, Bartho Saaiman wrote:
> Hi Nico
>
> I have cut some of your reply to make sure that this mail does not get
> to long.
>
> About your assumption: I have various forms of the name and might have
> more than one particuliar email. At this stage I am not really
> interested in a name, more in the email address. If I use your script in
> its current form, it seems to be adding the total for characters sent.
> What I want to establish is adding up the number of emails sent.
>
> Where can I find more on hash, as I can not seem to find anything on the
> use of this. Maybe it is time for coffee :)
>
> Nico Coetzee wrote:
> > On Wednesday 04 June 2003 08:33, Bartho Saaiman wrote:
> >
> > Just some notes of my own - it was probably mentioned in some of the
> > other mails, but I might have mist it.
> >
> > We assume you have various forms of the name, but one particular e-mail.
> > When ever you use regular expressions or other means, remember to first
> > convert all ASCII text to the same case (or at least ignore case). What
> > we can also do, is just use th first instance of the real name, and
> > ignore the rest ( if we want a name ). Also remember to do away with all
> > punctuations.
> >
> > Given the above example, here is a simple script:
> > Sample Run:
> > [Mon May 26 15:16:00 SAST 2003] SMS  Soe User <user at domain.co.za> sent
> > 142 characters to 271234567891
> > [Sat May 24 12:51:37 SAST 2003] SMS  "Another User" <user2 at domain.co.za>
> > sent 151 characters to 271234567891
> > [Fri May 23 18:16:02 SAST 2003] SMS  <user3 at domain.co.za> sent 150
> > characters to 271234567891
> > <output>
> > $ cat test.txt | perl test.pl
> > unknown = 150
> > Another User = 151
> > Some User = 486
> > </output>
> >
> > NOTE: You should be aware that the data in a hash is not sorted - there
> > is a way to do it, so just shout if you need it. Also note, that although
> > the last instance of "Some User", the actual name is misspelled, it will
> > still take only the first name it finds for that e-mail. For e-mails that
> > have NO known name, we simply use 'unknown', but they will still be
> > uniquely grouped, as we matched per e-mail.
> >
> > Cheers

-- 
Nico Coetzee

http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/

To the systems programmer, users and applications serve only to provide a
test load.




More information about the Za-pm mailing list