Sayed, Irfan (Irfan) wrote:
> Hi All,
>  
> I am getting error while running following script.Error is due to
> improper if else loop and curly braces.
>  
> Can you please guide me in placing the braces in right position and
> doing proper if..else looping
>
> My requirement is that I want to quit as soon as "if condition"
> fails.Please guide
>
>   
Whitespace is your friend.  If you indent blocks it makes it much easier
to figure out how the braces match up.  I haven't actually looked too
much at the code, but as already mentioned "else"s should only be at the
end of conditionals.    Also if you're trying to just use "else" to
quit, it's normally more concise to negate the conditional test and exit
there.  Along the lines of:  if ($menu_item != 1) { quit() }; (or the
block-less inverted if when you're comfortable using it...it looks as
though you should focus on the long way for now). 


if ($menu_item == 1) {
     $pvob=`$CT lsvob -s | grep apc`;
     chomp($pvob);
     my @proj=`$CT lsproj -invob $pvob | cut -d " " -f3`;
     [EMAIL PROTECTED];
     print "The projects are.....\n\n";
     my $i=1;
     foreach my $line(@proj) {
         print "\t" . $i++ . ". $line\n";
    }
    print "Your Choice :\t";
    chomp($choice = <STDIN>);
     if ($choice < $len) {
        print "Your choice: $proj[$choice-1]\n";
        chomp($pro=$proj[$choice-1]);
         chomp($proj1=$pro . "@" . $pvob);
         #print "$proj1\n";
         my $int_str=`$CT desc -fmt "%[istream]p" project:$proj1`;
    } else {
        quit();
    } elsif ($int_str eq "") {
        print "This project does not have Integration stream , so
quiting.....\n"; exit;
    } else{
        print "Integration Stream:$int_str\n";
        dev_strm();
    }
} else {
    quit();
}
> Regards
> Irfan
>
>  
>
>   


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to