[HRPM] Perl beginner looking for a little help

Collin Cusce cusce at jlab.org
Tue May 22 13:11:59 CDT 2001


    Ok, if you say so. I really am not sure that I follow your train of
thought on that...you could easily eliminate the older entries by comparing
the two files and grabing only the rows who's dates are greater than the max
date of your in your database and insert those automagically using
Perl::DBI.  I'm probably missing something, though, so sorry if I came
across as a know it all or something.
----- Original Message -----
From: "Jeff Self" <jocknerd at home.com>
To: <norfolk-pm-list at happyfunball.pm.org>
Sent: Tuesday, May 22, 2001 12:19 PM
Subject: Re: [HRPM] Perl beginner looking for a little help


> Thanks Collin. The reason I have the data in a flat file is because I
> don't create it myself. I do rankings for college football as well as NFL
> and there are about 700 college football teams in the country from the big
> guys all the way down to schools like Newport News Apprentice. So I would
> hate having to find scores for all these schools or entering them into a
> database. I download a file every week with all the scores up to that
> point. In a season, there are about 3500 college football games. Thats why
> I read from a file and not enter them into a database.
>
> I'll look over the code tonight and see if I can get it to work for me.
>
>
>
>  On Mon, 21 May 2001, Collin Cusce' wrote:
>
> >     Firstly, I would never store something this immense that is only
going
> > to grow more in a flat file. If you are willing to learn a bit about
> > databases (if you dont know it already) , you might want to consider
> > transfering your data into one and just run SQL queries on that.
Postgres is
> > my personal choice, but MySQL will do your needs nicely. Trust me, this
> > makes life a WHOLE lot easier and your data a whole lot less corruptable
> > (maybe that is just a false sense of security on my part, though). But I
> > digress.
> >     Unfortunatly, pretty much the full extent of Perl's data structures
has
> > been hacked together by Larry Wall as simple, quick fixes. There isnt
true
> > datatyping in perl ie: nothing like a 'struct' or a real 'class' (from
what
> > I understand Perl 6 will have this, though 8-). There is an example in
> > Advanced Perl Programming by O'Reilly that seems to be very similar to
the
> > problem you have. I'll include the source from the book and the data it
> > takes in below, but I'll address your problem, too.
> >     Ok, so you want to create a complex datastructure in Perl. Firstly,
you
> > need to create a sort of consrtuctor function that will alter a main
data
> > srtucutre based on the values you pass into it.You will need a main
> > datastrucutre, array or hash, that will contain all the data and then
you
> > build functions to navigate that datascructure.  This is a quick job I
threw
> > together in a few minutes which probably wont work to your needs and is
> > buggy, but hopefully it will give you the idea.
> >                 my(%games,%teams);
> >                 #parameters for enter_game passed in as follows:
> >                     #enter_game($date, \$teams{$vis_team},
> > \$teams{$home_team}, $vscore,$hscore,$ratio);
> >                 sub enter_game{
> >                    my($date, $visitors,$home,$vscore,$hscore,$ratio) =
@_;
> >                    %thisgame = {
> >                         'date' => $date,
> >                         #note, the next to values are references to the
> > teams, not a copy
> >                         'visitor' => $visitors,
> >                         'home' => $home,
> >                         'vis_score' => $vscore,
> >                         'home_score' => $hscore,
> >                         'ratio' => $ratio
> >                    };
> >                 $keyname = $visitor->$name."vs".$home->$name."on:"$date;
> >                 $games{$keyname} =  \$thisgame;
> >                 };
> >                 sub enter_team {
> >                     my($name,$won,$lost,$tied,$pf,$pa,$rating);
> >                     %team{$name} = {
> >                         'won' => $won,
> >                         'lost' => $lost,
> >                         'tied' => $tied,
> >                         'pf' => $pf,
> >                         'pa' => $pa,
> >                         'rating' => $rating
> >                     };
> >                 };
> > I hope that is what you are looking for. It most definetly has bugs in
> > it....sorry. Also, this might not be the best way to do this. I dont use
> > Perl nearly as much as I'd like to, and I'm responding mostly as a
refresher
> > for myself.
> >
> > I will try and attatch the example from Advanced Perl in hopes the
mailer
> > accepts attatchments. If not, I'll send out another post with the source
in
> > the text. I hope I helped!
> >
>
> --
> Hard Work Often Pays Off After Time, but Laziness Always Pays Off Now.
>
>




More information about the Norfolk-pm mailing list