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?
Here's my subroutine: 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); }
--------- And here's how I'm trying to capture the value:
@teams = ParseLineForHomeAndVisitors();
What values do you get in @teams (both in the function & as a return).
use Data::Dumper; print Dumper([EMAIL PROTECTED]);
----
I tried the same thing with my hash:
CreateAbbrevAndNicknamesHash();
my %hash = CreateAbbrevAndNicknamesHash(); use Data::Dumper; print Dumper(\%hash);
and here's the sub:
sub CreateAbbrevAndNicknamesHash() { my %AbbrevAndNicknames; %AbbrevAndNicknames = (
in place of the above two lines, you can just
return (
IND=> "Pacers", NJN=> "Nets", DET => "Pistons", NOH => "Hornets", #check this MIL => "Bucks", CLE => "Cavaliers", BOS => "Celtics", NYK => "Knicks", MIA => "Heat", PHI => "Sixers", TOR => "Raptors", ATL => "Hawks", WAS => "Wizards", ORL => "Magic", CHI => "Bulls", CHA => "Bobcats", SAC => "Kings", MIN => "Timberwolves", SAN => "Spurs", LAL => "Lakers", DAL => "Mavericks", MEM => "Grizzlies", HOU => "Rockets", DEN => "Nuggets", UTA => "Jazz", POR=> "Trail Blazers", SEA => "Supersonics", LAC => "Clippers", GSW => "Warriors", PHX => "Suns" ); }
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>