johngg has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; open my $inFH, q{<}, \ <<END or die qq{open: $!\n}; The boy stood on the burning deck, Eating an ice cream, Walls. The ice fell down his trouser leg, And paralysed his left kneecap. END while ( <$inFH> ) { print qq{$.: $_} if m{([aeiou])\1}; } close $inFH or die qq{close: $!\n};
1: The boy stood on the burning deck, 4: And paralysed his left kneecap.
my feeling is that checking for success on open and close are not needed and could safely be dispensed with. Is this a dangerous assumption?
Cheers,
JohnGG
Update: Thank you, jbert, kyle and Sartan for your responses. As happens, I am very likely to continue checking for success as it is already an ingrained habit and I wasn't even aware that one could open a scalar until recently. jbert, I thought your point regarding possible future implementations was particularly telling.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Checking success of open() on file held in scalar ref.
by kyle (Abbot) on Nov 14, 2007 at 18:07 UTC | |
|
Re: Checking success of open() on file held in scalar ref.
by jbert (Priest) on Nov 14, 2007 at 17:17 UTC | |
|
Re: Checking success of open() on file held in scalar ref.
by Sartan (Pilgrim) on Nov 14, 2007 at 18:12 UTC | |
by djp (Hermit) on Nov 15, 2007 at 05:56 UTC | |
by MidLifeXis (Monsignor) on Nov 15, 2007 at 19:23 UTC | |
by djp (Hermit) on Nov 19, 2007 at 02:17 UTC |