New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to avoid __FILE__ variable containing relative path #15212
Comments
From @hakonhaglandI am writing a module that implements a subroutine that requires to I believe the caller() function gets the filename from package I suspect the reason that __FILE__ is not populated with an absolute If this is the case, would it be possible to introduce an environment On the other hand, if the variable PERL5FILEPATH is not set, or set to This should also work for the main program file "$0", and it could Why use an environment variable like PERL5FILEPATH? Why not a special When does __FILE__ become relative? For modules, it will become Of course if the cost of Cwd::getcwd() is not the reason why __FILE__ Best regards, |
From zefram@fysh.orgHakon Haegland wrote:
That's not a good idea. Why do you think you need to do this? What are
Normally, if this kind of thing is an issue then the main program is
That's not a variable, and not located in a module package. Syntactically
No, it's not a desired feature that was sacrificed for performance.
Bad way to control it. However, if this would fix your case, that shows -zefram |
The RT System itself - Status changed from 'new' to 'open' |
From @hakonhaglandHi Zefram. Thanks for the detailed response! I am still not convinced that I
I am trying to make a small improvement to the CPAN module My thought was that the Pod documentation of the module could mention that
Do you mean if the file has been deleted in the mean time?
Cwd::abs_path($filename) should be able to convert a relative 2016-03-02 21:44 GMT+01:00 Zefram via RT <perlbug-followup@perl.org>:
|
From zefram@fysh.orgHakon Haegland wrote:
...
That is totally the wrong way to go about it. PadWalker and source
That's one possibility. Also may have been modified, or its permissions
It attempts to, but it is not always possible. The current directory This RT ticket should be rejected. -zefram |
From @hakonhagland
Thanks for the reference to Debug::Show. Unfortunately, I have limited So for the moment I will continue working with PPI (despite its
Since Perl have a philosophy of "making hard things possible", I I think for most practical cases __FILE_ABSPATH__ would be defined, 2016-03-04 15:37 GMT+01:00 Zefram via RT <perlbug-followup@perl.org>:
|
From zefram@fysh.orgHakon Haegland wrote:
The thing you want *is* possible. You're turning down the way to do
This would mean that the attempt at abspath() must be performed for every There are better ways to address your case, especially because it's only -zefram |
From @demerphqOn 7 March 2016 at 05:46, Zefram <zefram@fysh.org> wrote:
FWIW, I for one would not mind. If __FILE__, or caller, simply started
I don't know that its bizarre. I think the use case described in this I also think the cost is so trivial almost nobody would care.
Personally if someone had a patch that added it, and supporting it I guess to roll this yourself you would have to tie @INC, and make cheers, -- |
From @hakonhagland
Agree.
Yes it is possible to tie @INC, see for example Array::Sticky::INC https://metacpan.org/pod/Array::Sticky::INC but even if @INC was tied, I think it can only affect modules loaded after 2016-03-07 11:07 GMT+01:00 yves orton via RT <perlbug-followup@perl.org>:
|
Migrated from rt.perl.org#127646 (status was 'open')
Searchable as RT127646$
The text was updated successfully, but these errors were encountered: