aatrox has asked for the wisdom of the Perl Monks concerning the following question:
Subroutine parameters problem
Hello i was trying to make subroutine to print names of people to have less of writting but this doesnt work and i dont know which parameters i should use i was trying everything which come to my brain. If somebody can look at it and tell me what parameters should be inside function i would be thankful. Here is codeelsif($winners eq "denmark\n") { print "Denmark - people at competition:\n"; foreach $guest(@people) { if(length($guest->{'id'}) == 15 && $guest->{'id'} =~ /^20[ +0-5]|^26|^28/) { &write(#dont know what parameters should give) } } } # My function sub write { print "$guest->{'surname'} "; print "$guest->{'name'}"; print ":$guest->{'id'}\n"; } If i do it like this it works without problem elsif($winners eq "denmark\n") { print "Denmark - people at competition:\n"; foreach $guest(@people) { if(length($guest->{'id'}) == 15 && $guest->{'id'} =~ /^20[ +0-5]|^26|^28/) { print "$guest->{'surname'} "; print "$guest->{'name'}"; print ":$guest->{'id'}\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with parameters in subroutines
by choroba (Cardinal) on Jun 02, 2014 at 12:15 UTC | |
by aatrox (Initiate) on Jun 02, 2014 at 12:24 UTC | |
by aatrox (Initiate) on Jun 02, 2014 at 12:30 UTC | |
|
Re: Problem with parameters in subroutines
by smls (Friar) on Jun 02, 2014 at 12:32 UTC | |
by aatrox (Initiate) on Jun 02, 2014 at 14:05 UTC | |
by smls (Friar) on Jun 02, 2014 at 14:30 UTC | |
by taint (Chaplain) on Jun 02, 2014 at 14:46 UTC | |
|
Re: Problem with parameters in subroutines
by LanX (Saint) on Jun 02, 2014 at 12:11 UTC | |
by aatrox (Initiate) on Jun 02, 2014 at 12:21 UTC | |
by LanX (Saint) on Jun 02, 2014 at 12:30 UTC |