--- "Charles K. Clarkson" <[EMAIL PROTECTED]>
wrote:
> Stuart White <[EMAIL PROTECTED]> wrote:
> : 
> : I'm having trouble returning a hash from a
> subroutine,
> : and an array from a different subroutine. 
> "Beginning
> : Perl" said I could return a list, I can't get it
> to
> : work.  Must the hash and array really be a
> reference
> : to the hash and array in order to return them?
> 
> 
>     Stuart, I think there is an easier way to
> approach
> your solution. Is there any situation in which a
> line
> needing to be parsed will contain a team that is
> /not/
> on your list of teams?
> 

No.  All teams are accounted for.

>     Can you give us all the big picture? Tell us
> what
> your project is and let us help you solve that
> instead
> of these small snippets. If you can, give us a
> sample
> of the input data (about 10 or 20 lines), tell us
> what
> you expect and how you have decided to get there.
> We'll
> be able to help you get there with perl.
> 

Ok, fair enough.  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.

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
(11:40) [SAN] Robinson Rebound (Off:0 Def:1)
(11:23) [SAN 2-0] Bowen Jump Shot: Made (2 PTS)
Assist: Parker (1 AST)
(11:10) [PHX] Marbury Jump Shot: Missed
(11:08) [PHX] Marion Rebound (Off:1 Def:0)
(11:07) [PHX] Marion Jump Shot: Missed
(11:05) [SAN] Robinson Rebound (Off:0 Def:2)
(10:51) [SAN 4-0] Jackson Jump Shot: Made (2 PTS)
Assist: Duncan (1 AST)
(10:32) [PHX] Marion Turnover: Bad Pass (1 TO)
(10:23) [SAN] Jackson Jump Shot: Missed Block:
Hardaway (1 BLK)
(10:20) [PHX] Stoudemire Rebound (Off:0 Def:1)
(10:18) [PHX] Stoudemire Turnover: Lost Ball (1 TO)
Steal: Jackson (1 ST)
(10:09) [SAN] Duncan Turnover: Bad Pass (1 TO)
(10:03) [PHX] Marbury Reverse Layup: Missed
(10:00) [SAN] Duncan Rebound (Off:0 Def:1)
(9:43) [SAN] Duncan Jump Shot: Missed Block:
Stoudemire (1 BLK)
(9:41) [SAN] Team Rebound
(9:33) [SAN] Duncan Layup Shot: Missed Block:
Stoudemire (2 BLK)
(9:31) [SAN] Duncan Rebound (Off:1 Def:1)
(9:31) [PHX] Williams Foul: Personal (1 PF)
------------

The big picture is creating a box score.  the
categories are points, offensive rebounds, defensive
rebounds, assists, steals, turnovers, field goals
attempted, field goals made, blocks and fouls.

>     I assume you are doing this at least partially
> as
> an exercise to learn perl and my intent is not to do
> the script for you, but a little more information
> would
> aid me not pushing you into the wrong direction.
> 

Yes, the goal is to learn perl, and to write a program
that is big enough to be challenging, interesting, and
uses most, if not all of the building blocks, (or at
least what I'd call building blocks: scalars, arrays,
hashes, reading files, control structures, regex,
subroutines, and references.  
Good, I'm not looking for anyone to write the program
for me, as that isn't too helpful in learning.  I just
need some help along the way.

I plan on getting to the end by writing small programs
that parse the lines for the different categories. 
Then, I plan on putting them all together, either as
includes into one main, or cutting and pasting them
into one file.  I expect to use a lot of regular
expressions to parse the files, and some hashes,
arrays, and perhaps a bit more complex data structures
like ArraysOfArrays, or HashesOfHashes, to store the
information.

Does that help?

__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com

-- 
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