Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Test automation

by Eily (Monsignor)
on Jul 01, 2015 at 14:38 UTC ( [id://1132831]=note: print w/replies, xml ) Need Help??


in reply to Testing a .pl script

You can do something like this:

sub main { until (should_stop()) { # code goes here } } main unless caller;
This way the main sub will be called only if the script is called directly and not if it is included in a test through require "script.pl".

Replies are listed 'Best First'.
Re^2: Test automation
by perl_help26 (Beadle) on Jul 01, 2015 at 14:46 UTC
    Suppose we are running the script from crontab, will that be considered as a caller?

      caller only knows about callers in the same perl process. So do or require will not trigger a main call, while cron, or even system "perl script.pl"; will.

        Thank you

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1132831]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-18 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found