develooper Front page | perl.perl5.porters | Postings from July 2001

Re: [PATCH perl@11059] if at first you don't succeed, croak?

Thread Previous | Thread Next
July 3, 2001 13:23
Re: [PATCH perl@11059] if at first you don't succeed, croak?
Message ID:
In article <>,
	"Craig A. Berry" <> writes:
> The existing logic in openunicode() bails out if it fails to open the first 
> filespec it tries.  I believe the intent is to iterate through @INC until it 
> successfully finds and opens the file or exhausts the list.
> --- lib/Unicode/;-0       Sun Jul  1 01:56:14 2001
> +++ lib/Unicode/  Mon Jul  2 14:49:25 2001
> @@ -44,6 +44,7 @@
>         for my $d (@INC) {
>             use File::Spec;
>             $f = File::Spec->catfile($d, "unicode", @path);
> +           next unless -f $f;
>             if (open($$rfh, $f)) {
>                 last;
>             } else {

Strictly speaking that introduces a race. Normally it's better to
check the open result against ENOENT, but the cost would be to
have to load one of the Errno modules. Another way may be to do a
next in the else branch always, but remember $! and report the last one
on failure.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About