On Thursday 25 Mar 2010 16:04:01 Pry, Jeffrey wrote:
> That was exactly what I was looking for! Thank you so much!
> 
> - Jeffrey Kevin Pry
> 
> -----Original Message-----
> From: Gorrebeeck, Robert [mailto:gorrebeec...@cvty.com]
> Sent: Thursday, March 25, 2010 10:01 AM
> To: Pry, Jeffrey
> Subject: RE: Subroutines With Multiple Parameters
> 
> Jeffery
> 
> When you call your subroutine make sure you have the '&' in front of
> your subroutine name:
> 
> Like this
> 
>         &displayPage($servername, $password);
> 

&subroutine is not good advice:

http://www.perlfoundation.org/perl5/index.cgi?subroutines_called_with_the_ampersand

> In addition you can pass in as many parameters as you like (see above)
> 
> Within your subroutine to get the parameters out you would do this -
> declare another variable within your subroutine, (the variables you
> declare will only be active within your subroutine) Like this:
> 
> sub displayPage
> {
>         my ($a_server) = $_[0];
>         my ($a_pass) = $_[1];
> 
> }
> 

Don't use positional hard-coded indexes of @_ like that. What happens if you 
add a variable in between. Instead do either:

{{{
sub display_page
{
        my $a_server = shift;
        my $a_pass = shift;
        .
        .
        .
}
}}}

(shift is short for << shift(@_) >> )

Or:

{{{
sub display_page
{
        my ($a_server, $a_pass) = @_;
}
}}}


> Hope that helps
> 

Regards,

        Shlomi Fish

> Robert Gorrebeeck
> Sr. EDI Apps Dev Analyst
> Coventry Workers' Comp Services
> Solutions to Restore Health and Productivity
> Office: (972) 725-1484
> gorrebeec...@cvty.com
> www.coventrywcs.com
> 

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
List of Portability Libraries - http://shlom.in/port-libs

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to