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

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

Thread Previous | Thread Next
From:
perl5-porters
Date:
July 3, 2001 13:23
Subject:
Re: [PATCH perl@11059] UCD.pm: if at first you don't succeed, croak?
Message ID:
9ht265$p50$1@post.home.lunix
In article <5.1.0.14.0.20010702140058.01b6c9c0@exchi01>,
	"Craig A. Berry" <craigberry@mac.com> 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/UCD.pm;-0       Sun Jul  1 01:56:14 2001
> +++ lib/Unicode/UCD.pm  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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About