Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Main routines, unit tests, and sugar

by stephen (Priest)
on Jun 13, 2013 at 04:43 UTC ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found