more useful options | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hello syphilis,
I imagine you already know why is better to use lexical filehandles with 3 arguments (enforcing the scope, autoclose,...), but as you are asking about official docs I cannot find anything. Well generally speaking perl documentation is very eterogenous in style. At least. > What's so wrong with doing open RD, '<', 'file.txt' ? Nothing if you know what happens in this line and in the whole code you are writing.
I consider the second line less error prone, if you have thousand lines of code with many open FH statements the risk to forget to close one of them and mess the whole thing is high. So it is a matter of (better) habits and nothing wrong per se. See also why-the-modern-perl-book-avoids-bareword-filehandles. And perlmaven. More: if it is a matter of good habits I will enforce an exception also in the 2 arguments form of open What happens if you feed open my $in, $filename; with >/etc/passwd ? Infact 2 arguments form is dangeourous. If it was my decision I will enhance strict pragma to deal with this:
L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS. In reply to Re: Is there a problem with using barewords as filehandles ?
by Discipulus
|
|