> That'll be a good one, since this code is pretty poor (doesn't check return
> code on open, uses a bad regexp pattern in the grep, etc).
Ooops! Sorry bout that! I didn't actually execute it!
The regex should be: /^\./
and the the following line:
for my $names (keys %friends)
should be changed to:
for my $name (keys %friends)
The use strict would have caught it, if the program was executed.
Which brings a good point! Don't just start writing code in emails
from the top of your head! You will undoubtedly get criticized for
trying to help. =)
But seriously, you can use 'perl -c yourprogram.pl' to check and see
if your program has any errors. You should also read about 'use
strict'. And as Paul pointed out, error checking/handling is a good
part of every program.
A good way to learn about what functions "return" would be to use the
perldoc command. As Paul, so kindly pointed out, the open function can
fail. To see how a particular function works and examples on how to
use it, simply type:
perldoc -f [perl function name]
So for example, you could type the following to find out what the
'open' function does:
perldoc -f open
This should print out the documentation for the 'open' function.
And finally, one last word of advice; You will encounter many people
who will not be so willing to help out. You will get many responses
like "read the ******* manual" or something similiar. You must realize
that it takes much less effort to criticize than to help. Don't be
discouraged, just keep trying. Eventually you will find the one person
who is willing to help.
P.S. Reading the ******* manuals _is_ actually a good idea! ;-)