phantom20x has asked for the wisdom of the Perl Monks concerning the following question:
I was writing code for an assignment(already turned in), and a portion of it looked like below(ugly I know). The question is in regards to upon leaving the while loop, I could no longer access the arrays in their entirety. Only one element was left. Before leaving the while loop, all the elements were there in each array and accounted for. This seemed like a noob scoping problem but I couldn't seem to find any info on it, so I am asking the wise. Thanks in advance.
while(<>){ @coursename=split(/(\w+),\s\w+,\s\w+,\s\w+,\s\w+,\s\w+/); @building=split(/\w+,\s(\w+),\s\w+,\s\w+,\s\w+,\s\w+/); @room=split(/\w+,\s\w+,\s(\w+),\s\w+,\s\w+,\s\w+/); @day=split(/\w+,\s\w+,\s\w+,\s(\w+),\s\w+,\s\w+/); @time=split(/\w+,\s\w+,\s\w+,\s\w+,\s(\w+),\s\w+/); @name=split(/\w+,\s\w+,\s\w+,\s\w+,\s\w+,\s(\w+)/); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array Scopes?
by cdarke (Prior) on Nov 26, 2009 at 10:12 UTC | |
|
Re: Array Scopes?
by bichonfrise74 (Vicar) on Nov 26, 2009 at 06:17 UTC | |
|
Re: Array Scopes?
by 7stud (Deacon) on Nov 26, 2009 at 07:56 UTC | |
|
Re: Array Scopes?
by mykl (Monk) on Nov 26, 2009 at 12:48 UTC | |
by phantom20x (Acolyte) on Nov 30, 2009 at 02:56 UTC |