Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Observation 2 illustrates a danger

by tilly (Archbishop)
on Aug 22, 2001 at 09:37 UTC ( [id://106883]=note: print w/replies, xml ) Need Help??


in reply to Re: compilation errors???
in thread compilation errors???

In C one of the most common errors to make is an off-by-one error. If you use explicit for loops in Perl, you will make the same error just as often. This is a good reason to use foreach loops whenever possible.

I mention this because your second observation has an off-by-one in it. The odds of an off-by-one can be reduced, though, by:

foreach my $i (0..$#filenames) { # ... }
since that removes an inequality that people may miswrite. An even cleaner solution is offered by tye at mapcar -- map for more than one list.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://106883]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-28 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found