in reply to Introspecting the current Perl file via DATA, even w/o DATA?
I dedicated a few hours to this today to see if there's a way to explicitly gain access to and modify the __DATA__ target into existence, when it wasn't explicitly defined, or gain access to $0 without opening it.
I tried all manner of hacking the Symbol Table, trying to force things into position, tried to merge the current running script into something that could be used, and alas, I honestly think it can't be done the way you desire.
I agree with AnonymousMonk, that you're going to have to load __FILE__. Do it in BEGIN, stash the results, and deal with the penalty.
I have modules that'll do this, but your efficiency goes down the toilet.
Discipulus said "I hope to hear working solutions but i humbly suspect we'll not", and I agree. I have one module that does deep file 'stuff', but from what I can tell, there's no way to hack a file handle to point to the current running script without opening it directly (I'm hoping with all I have that someone will direct us to a different understanding).
I keenly await responses from those who might be able to correct this understanding, through perhaps perlapi, symtab or otherwise.
Good question.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Introspecting the current Perl file via DATA, even w/o DATA? ( __FILE__ )
by LanX (Saint) on Feb 05, 2016 at 15:22 UTC |