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

Subroutines With Multiple Parameters

2010-03-25 Thread Pry, Jeffrey
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 as well. So I would like to call it as displayPage("servername","mypassword"); How

RE: Multiple Parameters

2004-07-27 Thread mafioso1823
Cool it works, thanks alot for your help. -Original Message- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Monday, July 26, 2004 9:04 PM To: [EMAIL PROTECTED] Cc: Perl Beginners Subject: Re: Multiple Parameters On Jul 26, 2004, at 6:29 PM, <[EMAIL PROTECTED]>

Re: Multiple Parameters

2004-07-26 Thread James Edward Gray II
On Jul 26, 2004, at 6:29 PM, <[EMAIL PROTECTED]> wrote: Thank you very much for your help, but i have one more question, is this the way that regex works or is it something in my code, every time i try to run the script to search for a comma and replace it with a new line character (\n) it just

RE: Multiple Parameters

2004-07-26 Thread mafioso1823
line character. -Original Message- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Monday, July 26, 2004 9:22 AM To: [EMAIL PROTECTED] Cc: Perl Beginners Subject: Re: Multiple Parameters (Let's keep our discussion on the list so all can help and learn.) On Jul 25, 2004,

Re: Multiple Parameters

2004-07-26 Thread James Edward Gray II
(Let's keep our discussion on the list so all can help and learn.) On Jul 25, 2004, at 8:09 PM, <[EMAIL PROTECTED]> wrote: OK i still can't figure this out, i understand what you explained but i still can't figure out why it doesn't want to write to the new file and also why it only removes the co

Re: Multiple Parameters

2004-07-25 Thread James Edward Gray II
at script.pl line 11, <> line 1. Why am i getting these errors, and how can i fix this? Thanks in advance. -Original Message- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Saturday, July 24, 2004 3:13 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Multip

RE: Multiple Parameters

2004-07-25 Thread mafioso1823
ch file or directory at script.pl line 11, <> line 1. Why am i getting these errors, and how can i fix this? Thanks in advance. -Original Message- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Saturday, July 24, 2004 3:13 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Su

Re: Multiple Parameters

2004-07-25 Thread JupiterHost.Net
[EMAIL PROTECTED] wrote: Hello, I am trying to write a search and replace script that can accept multiple arguments, but i want the first argument to be the filename to read, the next one to be the string to search for, the next one to be the replacement string, and the last one to be the name of

Re: Multiple Parameters

2004-07-24 Thread James Edward Gray II
On Jul 24, 2004, at 11:38 AM, <[EMAIL PROTECTED]> wrote: I am trying to write a search and replace script that can accept multiple arguments, but i want the first argument to be the filename to read, the next one to be the string to search for, the next one to be the replacement string, and the

Multiple Parameters

2004-07-24 Thread mafioso1823
I am trying to write a search and replace script that can accept multiple arguments, but i want the first argument to be the filename to read, the next one to be the string to search for, the next one to be the replacement string, and the last one to be the name of the new file it creates with the