On Tue, Jul 03, 2001 at 06:16:37PM +0000, Ton Hospel wrote: > 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. Hmmm. Let's croak only if nothing worked. unless (defined $$rfh) { for my $d (@INC) { use File::Spec; $f = File::Spec->catfile($d, "unicode", @path); last if open($$rfh, $f); } croak __PACKAGE__, ": failed to find ",join("/",@path)," in @INC\n" unless defined $rfh; } -- $jhi++; # http://www.iki.fi/jhi/ # There is this special biologist word we use for 'stable'. # It is 'dead'. -- Jack CohenThread Previous | Thread Next