A Conversation for Perl (under construction)

Not really Perlish

Post 1

Researcher 193823

Please note that the Perl code presented here isn't very idiomatic, or even correct.

The C-style for-loop is not the best way to write that kind of Perl loop (apart from the fact that "$i = 5" probably isn't right). An alternative would be:

for my $i (1..5) {
#Loop stuff
}

But there is more than one way to do it. Dealing with lists and arrays are one of the many strong points of Perl BTW.

The comparison with Pascal isn't very useful either, since the Perl code lacks "use strict" and doesn't declare the variables (something all Perl programs above a few lines really should do). Including them would make the Perl example as long as the Pascal code. Perl _is_ more compact than Pascal however, even though this small example doesn't show it smiley - smiley

This is how you read a line from STDIN:

my $x = ;


/J


Key: Complain about this post

Not really Perlish

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more