(Let's keep our discussion on the list, for all to help and learn.)
On Aug 8, 2004, at 11:08 PM, William Paoli wrote:
The field format of the file is structured like this: "Car Number":"Driver Name":"Sponsor":"Owner":"Crew Chief":"Car Make":"Mini Biography":"Team Name"
I couldn't tell, are you struggling with this part?
Yes actually I think I am. Am I on the right track with:
sub load_data_file { open FILE, "winstoncup_2002_drivers.txt"; @driver_info = <FILE>;
This "slurps the entire file into the array. I assume that would be a lot of drivers. Don't you just want to walk through them one at a time? A typical line-by-line read in Perl looks something like:
while (my $line = <FILE) {
# work with $line here...
}
while (@driver_info) {
That says, "While there are elements in the array driver_info..." You aren't removing any elements below though, meaning it will always be true and thus probably an infinite loop. Again, I think you meant to deal with the file line-by-line.
$obj = $Car_Number, $Driver_Name,$Sponsor,$Owner,$Chief,$Car,$Bio,$Team = split /:/;
split /:/ is just short for split /:/, $_, but I don't see you setting $_ anywhere. I doubt that's doing what you expect.
The assignment is another issue. I don't know what you're trying with "$obj =", but I doubt you're getting what you expect there. As for the rest, use parens around your lists, so you can see they are lists:
($list, $of, $some, @vars) = split ... ;
Hopefully that gives you some new things to think about.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>