There's never a
need to use 'while' either, given there's a plethora of other good flow control structures as well. But from that doesn't follow we should shy away from 'while'. Perl gives the programmer a full toolbox, full enough to make almost any tool 'redundant', in the sense that there are enough other tools to not use a particular tool. But we don't use that argument to select some tools, and reject others.
Personally, I use almost every tool* in the toolbox. Some more than others. I don't use goto often, but I do use it. For instance, in code like this:
my $max_tries = 10;
GETSTORE:
my $url = ask_url();
my $status = getstore($url, $file);
goto GETSTORE if $status == 200 && !-s $file && --$max_tries > 0;
... do stuff ...
return $status;
I find that more attractive than
my $max_tries = 10;
my $status;
{
my $url = ask_url();
$status = getstore($url, $file);
redo if $status == 200 && !-s $file && --$max_tries > 0;
}
.. do stuff ..
return $status
*Tools I never use that I can think of right now: formats, 1-arg open, study, and /o.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.