Stuart White <[EMAIL PROTECTED]> wrote:
: 
: I figured the small snippets, how to 
: print an array, how to split a string etc., was
: better as it was more focused, and would apply
: to not just the one example.

    That's a great way to break the program down, but
over the years I have found that many beginners are
asking the wrong question. Supplying a good answer
to the wrong question doesn't usually help much. With
just a bit more information, I can tell whether the
question is the right one and whether I should invest
my time in it or not.

    For example, here's your parsing sub:

sub ParseLineForHomeAndVisitors()
{
 if ($_
=~/Spurs|Suns|Mavericks|Lakers|Clippers|Cavaliers|Celtics|
Pacers|Pistons|Wizards|Warriors|Bulls|Hawks|Raptors|Magic|
Heat|Kings|Rockets|Nuggets|Grizzlies|Jazz|Knicks|Nets|
Supersonics|'Trail Blazers'|Bucks|Timberwolves|Hornets|
Sixers|Bobcats)/)
 {
  @teams = /([[:alpha:]]+)/g;
 }
 return (@teams);
}

    The 'if' statement is doing 3 suspicious things. One,
it is capturing the match. Two, I suspect 'Trail Blazers'
in single quotes will never be found. And it is not
obvious what happens if there is no match. It looks like
@teams is a global variable, but since that is a Bad
Thing, I would hope you weren't using it.

    More importantly, (IMO) the sub probably shouldn't be
doing the line validation. That should be done to determine
if this sub should be called. I could write a nice long
answer about this sub, but I'd probably be answering the
wrong question.


: Here's 25 lines of sample input:
: ------------------
: Spurs 94, Suns 82 
: 4/29/2003 SBC Center, San Antonio, TX 
: Officials: #16 Ted Bernhardt , #33 Sean Corbin , #15
: Bennett Salvatore
: 1st Period
: (12:00) Jump Ball Robinson vs Williams
: (11:41) [PHX] Marion Turnaround Jump: Missed
[snip]
: ------------

    Thanks. Is each input example like this.? Is there
a chance that a second line like "Spurs 94, Suns 82"
will show up? Or will it be in a different dataset
(file, recordset, etc.)?

    The reason I ask Is that there is probably a better
way to pick this line out of the file than that it
contains team names. For example, it seems to be the
only line that will match /[[:alpha:]]+\s+[[:digit:]]+,/.
It also seems to be the first line. Is it always the
first line?

my $first_line = <DATA>;
my @teams = $first_line =~ /([[:alpha:]]+)/g;


    As I progress with my own skills I find that
programming is just manipulating of one form of data to
another form. I haven't really learned more about perl
in the last year, I've learned more about pattern
recognition and how to apply it to the data coming in
and leaving my scripts.

    I have also find that the better idea of what
the output should be, the easier (and faster) I can
create the solution.


: The big picture is creating a box score.

    I have no idea what a box score is. I am sports
deficient and only know this is basketball because
of the categories you mention.


: the categories are points, offensive rebounds,
: defensive rebounds, assists, steals, turnovers,
: field goals attempted, field goals made, blocks
: and fouls.

    There are "field goals" in basketball?!?


: Does that help?

    Yes.

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to