RE: Subroutines With Multiple Parameters

2010-03-26 Thread Bob McConnell
From: Shlomi Fish [mailto:shlo...@iglu.org.il] > On Friday 26 Mar 2010 18:39:30 Shawn H Corey wrote: >> It's nice to be brief but only providing it does interfere with >> understanding. Remember: Hard to understand code is costly to >> maintain code. > > I don't believe in programming in an id

Re: Subroutines With Multiple Parameters

2010-03-26 Thread Shlomi Fish
Hi Shawn, On Friday 26 Mar 2010 18:39:30 Shawn H Corey wrote: > On Fri, 26 Mar 2010 16:06:04 +0300 > > Shlomi Fish wrote: > > One thing hackers like is brevity. > > I got a better idea. Let's assume that the person who maintains your > code is a recent graduate that doesn't have any experience

Re: Subroutines With Multiple Parameters

2010-03-26 Thread Shawn H Corey
On Fri, 26 Mar 2010 16:06:04 +0300 Shlomi Fish wrote: > One thing hackers like is brevity. I got a better idea. Let's assume that the person who maintains your code is a recent graduate that doesn't have any experience with Perl. How would he know that shift does two different things? It's nic

Re: Subroutines With Multiple Parameters

2010-03-26 Thread Shlomi Fish
Hi Shawn! On Thursday 25 Mar 2010 20:38:59 Shawn H Corey wrote: > On Thu, 25 Mar 2010 19:54:48 +0200 > > Shlomi Fish wrote: > > Well, this is a bike shed argument. I find using "shift;" instead of > > "shift(@_);" when inside subroutines to be faster to write, more > > concise and more idiomatic

Re: Subroutines With Multiple Parameters

2010-03-25 Thread Shawn H Corey
On Thu, 25 Mar 2010 19:54:48 +0200 Shlomi Fish wrote: > Well, this is a bike shed argument. I find using "shift;" instead of > "shift(@_);" when inside subroutines to be faster to write, more > concise and more idiomatic. shift has this magic for a reason. I'm > unlikely to use shift the other wa

Re: Subroutines With Multiple Parameters

2010-03-25 Thread Shlomi Fish
On Thursday 25 Mar 2010 18:52:09 Shawn H Corey wrote: > On Thu, 25 Mar 2010 17:13:53 +0200 > > Shlomi Fish wrote: > > sub display_page > > { > > > > my $a_server = shift; > > my $a_pass = shift; > > . > > . > > . > > > > } > > }}} > > > > (shift is short for << shift(@_) >>

Re: Subroutines With Multiple Parameters

2010-03-25 Thread Shawn H Corey
On Thu, 25 Mar 2010 17:13:53 +0200 Shlomi Fish wrote: > sub display_page > { > my $a_server = shift; > my $a_pass = shift; > . > . > . > } > }}} > > (shift is short for << shift(@_) >> ) If you're going to use shift, name the array. my $var; sub foo { $var = shi

Re: Subroutines With Multiple Parameters

2010-03-25 Thread Shlomi Fish
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);

Re: Subroutines With Multiple Parameters

2010-03-25 Thread Damon Allen Davison
On Thu, Mar 25, 2010 at 1:54 PM, Pry, Jeffrey wrote: > sub displayPage($) { > >my($server) = shift; >print $server; > } > Hi, I'd repeat the advice about staying away from prototypes, i.e. the '($)' business after your subroutine name. Perl is very good at figuring out wh

Re: Subroutines With Multiple Parameters

2010-03-25 Thread Shawn H Corey
On Thu, 25 Mar 2010 09:54:13 -0400 "Pry, Jeffrey" wrote: > Hey, > > I have a subroutine > > sub displayPage($) { > > my($server) = shift; > print $server; > } > > Which I can call using displayPage("servername"); > > My question is lets say I wanted to pass a password

RE: Subroutines With Multiple Parameters

2010-03-25 Thread Pry, Jeffrey
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