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

Main routines, unit tests, and sugar

by stephen (Priest)
on Jun 13, 2013 at 04:43 UTC ( #1038667=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/env perl
    
    ...
        
        print "Hello $name\n";
    }
    
  2. or download this
    # Main routine
    sub main {
    ...
    }
    
    main();
    
  3. or download this
    # Main routine
    MAIN: {
    ...
    
        say_hello($greeted);
    }
    
  4. or download this
    # Main routine
    MAIN: {
    ...
    
        exit(0);
    }
    
  5. or download this
    package My::Routine;
    
    ...
    
    # Run the main routine only when called as a script
    __PACKAGE__->main() unless caller;
    
  6. or download this
    #!/usr/bin/perl
    
    ...
        say_hello($greeted);
    };
    
  7. or download this
    #!/usr/bin/env perl
    require 'script_with_main.pl';
    print "Loaded script!\n";
    run_main('Shakespeare!', 'perlmonks');
    
  8. or download this
    $ perl test_test_main.pl 
    Loaded script!
    Hello perlmonks
    
  9. or download this
    use strict;
    use warnings;
    ...
    };
    
    1;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1038667]
Approved by davido
Front-paged by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-12-26 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (163 votes), past polls