Well, you are forgetting a my $i
if you want
to have equivalent code. I maintain the code is nearly
identical - there's a few lines more in C, which look a lot
for such a short program, but it wasn't linear in the size
of the Perl program. Had you have had 100 of such loops,
you'd have had the same amount of extra lines.
I never claimed that C would have been a better choice than
Perl. Instead, I said that I didn't consider C a good first
language either. IMO there's only one reason to learn C before
learning Perl and that's because there's so much of C in Perl.
It makes you a better Perl programmer.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||