in reply to Coderefs and @INC

You should have asked me :D

In short, return a filehandle or undef

See Re: how to make lexical pragma global, hints ( pl_hints $^H %^H ), taint::all (package taintall)

Compare with https://perl5.git.perl.org/perl.git/blob/blead:/t/op/inccode.t

  • Comment on Re: Coderefs and @INC (return filehandle or undef)

Replies are listed 'Best First'.
Re^2: Coderefs and @INC (return filehandle or undef)
by clueless newbie (Curate) on Jul 04, 2018 at 16:13 UTC

    Thank you, very much for the second link.

    What is weird is that if my dbLoader writes the source to a file then returns a filehandle (the method used in the test) to that file both 'works.pl' and 'worksnot.pl' run successfully. But if dbLoader opens a filehandle on the reference to a string (aka in-memory-file) only 'works.pl' runs successful. 'worksnot.pl' still throws the error shown in the op.

    Apparently I'm looking in the wrong place for the source of the problem. If dbloader opens a filehandle on an in-memory file where the contents are copied (rather than on the reference returned by the database) all is well. ie:

    Won't work
    open my $fh,'<',$body_sref or die "Couldn't open '\$body_ref' for reading. $!"; return $fh;
    Will work
    open my $fh,'<',\(my $buffer=$$body_sref) or die "Couldn't open in-memory file for io. $!"; return $fh;