Re: Switch, Ranges and Memory

2006-08-29 Thread John W. Krahn
Barron Snyder (CE CEN) wrote: > When using the range operator, is the list actually created with all the > elements? It depends. :-) In general, yes it does. See the "Range Operators" section of perlop: perldoc perlop > For example, if I create a list like (123..456754), does it take up the

Re: Switch, Ranges and Memory

2006-08-29 Thread Tom Phoenix
On 8/29/06, Barron Snyder (CE CEN) <[EMAIL PROTECTED]> wrote: For example, if I create a list like (123..456754), does it take up the same amount of memory as if I actually entered all those in between numbers? Generally, yes. I'm asking because I want to use ranges in a switch statement and

RE: Switch -- confused

2005-04-13 Thread David Gilden
Greetings, Thanks for the help so far, I am added switch... but not sure that I have syntax correct Maybe this is best written as if else logic and or: my $action = $q->param( "action" ); SWITCH ($action) { if (/Upload/) { last SWITCH; }; etc... -

Re: switch statement

2004-02-19 Thread WilliamGunther
I just benchmarked Filter, and it was worse than 100 times slower In a message dated 2/19/2004 6:53:56 PM Eastern Standard Time, [EMAIL PROTECTED] writes: last time i benchmark a source filter, it's about 100 times slower. has that change since v5.8? -Will ---

Re: switch statement

2004-02-19 Thread John W. Krahn
Anthony Vanelverdinghe wrote: > > Hi Hello, > Could anyone please tell me what's wrong with the following "program"? > The compiler gives errors in the switch statement. > > %commands=('v',0,'w',1,'t',2,'/pattern/',3,'s',4,'x',5); > $end = 0; > while (!end){ > print "bookmarks.html>"; > $operat

Re: switch statement

2004-02-19 Thread david
Rob Dixon wrote: > <[EMAIL PROTECTED]> wrote: >> >> The Advantage is you get to use the switch statement. The disadvantage is >> your code will run extraordinarily slow because the Switch module uses a >> run time Filter. In short: isn't an is-elsif-else statement enough?? > > Are you saying that

Re: switch statement

2004-02-19 Thread James Edward Gray II
On Feb 19, 2004, at 5:21 PM, Paul Johnson wrote: The problem is that Switch.pm is a source filter, which is effectively an extra level of processing before compilation. Personally, I wouldn't use a source filter for anything I cared about. The docs for Switch state: There are undoubtedly serio

Re: switch statement

2004-02-19 Thread Paul Johnson
On Thu, Feb 19, 2004 at 10:46:33PM -, Rob Dixon wrote: > <[EMAIL PROTECTED]> wrote: > > > > The Advantage is you get to use the switch statement. The disadvantage is > > your code will run extraordinarily slow because the Switch module uses a run time > > Filter. In short: isn't an is-elsif-els

Re: switch statement

2004-02-19 Thread WilliamGunther
This: if ($op == 0) {} elsif ($op == 1) {} elsif ($op == 2) {} elsif ($op == 3) {} elsif ($op == 4) {} elsif ($op == 5) {} is faster than this: use Switch; switch ($op) { case 0 { last } case 1 { last } case 2 { last } case 3 { last } case 4 { last } case 5 { last } } B

Re: switch statement

2004-02-19 Thread Rob Dixon
<[EMAIL PROTECTED]> wrote: > > The Advantage is you get to use the switch statement. The disadvantage is > your code will run extraordinarily slow because the Switch module uses a run time > Filter. In short: isn't an is-elsif-else statement enough?? Are you saying that 'if-elsif-else' is a compil

Re: switch statement

2004-02-19 Thread u235sentinel
In addition, I've been playing around with the 'use diagnostics' feature in perl. That's in addition to 'use warnings'. I don't recommend it for regular coding but when stumped it may help. > On Feb 19, 2004, at 3:14 PM, Anthony Vanelverdinghe wrote: > > > Hi > > Howdy. > > > Could anyone

Re: switch statement

2004-02-19 Thread WilliamGunther
The Advantage is you get to use the switch statement. The disadvantage is your code will run extraordinarily slow because the Switch module uses a run time Filter. In short: isn't an is-elsif-else statement enough?? In a message dated 2/19/2004 4:40:56 PM Eastern Standard Time, [EMAIL PROTECTED]

Re: switch statement

2004-02-19 Thread Daniel Staal
--As of Thursday, February 19, 2004 10:29 PM +0100, Anthony Vanelverdinghe is alleged to have said: Didn't know it wasn't in Perl, but I've just discovered it's possible with some file called "Switch.pm" --As for the rest, it is mine. You mean the 'Switch' module. (Sorry, I should have mentione

Re: switch statement

2004-02-19 Thread James Edward Gray II
On Feb 19, 2004, at 3:14 PM, Anthony Vanelverdinghe wrote: Hi Howdy. Could anyone please tell me what's wrong with the following "program"? I'll try. The compiler gives errors in the switch statement. Perl doesn't have a native switch statement, but it is included as a module in 5.8+ Thx!! An

Re: switch statement

2004-02-19 Thread Anthony Vanelverdinghe
Didn't know it wasn't in Perl, but I've just discovered it's possible with some file called "Switch.pm" From: Daniel Staal <[EMAIL PROTECTED]> Reply-To: Perl Beginners <[EMAIL PROTECTED]> To: Perl Beginners <[EMAIL PROTECTED]> Subject: Re: switch

Re: switch statement

2004-02-19 Thread Daniel Staal
--As of Thursday, February 19, 2004 10:14 PM +0100, Anthony Vanelverdinghe is alleged to have said: Could anyone please tell me what's wrong with the following "program"? The compiler gives errors in the switch statement. --As for the rest, it is mine. You mean, besides the fact that Perl doesn'

Re: switch user

2003-06-16 Thread Ahmed Moustafa
Steve Grazzini wrote: Ahmed Moustafa <[EMAIL PROTECTED]> wrote: [ That address is bouncing, by the way. ] It should not! What was the message that you got? How can I switch user "su" in perl? It's much easier to do that before running the script. :-) $ su -c ./script.pl And then once you'

Re: switch user

2003-06-16 Thread Steve Grazzini
Ahmed Moustafa <[EMAIL PROTECTED]> wrote: [ That address is bouncing, by the way. ] > How can I switch user "su" in perl? It's much easier to do that before running the script. :-) $ su -c ./script.pl And then once you're root, you can change the real and effective user ids with the magic $

Re: switch

2002-10-13 Thread Mark Goland
t;>) ; last; } } print " $P_length is the value \n"; _exit 0; # take this out once fixed print PW_FH "p $P_num $P_type $P_start $P_lenght"; close PW_FH; _exit 0; Thanx in advance, Mark - Original Message - From: "Hanson, Rob" <[EMAIL PROTECTED]&

RE: switch

2002-10-13 Thread nkuipers
0; # take this out once fixed > >print PW_FH "p $P_num $P_type $P_start $P_lenght"; > >close PW_FH; > >_exit 0; > >Thanx in advance, > Mark >- Original Message - >From: "Hanson, Rob" <[EMAIL PROTECTED]> >To: "'Mark Goland&

RE: switch

2002-10-12 Thread nkuipers
uot;; >_exit 0; # take this out once fixed > >print PW_FH "p $P_num $P_type $P_start $P_lenght"; > >close PW_FH; > >_exit 0; > >Thanx in advance, > Mark >- Original Message - >From: "Hanson, Rob" <[EMAIL PROTECTED]> >To: "'M

Re: switch

2002-10-12 Thread Jim Thomason
Try this: SWITCH: { $a >= 90 && do {print "A"; last SWITCH;}; $a >=80 && do {print "B"' last SWITCH;}; $a >=70 && do {print "C"; last SWITCH;}; $a >=60 && do {print "D"; last SWITCH;}; print "F"; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For addition

RE: switch

2002-10-11 Thread nkuipers
You could use a ternary operator here: $Ans =~ m/u/i ? print "u\n" : $Ans =~ m/d/i ? print "d\n" : $Ans =~ m/r/i ? print "r\n" : (some default); :) >= Original Message From Mark Goland <[EMAIL PROTECTED]> = >Hi guys, > >I am trying to implement a switch statment in perl. I have tryed d

RE: switch

2002-10-11 Thread Hanson, Rob
Ooops, I think I misunderstood the question in my last post. That will teach me to read the whole post first! Anyway... What does that $where in your code come from? It is in the for() statement. Shouldn't it be $Ans? I would do it more like this... print "Enter the command: "; chomp(my $inp

RE: switch

2002-10-11 Thread Hanson, Rob
You might want to try a search on CPAN, there is a switch module there... http://search.cpan.org/search?query=switch&mode=all Here is some sample code from the perldoc: = use Switch; switch ($val) { case 1 { print "number 1" } case "a"

Re: switch/case foo - a quandery

2002-06-03 Thread Peter Scott
At 11:19 AM 6/3/02 -0700, drieux wrote: >[ name withheld to protect the innocent.] >[..] >> From reading your response, below, I take it that you don't think very >> highly of the SWITCH command? Can you elaborate just a little for me as >> to why? You see, I've dabbled in other languages (mos