Skip Menu |

This queue is for tickets about the PodParser CPAN distribution.

Report information
The Basics
Id: 9274
Status: resolved
Worked: 15 min
Priority: 0/
Queue: PodParser

People
Owner: Nobody in particular
Requestors: mark [...] summersault.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.28
Fixed in: (no value)



Subject: failure with relative paths and chdir before pod2usage()
pod2usage() won't find the file if the working directory has changed and the script was invoked with a relative path. The solution is to provide a better default instead of "$0" here: ## Default the input file $opts{"-input"} = $0 unless (defined $opts{"-input"}); I don't have the patience to track down how to do that right now, though.
Neither I see a chance to fix this in a sensible way. Pod::Usage already spends considerable effort to determine the script/module location, by searching $PATH etc. Only in the pathological case that $0 is a relative path, and the script itself takes away the point of reference (the cwd) there is a problem - and I do not see a robust way to do this: 1. Store the cwd in a BEGIN {} in Pod::Usage for later reference: This can easily be broken by doing the chdir in a BEGIN block in the script itself. And it adds significant overhead (loading Cwd and executing cwd()) for all normal cases 2. Search the entire file system for $0 That's a no-go for enterprise sites I can only say: Don't do it! Postpone the chdir() after (potentially) calling pod2usage. Or restore the chdir() to the original value (which your script must determine first) before calling pod2usage. Hope this helps... I will add a warning in Pod::Usage doc though. Feel free to reopen this ticket if you have some bright idea! -Marek
Setting this to resolved as there was no further communication for years.