sarvan has asked for the wisdom of the Perl Monks concerning the following question:
I have the following code with nested if else. Two if conditions are nested. In the first if i check on condition. if it satisfies then go into the 2nd if. In the 2nd if i route the prgm to different other programs based on the condition satisfied.
But, now it takes me directly to the else of 1st if without executing the 2nd if and its condition's. I have no idea where i did mistake. Can anyone help me.
#!/usr/bin/perl use strict; use warnings; print "Which Metric jaccard or Bleu:"; my $metric=<>; print "Which source title or snippet or url:"; my $source=<>; if($metric eq "jaccard") { if($source eq "title") { print "in title"; system("/usr/bin/perl filecom.pl") } elsif($source eq "snippet") { print "in snippet"; system("/usr/bin/perl searchsnipdup.pl") } elsif($source eq "url") { print "in url"; print"jaccard method not called"; } else { print "jacccard not called"; } } elsif($metric eq "bleu") { print "bleu called"; } else { print "bleu not called"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: nested if else
by kcott (Archbishop) on Jul 13, 2011 at 06:07 UTC | |
|
Re: nested if else
by lidden (Curate) on Jul 13, 2011 at 06:04 UTC | |
|
Re: nested if else
by Marshall (Canon) on Jul 13, 2011 at 13:47 UTC | |
|
Re: nested if else
by BrowserUk (Patriarch) on Jul 13, 2011 at 05:24 UTC |