Since you asked, here's the equivalent in C (for those that aren't familiar -- I'm sure you are):
#include <stdio.h>
int main(void)
{
int i;
for ( i = 0; i < 10; i++ )
{
printf ( "%d", i );
}
}
The equivalent in Perl is
for ( $i = 0; $i < 10; $i++ )
{
print $i;
}
No variable declarations, a friendlier print statement, and no mysterious 'cargo-cult' include thingy.
Don't get me wrong -- I have programmed in C since the early 80's and I love the language. But Perl takes care of lots of the underlying stuff (how many times did I write fopen(), fread() and fclose() statements I wonder). That's why I think Perl is a better choice than C.
Perl can be a heavyweight language, but it can also be lightweight. To use the car analogy, C is a bit like the British Triumph, a little finicky, but piles of power and cornering. Pascal is a bit like a Pinto or a CV5 stuck in second gear. Perl is like a Porsche or a Lexus, nimble yet powerful.
--t. alex
"Mud, mud, glorious mud. Nothing quite like it for cooling the blood!"
--Michael Flanders and Donald Swann
|