Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Do you know where your variables are?
 
PerlMonks  

behaviour of do

by rsiedl (Friar)
on Apr 13, 2006 at 22:10 UTC ( [id://543268]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

rsiedl has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I'm trying to find out more about how the perl function 'do' works.
I'm aware that in almost all cases it's better to 'use', but please bear with me...
If I have a cgi script with the following:
do 'loation/to/code.pl';
and the code looks like such:
warn 'this is a warning';
everything works fine.
However with the following setup, it doesnt print the warning the the http error log...
Script:
do 'location/to/code.pl';
code.pl:
do 'location/to/another/code.pl';
another/code.pl
warn 'this is a warning from another code";
Can anyone explain this to me please?

Cheers,
Reagen

Big Update: I've discovered that the problem is not being caused by the do code, but because one of the blocks of code is forking into the background.
I'm still interested to know what is going on, ie. how i can see the warnings, but I'm not sure now what route to take.
Should I mark this question as mute and open a new one or continue with this one?
Cheers.

Replies are listed 'Best First'.
Re: behaviour of do
by revdiablo (Prior) on Apr 13, 2006 at 22:22 UTC

    I can't reproduce your behavior. It seems to Work For Me:

    $ cat one.pl #!/usr/bin/perl do 'two.pl'; $ cat two.pl #!/usr/bin/perl warn "Oops"; do "three.pl"; $ cat three.pl #!/usr/bin/perl warn "Poops"; $ perl one.pl Oops at two.pl line 2. Poops at three.pl line 2.
      yeah, thanks revdiablo.

      I just did the same test with the same results as you.
      Does each bit of 'do' code need to return true, do you know?
        perldoc -f do

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://543268]
Approved by ikegami
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.