Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Strawberry perl - file association?

by zeltus (Sexton)
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 'common.pl';" 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 check_email.pl an@email.address All is well and it runs fine. And fast. Lovely. But D:/pearls/> check_email.pl 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

Comment on Strawberry perl - file association?
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 script.pl works fine. But > script.pl 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.

Reaped: Re: Strawberry perl - file association?
by NodeReaper (Curate) on Oct 24, 2011 at 13:54 UTC
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 'common.pl' }; 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-12-20 23:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (99 votes), past polls