Re: Nested if and elsif and else

2010-04-15 Thread Harry Putnam
Ron Bergin writes: > Sorry for not posting the if/elsif/else block, but to me that part > appeared to be obvious, but I guess it wasn't. Probably would have been for all but the densist I guess. Not the first time I've been guilty of that. > I see that Jim has posted the if/elsif/else part, so

Re: Nested if and elsif and else

2010-04-15 Thread Ron Bergin
On Apr 15, 9:21 am, rea...@newsguy.com (Harry Putnam) wrote: > r...@i.frys.com writes: > > Here's an example I gave in a similar question in another > > forum. > > Thanks... > > I'm sorry to ask more but if someone asked to be shown an > if/elsif/else construct being replaced by a dispatch table, I

Re: Nested if and elsif and else

2010-04-15 Thread Jim Gibson
On 4/15/10 Thu Apr 15, 2010 9:21 AM, "Harry Putnam" scribbled: > r...@i.frys.com writes: > >> Here's an example I gave in a similar question in another >> forum. > > Thanks... > > I'm sorry to ask more but if someone asked to be shown an > if/elsif/else construct being replaced by a dispatc

Re: Nested if and elsif and else

2010-04-15 Thread Harry Putnam
r...@i.frys.com writes: > Here's an example I gave in a similar question in another > forum. Thanks... I'm sorry to ask more but if someone asked to be shown an if/elsif/else construct being replaced by a dispatch table, I don't really see how that answered there question. It didn't for me. W

Re: Nested if and elsif and else

2010-04-15 Thread rkb
Harry Putnam wrote: > "Uri Guttman" writes: > >> i disagree that it is elegant. too often if/else lists >> are not >> needed. many can be replaced by dispatch tables. if one >> of the clauses >> does just a return or next/last that can be replaced >> with a modifier or >> shorter statement. withou

Re: Nested if and elsif and else

2010-04-15 Thread Harry Putnam
"Uri Guttman" writes: > i disagree that it is elegant. too often if/else lists are not > needed. many can be replaced by dispatch tables. if one of the clauses > does just a return or next/last that can be replaced with a modifier or > shorter statement. without ANY serious work, i have over 10k

Re: Nested if and elsif and else

2010-04-14 Thread Raymond Wan
Hi Mimi, Mimi Cafe wrote: I think this will work, but is it elegant.? If (condition){ if (nexted_condition){ As others have noted, it will work. But as for elegance, this is a very subjective opinion and contrary to what recent comments have said, my take on it is that it depends on

Re: Nested if and elsif and else

2010-04-14 Thread Steve Bertrand
On 2010.04.13 23:17, Kenneth Wolcott wrote: > Hi; > > On Tue, Apr 13, 2010 at 19:54, Uri Guttman wrote: >>> "JG" == Jim Gibson writes: >> >> JG> On 4/13/10 Tue Apr 13, 2010 4:35 PM, "Mimi Cafe" >> >> JG> scribbled: >> >> >> I think this will work, but is it elegant.? >> >> JG> Yes, i

RE: Nested if and elsif and else

2010-04-14 Thread Mimi Cafe
Yes, the nested if and elsif and else makes the code difficult to read and I often get stuck trying to make sense of it all. For now, I will look to see if I can move some bit and pieces to subroutines to improve readability. Thanks guys Mimi -Original Message- From: Jim Gibson

Re: Nested if and elsif and else

2010-04-14 Thread Shlomi Fish
On Wednesday 14 Apr 2010 02:35:50 Mimi Cafe wrote: > I think this will work, but is it elegant.? > > > > If (condition){ > >if (nexted_condition){ > > do this. > >} > >Elsif (nexted_condition){ > > Do that... > >} > > else{ > > Do something else. > >

Re: Nested if and elsif and else

2010-04-13 Thread Kenneth Wolcott
Hi; On Tue, Apr 13, 2010 at 19:54, Uri Guttman wrote: >> "JG" == Jim Gibson writes: > >  JG> On 4/13/10 Tue  Apr 13, 2010  4:35 PM, "Mimi Cafe" > >  JG> scribbled: > >  >> I think this will work, but is it elegant.? > >  JG> Yes, it will work, and yes, it is elegant, as long as it encapsul

Re: Nested if and elsif and else

2010-04-13 Thread Uri Guttman
> "JG" == Jim Gibson writes: JG> On 4/13/10 Tue Apr 13, 2010 4:35 PM, "Mimi Cafe" JG> scribbled: >> I think this will work, but is it elegant.? JG> Yes, it will work, and yes, it is elegant, as long as it encapsulates the JG> logic that is required by your program. i disagree

Re: Nested if and elsif and else

2010-04-13 Thread Jim Gibson
On 4/13/10 Tue Apr 13, 2010 4:35 PM, "Mimi Cafe" scribbled: > I think this will work, but is it elegant.? Yes, it will work, and yes, it is elegant, as long as it encapsulates the logic that is required by your program. Be sure and watch your indenting, so you can mentally group the correct b

Nested if and elsif and else

2010-04-13 Thread Mimi Cafe
I think this will work, but is it elegant.? If (condition){ if (nexted_condition){ do this. } Elsif (nexted_condition){ Do that... } else{ Do something else. } } else{ Do something else.. } Mimi

Re: nested "if"

2004-07-04 Thread Michael S. Robeson II
Great, thanks for the help! -Mike On Jul 3, 2004, at 2:16 PM, Gunnar Hjalmarsson wrote: Michael S. Robeson II wrote: No, your post was not in the last e-mail digest I received, I see. Sometimes I think that digest mode for mailing lists is a nuisance. ;-) But the link you provided seems to clear th

Re: nested "if"

2004-07-04 Thread Michael S. Robeson II
, the indentation makes it much more clearer. However, this does not help me understand how the nested "if" statements are working. Which of the two "if" statements gets evaluated first? I am trying to figure out "in english" what the "if" statements are act

Re: nested "if"

2004-07-03 Thread Michael S. Robeson II
s a key-value pair in the hash. I guess the individual who wrote the code could make it much cleaner or easier to read. The re-organizing of the conditionals in your second e-mail makes it perfectly clear and would be something I would have done had I known how the nested 'if' statement

Re: nested "if"

2004-07-03 Thread Gunnar Hjalmarsson
Michael S. Robeson II wrote: Which of the two "if" statements gets evaluated first? I am trying to figure out "in english" what the "if" statements are actually doing. Is it saying: "If a line begins with ">bla-bla" and if $seq (which appears no where else in the code other than " $seq="" ") ex

Re: nested "if"

2004-07-03 Thread Randy W. Sims
On 7/3/2004 4:38 AM, Randy W. Sims wrote: Tidied up a little more: Actually, I'd probably invert the condition to make it clearer that it's accumulating multi-line sequences. my( %pro, @names); my( $name, $seq, $k ); while (defined( my $line = )) { unless ($line =~ /^>(.+)/) { chomp(

Re: nested "if"

2004-07-03 Thread Randy W. Sims
On 7/2/2004 10:25 PM, Michael S. Robeson II wrote: Well yeah, the indentation makes it much more clearer. However, this does not help me understand how the nested "if" statements are working. Which of the two "if" statements gets evaluated first? I am trying to figure out &

Re: nested "if"

2004-07-03 Thread Michael S. Robeson II
Well yeah, the indentation makes it much more clearer. However, this does not help me understand how the nested "if" statements are working. Which of the two "if" statements gets evaluated first? I am trying to figure out "in english" what the "if" stat

Re: nested "if"

2004-07-02 Thread Gunnar Hjalmarsson
$pro\n\n"; } $name=$1; $name=~s/\s//g; push @names, $name; #print "$name\n"; $k++; $seq=""; } else { chomp $line; $seq.=$line; } } I am having troub

nested "if"

2004-07-02 Thread Michael S. Robeson II
$name=$1; $name=~s/\s//g; push @names, $name; #print "$name\n"; $k++; $seq=""; } else { chomp $line; $seq.=$line; } } I am having trouble figuring out

Re: question on nested if

2003-01-16 Thread John W. Krahn
Seamus Carr wrote: > > I'm trying to count first occurrence of a pattern in a block of lines > which have the same number in first field. I was using if statements to > test the conditions. The problem is that it reads the pattern of every > line, not skipping rest of the block if the pattern ha

Re: question on nested if

2003-01-16 Thread Rob Dixon
Hi Seamus Seamus Carr wrote: > I'm trying to count first occurrence of a pattern in a block of lines > which have the same number in first field. 'Count the first occurrence'? That would be '1' ;-) > I was using if statements > to test the conditions. The problem is that it reads the pattern of

question on nested if

2003-01-16 Thread Seamus Carr
I'm trying to count first occurrence of a pattern in a block of lines which have the same number in first field. I was using if statements to test the conditions. The problem is that it reads the pattern of every line, not skipping rest of the block if the pattern has been matched. Putting th

Re: Nested IF

2002-01-02 Thread John W. Krahn
Michael Simmons wrote: > > Does anyone see what the problem with this is? > > if ( $tline[$i] =~ /^$name\s/ ) { > if ( $tline[$i] =~ /\scname\s/ ) { > print "Found the following alias: \n"; > print "$tline[$i]; > } > elsif ( $t

RE: Nested IF

2002-01-02 Thread Hanson, Robert
immons [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 02, 2002 12:08 PM To: [EMAIL PROTECTED] Subject: Nested IF Does anyone see what the problem with this is? if ( $tline[$i] =~ /^$name\s/ ) { if ( $tline[$i] =~ /\scname\s/ ) { print "Fou

Nested IF

2002-01-02 Thread Michael Simmons
Does anyone see what the problem with this is? if ( $tline[$i] =~ /^$name\s/ ) { if ( $tline[$i] =~ /\scname\s/ ) { print "Found the following alias: \n"; print "$tline[$i]; } elsif ( $tline[$i] =~ /\sa\s/ ) { p