Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Strawberry perl - file association?

by zeltus (Beadle)
on Oct 24, 2011 at 09:44 UTC ( #933332=perlquestion: print w/replies, xml ) Need Help??
zeltus has asked for the wisdom of the Perl Monks concerning the following question:

I am not sure if this is a perl problem or (more likely I guess) a Windows issue. I am running Strawberry perl 5.12.3. My code has a "require '';" statement in it containing useful (to me) functions and routines that I call in all/most of my programs, declared as a package. If I run the proggie D:/pearls/> perl an@email.address All is well and it runs fine. And fast. Lovely. But D:/pearls/> an@email.address Undefined subroutine log_exit at line 51... log_exit is declared (as a main::) subroutine in my require'd package. Can someone explain this to me please? Once I understand why I have this issue, I can work out what I want to do about it. I am running this under 32-bit Win7 by the way, if that has any impact on the problem. Cheers Bill

Replies are listed 'Best First'.
Re: Strawberry perl - file association?
by Anonymous Monk on Oct 24, 2011 at 09:52 UTC
      Yup, FTYPE and ASSOC set up correctly, I believe. But the problem is completely this area as far as I can tell. Calling my script as an argument to perl.exe > perl works fine. But > runs the script (correctly) but then if barfs on the require'd package. It does this when a subroutine declared as, say, main::runme() is called. So the require opertion itself seems to work OK. Looks like there is some sort of conflict betwixt the namespaces and Windows. Somewhere. Somehow.

        Please reduce your code to a small, self-contained example that still exhibits the error. Most likely, this will mean you have to create your main file and the file that is loaded via require, but neither should be more than 10 lines long. Once you have these, we can look at them and try to reproduce your problem.

        Are you sure that the perl.exe that you are explicitly invoking is the same perl.exe that your file association is set up for? Output $^X from within your Perl script to check.

Re: Strawberry perl - file association?
by mrstlee (Beadle) on Oct 24, 2011 at 15:17 UTC
    Maybe the require silently fails (Unlikely - but ...)? One thing you could try is wrapping the 'require statement' in an eval and then checking $@ afterwards e.g.:
    eval { require '' }; die "Not good:$@\n" if defined $@;
    When log_exit is called is it called as main::log_exit? Can't imagine why but is it possible that the indirect invocation causes log_exit to be called in a package other than main?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://933332]
Approved by wfsp
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2016-09-28 00:15 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (516 votes). Check out past polls.