Well, it is "pointless" by definition - there's a condition that exists
where you do nothing.
Take the example of checking the properties of a file that I sent along. If
the file checks out 'ok' - i.e., passes all the if's and elsif's - then you
are at the end of your if-eslif-else construct and you do:
1.) Nothing - leave the 'else' off,
2.) Add the 'else with a ';' ( e.g., else { ; # continue } ),
3.) Add the 'else' and print a log message saying 'all ok'.
( The above are some of the suggestions - all good - that I got ). I am use
to writing in C/C++ and I usually add the 'else' at the end because other
coders debugging the program in the future might very well be looking for
it. It is a matter of style, of course, but I think it would be nice to
have a 'continue' statement in Perl for readability.
Anyway, thanks for all your input - this is kind of a 'religious' question
after all! :-)
> Anthony (Tony) Esposito
> Senior Technical Consultant
> Inovis(tm), formerly Harbinger and Extricity
> 2425 N. Central Expressway, Suite 900
> Richardson, TX 75080
> (972) 643-3115
> [EMAIL PROTECTED]
>
-----Original Message-----
From: Jeff Westman [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 03, 2003 1:07 PM
To: beginners
Subject: RE: Syntatic sugar maybe - no 'continue' command
It's a matter of style, I suppose, but seems kind of pointless to me. To
each their own...
But to answer your question, you can use a ';' on a line by itself, such as
#!/usr/bin/perl -w
$a = localtime();
if ($a =~ /Mar/) {
print "March\n";
} elsif ($a =~ /Feb/) {
print "February\n";
} else {
; # do nothing
}
You should definitely put a comment on the ';' line to show your intentions.
-Jeff
--- "Wagner, David --- Senior Programmer Analyst --- WGO"
<[EMAIL PROTECTED]> wrote:
> Tony Esposito wrote:
> > When you have an if-elsif-else situation like below, where there is no
> > action taken on the final 'else', is there a way to just say
> > 'continue' - like one would do in C - or is it considered 'ok' to
> > just leave off the final 'else'?
> > My experience has taught me to include the final 'else' but just add a
> > 'continue' command or NULL. This is to make the code more readable.
> >
> Talking about style and what makes the most sense to you. I assume
this
> is in some type of sub or loop which will finally get out. To me, I would
> use the else only if I had something else to do otherwise leave off.
>
> Wags ;)
>
>
> **********************************************************
> This message contains information that is confidential
> and proprietary to FedEx Freight or its affiliates.
> It is intended only for the recipient named and for
> the express purpose(s) described therein.
> Any other use is prohibited.
> ****************************************************************
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]