Re: shift vs @_

2012-05-21 Thread David Christensen
On 05/21/2012 08:37 PM, Steve Bertrand wrote: On 2012-05-21 21:10, David Christensen wrote: Therefore, performance is first and clarity is second. Would you not agree that these are pretty extreme cases to be making such a wide-reaching decision on? Please trim your replies. No, I don't thi

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
On 2012-05-21 21:10, David Christensen wrote: On 05/21/2012 12:40 PM, sono-io wrote: David, Are you saying that it would be faster to do: my $this_date = shift; my $output = shift; as opposed to: my ($this_date, $output) = @_; or am I not reading your assessment correctly? 1. Benchmarking on t

Re: shift vs @_

2012-05-21 Thread Rob Dixon
On 21/05/2012 21:12, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck. I'm curious as to why you say this. If one way is faster than another, wouldn't it be better to

Re: shift vs @_

2012-05-21 Thread David Christensen
On 05/21/2012 12:40 PM, sono-io wrote: David, Are you saying that it would be faster to do: my $this_date = shift; my $output = shift; as opposed to: my ($this_date, $output) = @_; or am I not reading your assessment correctly? 1. Benchmarking on the target (production)

Re: shift vs @_

2012-05-21 Thread sono-io
> For one thing, there is the "Lies, Damned Lies and Benchmarks" factor I must have missed the e-mail that said "DOG PILE!!!". =;) Thanks to everyone for the explanations - all good food for thought. That's why I'm here. Marc -- To unsubscribe, e-mail: beginners-unsubscr...@pe

Re: shift vs @_

2012-05-21 Thread Lawrence Statton
On 05/21/2012 03:12 PM, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck. I'm curious as to why you say this. If one way is faster than another, wouldn't it

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
On 2012-05-21 14:51, Shawn H Corey wrote: On 12-05-21 04:32 PM, Steve Bertrand wrote: On 2012-05-21 14:12, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck. I'm cur

Re: shift vs @_

2012-05-21 Thread Shawn H Corey
On 12-05-21 04:32 PM, Steve Bertrand wrote: On 2012-05-21 14:12, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck. I'm curious as to why you say this. If one way is

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
On 2012-05-21 14:12, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck. I'm curious as to why you say this. If one way is faster than another, wouldn't it be

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
On 2012-05-21 13:40, sono...@fannullone.us wrote: On May 20, 2012, at 10:07 PM, David Christensen wrote: I've updated function_arguments.pl with Benchmark, below. f_direct() is the fastest, f_shift() is in the middle (12% slower), and f_assign() is the slowest (37%). David, Are you

Re: shift vs @_

2012-05-21 Thread sono-io
Hi Paul, > Please don't care about this until your code is running correctly but > too slowly and profiling has determined that this is the bottleneck. I'm curious as to why you say this. If one way is faster than another, wouldn't it be better to do it that way, as long as it doesn't c

Re: shift vs @_

2012-05-21 Thread Paul Johnson
On Mon, May 21, 2012 at 12:40:15PM -0700, sono...@fannullone.us wrote: > On May 20, 2012, at 10:07 PM, David Christensen wrote: > > > I've updated function_arguments.pl with Benchmark, below. f_direct() is the > > fastest, f_shift() is in the middle (12% slower), and f_assign() is the > > slowes

Re: shift vs @_

2012-05-21 Thread sono-io
On May 20, 2012, at 10:07 PM, David Christensen wrote: > I've updated function_arguments.pl with Benchmark, below. f_direct() is the > fastest, f_shift() is in the middle (12% slower), and f_assign() is the > slowest (37%). David, Are you saying that it would be faster to do: my $this

Re: shift vs @_

2012-05-21 Thread Shawn H Corey
On 12-05-21 01:07 AM, David Christensen wrote: That's what I thought, until I started writing subroutines that modified @_ and stomped on the the caller's variables. Yes, that's what it does. That's why it's recommended to copy the values to my variables inside the subroutine. -- Just my 0.

Re: shift vs @_

2012-05-20 Thread David Christensen
On 05/20/2012 03:28 PM, Shawn H Corey wrote: On 12-05-20 06:15 PM, David Christensen wrote: If your subroutine needs to know how many arguments were passed, the former style (assignment) makes this trivial. Once @_ has been shifted (latter style), I don't know an easy way to determine if zero or

Re: shift vs @_

2012-05-20 Thread Shawn H Corey
On 12-05-20 06:15 PM, David Christensen wrote: If your subroutine needs to know how many arguments were passed, the former style (assignment) makes this trivial. Once @_ has been shifted (latter style), I don't know an easy way to determine if zero or one argument was passed (stack crawling?).

Re: shift vs @_

2012-05-20 Thread David Christensen
On 05/20/2012 08:09 AM, sono-io wrote: Are there any differences between these two idioms if only one or zero arguments are passed to them? my ($mode) = @_; my $mode = shift; If your subroutine needs to know how many arguments were passed, the former style (assignment) makes this tri

Re: shift vs @_

2012-05-20 Thread Rob Dixon
On 20/05/2012 16:16, John SJ Anderson wrote: On Sunday, May 20, 2012 at 11:09 AM, sono...@fannullone.us wrote: Are there any differences between these two idioms if only one or zero arguments are passed to them? my ($mode) = @_; my $mode = shift; If so, why would you chose one over the other

Re: shift vs @_

2012-05-20 Thread John SJ Anderson
On Sunday, May 20, 2012 at 11:09 AM, sono...@fannullone.us wrote: > Are there any differences between these two idioms if only one or zero > arguments are passed to them? > > my ($mode) = @_; > > my $mode = shift; > > If so, why would you chose one over the other? > > It seems to me that they

Re: shift oo

2011-03-24 Thread shawn wilson
On Thu, Mar 24, 2011 at 4:42 PM, Rob Dixon wrote: > > On 24/03/2011 02:39, Peter Scott wrote: >> >> On Tue, 22 Mar 2011 13:41:59 -0700, Randal L. Schwartz wrote: >> >>> "Peter" == Peter Scott  writes: my $s = Streamer->new; my $app = sub { return sub { $s->open_fh; my

Re: shift oo

2011-03-24 Thread Rob Dixon
On 24/03/2011 02:39, Peter Scott wrote: On Tue, 22 Mar 2011 13:41:59 -0700, Randal L. Schwartz wrote: "Peter" == Peter Scott writes: my $s = Streamer->new; my $app = sub { return sub { $s->open_fh; my $writer = shift->( [ 200, [ "Content-type" => "text/plain" ], $s ] ); }; }; Peter> As i

Re: shift oo

2011-03-23 Thread Peter Scott
On Tue, 22 Mar 2011 13:41:59 -0700, Randal L. Schwartz wrote: >> "Peter" == Peter Scott writes: > >>> my $s = Streamer->new; >>> my $app = sub { >>> return sub { >>> $s->open_fh; >>> my $writer = shift->( >>> [ 200, [ "Content-type" => "text/plain" ], $s ] ); >>> }; >>> }; > > Peter> As it

Re: shift oo

2011-03-23 Thread Brandon McCaig
On Fri, Mar 18, 2011 at 5:34 PM, shawn wilson wrote: > sorry, i don't know how to do any better in gmail (and does it different on > the gmail app on my android too - sorta messed up). should i color replies > differently or something? Quoting is typically done by prefixing each line of the quote

Re: shift oo

2011-03-23 Thread Brandon McCaig
You still seem a bit confused so lets try to start over straight to the point: On Fri, Mar 18, 2011 at 4:31 PM, shawn wilson wrote: > i ran across a peace of interesting code: > > my $writer = shift->( >  [ 200, [ "Content-type" => "text/plain" ], $s ] > ); To understand just this piece of code,

Re: shift oo

2011-03-22 Thread Uri Guttman
> "sw" == shawn wilson writes: sw> I learned a new way to use shift here (or probably any function sw> that uses $_) and I have (sorta learned about closures. you are doing it again. $_ and @_ have nothing to do with each other. and shift never touches $_. shift works on its array argume

Re: shift oo

2011-03-22 Thread shawn wilson
On Mar 22, 2011 4:43 PM, "Randal L. Schwartz" wrote: > > > "Peter" == Peter Scott writes: > > >> my $s = Streamer->new; > >> my $app = sub { > >> return sub { > >> $s->open_fh; > >> my $writer = shift->( > >> [ 200, [ "Content-type" => "text/plain" ], $s ] > >> ); > >> }; > >> }; > > Peter> A

Re: shift oo

2011-03-22 Thread Randal L. Schwartz
> "Peter" == Peter Scott writes: >> my $s = Streamer->new; >> my $app = sub { >> return sub { >> $s->open_fh; >> my $writer = shift->( >> [ 200, [ "Content-type" => "text/plain" ], $s ] >> ); >> }; >> }; Peter> As it stands, this doesn't make sense because nothing happens to $writer; Peter

Re: shift oo

2011-03-19 Thread Uri Guttman
> "sw" == shawn wilson writes: uri> please keep the various things clear. the original code you uri> posted (without the surrounding sub) was not OO, nor a closure, uri> nor an event handler. your original question was about shift->() uri> and only that. >> don't uri> keep wanderi

Re: shift oo

2011-03-19 Thread shawn wilson
On Sat, Mar 19, 2011 at 10:46 PM, Uri Guttman wrote: > > "sw" == shawn wilson writes: > > sw> thank you all. i have a much better grasp on what this means > sw> now. at least i know why i had trouble with it - i didn't (don't) > sw> understand closures. and, i am not used to event driven

Re: shift oo

2011-03-19 Thread Uri Guttman
> "sw" == shawn wilson writes: sw> thank you all. i have a much better grasp on what this means sw> now. at least i know why i had trouble with it - i didn't (don't) sw> understand closures. and, i am not used to event driven sw> programming. the example comes from psgi which (general

Re: shift oo

2011-03-19 Thread shawn wilson
thank you all. i have a much better grasp on what this means now. at least i know why i had trouble with it - i didn't (don't) understand closures. and, i am not used to event driven programming. the example comes from psgi which (generally) gets an event and gives you data. i've also been looking

Re: shift oo

2011-03-19 Thread Peter Scott
On Fri, 18 Mar 2011 17:34:00 -0400, shawn wilson wrote: > here's the whole function (i didn't think i needed to post it because i > get the rest of this code): Your problem is less to do with Perl than it is with explaining what you need clearly. Clear thinking and clear communication lead to cl

Re: shift oo

2011-03-18 Thread Uri Guttman
> "sw" == shawn wilson writes: sw> On Fri, Mar 18, 2011 at 7:02 PM, Shawn H Corey wrote: >> my sub_ref = shift @_; >> my $writer = $sub_ref->( >> [ 200, [ "Content-type" => "text/plain" ], $s ] >> ); sw> oh, that's right, i forgot the general oo use of: sw> my( $self, @etc )

Re: shift oo

2011-03-18 Thread shawn wilson
On Fri, Mar 18, 2011 at 7:02 PM, Shawn H Corey wrote: > On 11-03-18 06:41 PM, shawn wilson wrote: > >> an argument to what sub? >> (it's obvious that i've missed the boat on this concept) >> > > my $writer = shift->( >[ 200, [ "Content-type" => "text/plain" ], $s ] >); > > The

Re: shift oo

2011-03-18 Thread Shawn H Corey
On 11-03-18 06:41 PM, shawn wilson wrote: an argument to what sub? (it's obvious that i've missed the boat on this concept) my $writer = shift->( [ 200, [ "Content-type" => "text/plain" ], $s ] ); The array @_ contains a sub ref as its first argument. It is this sub that

Re: shift oo

2011-03-18 Thread shawn wilson
On Fri, Mar 18, 2011 at 6:36 PM, Shawn H Corey wrote: > On 11-03-18 06:21 PM, shawn wilson wrote: > >> my $a = Streamer->new; >> my $app = sub { >> return [ 200, [ "Content-type" => "text/plain" ], $a->open_fh ]; >> } >> >> ... i think, but a part of me is thinking that if it were that simple, i

Re: shift oo

2011-03-18 Thread Shawn H Corey
On 11-03-18 06:21 PM, shawn wilson wrote: my $a = Streamer->new; my $app = sub { return [ 200, [ "Content-type" => "text/plain" ], $a->open_fh ]; } ... i think, but a part of me is thinking that if it were that simple, it would have written like that (bad reasoning for thinking i'm wrong, but

Re: shift oo

2011-03-18 Thread shawn wilson
On Fri, Mar 18, 2011 at 6:21 PM, shawn wilson wrote: > > > On Fri, Mar 18, 2011 at 5:45 PM, Uri Guttman wrote: > >> > "sw" == shawn wilson writes: >> >> >> sw> On Fri, Mar 18, 2011 at 5:23 PM, Uri Guttman >> wrote: >> >> > "sw" == shawn wilson writes: >> >> > ok, taking another crac

Re: shift oo

2011-03-18 Thread shawn wilson
On Fri, Mar 18, 2011 at 5:45 PM, Uri Guttman wrote: > > "sw" == shawn wilson writes: > > > sw> On Fri, Mar 18, 2011 at 5:23 PM, Uri Guttman > wrote: > >> > "sw" == shawn wilson writes: > >> >> > >> >> so, what your saying is: > >> > sw> my $writer = sub { > sw> my $a = shift; >

Re: shift oo

2011-03-18 Thread Uri Guttman
> "sw" == shawn wilson writes: sw> On Fri, Mar 18, 2011 at 5:23 PM, Uri Guttman wrote: >> > "sw" == shawn wilson writes: >> >> please learn how to quote emails properly. it is hard to tell here what >> i replied and what you wrote. >> >> sorry, i don't know how to do any

Re: shift oo

2011-03-18 Thread shawn wilson
On Fri, Mar 18, 2011 at 5:23 PM, Uri Guttman wrote: > > "sw" == shawn wilson writes: > > please learn how to quote emails properly. it is hard to tell here what > i replied and what you wrote. > > sorry, i don't know how to do any better in gmail (and does it different on the gmail app on my

Re: shift oo

2011-03-18 Thread Uri Guttman
> "SHC" == Shawn H Corey writes: SHC> On 11-03-18 04:31 PM, shawn wilson wrote: >> my $writer = shift->( >> [ 200, [ "Content-type" => "text/plain" ], $s ] >> ); SHC> shift will shift @_ in a sub and @ARGV outside of one. So the first SHC> question is this inside a sub or not?

Re: shift oo

2011-03-18 Thread Shawn H Corey
On 11-03-18 05:05 PM, shawn wilson wrote: my $writer = sub { my $a = shift; return [ 200, [ "Content-type" => "text/plain" ], $s ]; } Try: $sub_ref = shift @_; my $writer = $subref->( [ 200, [ "Content-type" => "text/plain" ], $s ] ); The shift is shifting @_; it should be written as:

Re: shift oo

2011-03-18 Thread Uri Guttman
> "sw" == shawn wilson writes: please learn how to quote emails properly. it is hard to tell here what i replied and what you wrote. sw> On Fri, Mar 18, 2011 at 4:50 PM, Uri Guttman wrote: >> > "sw" == shawn wilson writes: >> sw> i ran across a peace of interesting code: sw

Re: shift oo

2011-03-18 Thread shawn wilson
On Fri, Mar 18, 2011 at 4:51 PM, Shawn H Corey wrote: > On 11-03-18 04:31 PM, shawn wilson wrote: > >> my $writer = shift->( >> [ 200, [ "Content-type" => "text/plain" ], $s ] >> ); >> > > shift will shift @_ in a sub and @ARGV outside of one. So the first > question is this inside a sub or not

Re: shift oo

2011-03-18 Thread shawn wilson
On Fri, Mar 18, 2011 at 4:50 PM, Uri Guttman wrote: > > "sw" == shawn wilson writes: > > sw> i ran across a peace of interesting code: > sw> my $writer = shift->( > sw> [ 200, [ "Content-type" => "text/plain" ], $s ] > sw> ); > > first off, there is no OO anywhere in that code. all it i

Re: shift oo

2011-03-18 Thread Shawn H Corey
On 11-03-18 04:31 PM, shawn wilson wrote: my $writer = shift->( [ 200, [ "Content-type" => "text/plain" ], $s ] ); shift will shift @_ in a sub and @ARGV outside of one. So the first question is this inside a sub or not? The first item in the array (@_ or @ARGV) has to be a reference to

Re: shift oo

2011-03-18 Thread Uri Guttman
> "sw" == shawn wilson writes: sw> i ran across a peace of interesting code: sw> my $writer = shift->( sw> [ 200, [ "Content-type" => "text/plain" ], $s ] sw> ); first off, there is no OO anywhere in that code. all it is is a dereference of a code reference passed in to a sub. sw

Re: Shift Question

2005-09-27 Thread Chris Devers
On Tue, 27 Sep 2005, Dave Adams wrote: > What is the purpose of the line "my $msg = shift;"? In the context of subroutines, it copies the first scalar argument passed to the routine to the variable $msg. If more than one argument was passed, the others aren't touched by this statement -- as yo

Re: Shift Question

2005-09-27 Thread John W. Krahn
Mulander wrote: > If I understood you question properly you want to know why people use > shift in subrutines and how does shift work. > > I will try to make it short: > shift works on lists, it removes the first element of the list perldoc -q "What is the difference between a list and an array"

Re: Shift Question

2005-09-27 Thread Wiggins d'Anconia
Mulander wrote: > If I understood you question properly you want to know why people use > shift in subrutines and how does shift work. > > I will try to make it short: > shift works on lists, it removes the first element of the list ( the 0 > indexed element ) and returns it as a lvalue ( if there

RE: Shift Question

2005-09-27 Thread Ryan Frantz
> -Original Message- > From: Ryan Frantz > Sent: Tuesday, September 27, 2005 5:27 PM > To: Dave Adams; beginners perl > Subject: RE: Shift Question > > > > > -Original Message- > > From: Dave Adams [mailto:[EMAIL PROTECTED] > > Sent:

RE: Shift Question

2005-09-27 Thread Ryan Frantz
> -Original Message- > From: Dave Adams [mailto:[EMAIL PROTECTED] > Sent: Tuesday, September 27, 2005 5:17 PM > To: beginners perl > Subject: Shift Question > > QUESTION: What is the purpose of the line "my $msg = shift;"? I am > guessing it is for the @_ array but what list element is

Re: shift what?

2005-04-13 Thread Randal L. Schwartz
> "Jesper" == Jesper Krogh <[EMAIL PROTECTED]> writes: >> $a=shift; >> . >> shift what? @_ ? Jesper> Yes Sometimes. shift defaults to @ARGV when outside a subroutine, and @_ when inside a subroutine, the argument being that those are both "arguments". :) -- Randal L. Schwartz - Stoneh

Re: shift what?

2005-04-13 Thread Owen Cook
On Wed, 13 Apr 2005 [EMAIL PROTECTED] wrote: > Hi all. > I always see like : > > $a=shift; > . > shift what? @_ ? > > And how dose it work? Try this example and see if you understand what is happening. --- #!/usr/bin/perl use strict; my @array=

Re: shift what?

2005-04-13 Thread Jesper Krogh
I gmane.comp.lang.perl.beginners, skrev [EMAIL PROTECTED]: > Hi all. > I always see like : > > $a=shift; > . > shift what? @_ ? Yes > And how dose it work? $ perldoc -f shift Jesper -- ./Jesper Krogh, [EMAIL PROTECTED], Jabber ID: [EMAIL PROTECTED] ... der er blevet medlem af

Re: shift question

2004-08-30 Thread John W. Krahn
[EMAIL PROTECTED] wrote: I found this in a template for creating subroutines, this is the base that is created when you use the template to create the subroutine. So now the newbie part, why would you place "my $par1 = shift;" in the subroutine template, and what does it do?? Basically I am trying

RE: shift question

2004-08-30 Thread Moon, John
Subject: RE: shift question [EMAIL PROTECTED] wrote: > Ok fantastic, I totally understand that, and if there were going to be > more than one thing passed, just insert $par2 = shift; on the next > line and then the second argument is in $par2, I assume.right?? Yes. You might al

RE: shift question

2004-08-30 Thread Wiggins d Anconia
> [EMAIL PROTECTED] wrote: > > Ok fantastic, I totally understand that, and if there were going to be > > more than one thing passed, just insert $par2 = shift; on the next > > line and then the second argument is in $par2, I assume.right?? > > Yes. > > You might also see it this way: > >

RE: shift question

2004-08-30 Thread Bob Showalter
[EMAIL PROTECTED] wrote: > Ok fantastic, I totally understand that, and if there were going to be > more than one thing passed, just insert $par2 = shift; on the next > line and then the second argument is in $par2, I assume.right?? Yes. You might also see it this way: my ($par1, $par2) =

RE: shift question

2004-08-30 Thread christopher . l . hood
please notify the sender immediately and delete the message. -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED] Sent: Monday, August 30, 2004 2:41 PM To: Christopher L. Hood; [EMAIL PROTECTED] Subject: RE: shift question [EMAIL PROTECTED] wrote: > OK here comes the new

RE: shift question

2004-08-30 Thread Bob Showalter
[EMAIL PROTECTED] wrote: > OK here comes the newbie question. > > I found this in a template for creating subroutines, this is the base > that is created when you use the template to create the subroutine. > > So now the newbie part, why would you place "my $par1 = shift;" in > the subroutine te

RE: shift, push, hash references, array references

2004-04-30 Thread Charles K. Clarkson
William Martell <[EMAIL PROTECTED]> wrote: : : I have a question about this procedure. I am trying : to extract these 12 values of text from a text file. : I am trying to get my first two hash values and this : is the procedure that handles that. Thanks Charles : for all your help and mentoring.

Re: Shift

2002-07-16 Thread Ian Harisay
THat depends on the context of its use. in a subroutine this would take the first element from @_. >>> "Adriano Sastre Vieira" <[EMAIL PROTECTED]> 07/16/02 10:54AM >>> What does the following instruction means? That is, when my variable receives shift, what is it? my $MENUI = shift; Thanks

Re: Shift

2002-07-16 Thread Jeff 'japhy' Pinyan
On Jul 16, Adriano Sastre Vieira said: >What does the following instruction means? That is, when my variable >receives shift, what is it? > > my $MENUI = shift; shift() is explained here: perldoc -f shift shift() with no args either looks at @_ (if you're in a subroutine) or @ARGV (if you a

RE: Shift

2002-07-16 Thread Timothy Johnson
It means that your script is removing the first element from the @_ array and assigning it to your variable. Usually you will see this at the beginning of a subroutine when variables have been passed to it, since all variablesa passed to a sub are put into the @_ array. -Original Message---

RE: Shift

2002-07-16 Thread Daryl J. Hoyt
It returns the first value of an array and then increments the index. Daryl J. Hoyt Software Engineer Geodesic Systems 312-832-2010 < http://www.geodesic.com> < mailto:[EMAIL PROTECTED]> -Original Message- From: Adriano Sastre Vieira [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 16,

Re: Shift

2002-07-16 Thread Michael A Chase
On Tue, 16 Jul 2002 13:54:14 -0300 Adriano Sastre Vieira <[EMAIL PROTECTED]> wrote: > What does the following instruction means? That is, when my variable > receives shift, what is it? > > my $MENUI = shift; It's in the fine manual: perldoc -f shift -- Mac :}) ** I normally forward privat

RE: shift inside of for loop

2002-02-21 Thread Mark Anderson
I inserted a print statement into your code that may help you understand what's happening: my @ary = (0..1000); for (@ary) { if($_ <= 1000) { print; shift @ary; } } print scalar @ary, "\n"; ## my comments: the for

Re: Shift question...

2001-12-21 Thread Michael R. Wolf
Wim De Hul <[EMAIL PROTECTED]> writes: > my $var = shift; > > I thought that shift puts a variable in an array? What does this mean? Did you check the documentation on "shift" *before* posting the question? >From "Programming Perl": 3.2.143 shift shift ARRAY shift This fu

RE: Shift question...

2001-12-20 Thread Bob Showalter
> -Original Message- > From: Wim De Hul [mailto:[EMAIL PROTECTED]] > Sent: Thursday, December 20, 2001 10:48 AM > To: [EMAIL PROTECTED] > Subject: Shift question... > > > Hello guys ( and girls), > > While I was reading a script, I saw the lines: > > my $var = shift; > > I thought tha

Re: Shift question...

2001-12-20 Thread Michael Stidham
The way I understand it Shift removes the first element of the list and moves (or "shifts") every remaining element of the list to the left to cover the gap. Shift then returns the removed element.ex:) @list = qw(1,2,3); $fisrtval = shift(@list); Hope this helped...Stiddy >From: Wim De Hul

RE: Shift question...

2001-12-20 Thread John Edwards
shift returns the first value of the array. When no array is defined it operates on the default array @_ You will most likely see the line you mention as the first line of a subroutine. E.g &call_sub('John'); sub call_sub { my $name = shift; print "Name is $name\n"; } What's ha

RE: Shift and "=>"

2001-12-18 Thread Bob Showalter
> -Original Message- > From: Michael R. Wolf [mailto:[EMAIL PROTECTED]] > Sent: Monday, December 17, 2001 10:27 PM > To: [EMAIL PROTECTED] > Subject: Re: Shift and "=>" > > => is the stringifying-coma it's just like a coma, but it > force

Re: Shift and "=>"

2001-12-17 Thread Michael R. Wolf
"Lorne Easton" <[EMAIL PROTECTED]> writes: > I don't understand this line.. > > $session = Net::SNMP->session(-hostname => "10.0.0.100", -community => > "public"); I'd align it differently for readability: $session = Net::SNMP->session(-hostname => "10.0.0.100",

Re: Shift and "=>"

2001-12-17 Thread Frank
On Mon, Dec 17, 2001 at 11:36:30AM +1000, Lorne wrote: > I don't understand this line.. > > $session = Net::SNMP->session(-hostname => "10.0.0.100", -community => > "public"); The parameters are a hash: -hostname=>'10.0.0.100' is the same as: '-hostname','10.0.0.100'... so you could pass: $ses

RE: Shift and "=>"

2001-12-17 Thread Lorne Easton
Hi, Below is some example code that I have butchered to it's simplest impelmentation. I don't understand this line.. $session = Net::SNMP->session(-hostname => "10.0.0.100", -community => "public"); Particularly, the way data is presented to the function.. I.E : -data => "text" Is this some

Re: shift on an array of arrays

2001-10-30 Thread Andrea Holstein
Will Muir wrote: > I have an array of arrays @data that > I would like to take the reference of the 5th element of the first 3 elements and > put them into another array and then shorten @data by 3. > I hope that this makes sense, I am new to this and > don't really know a better way too expl

Re: shift on an array of arrays

2001-10-29 Thread Jeff 'japhy' Pinyan
On Oct 29, Will Muir said: >I have an array of arrays @data that I would like to take the reference >of the 5th element of the first 3 elements and put them into another >array and then shorten @data by 3. I hope that this makes sense, I am >new to this and don't really know a better way too exp