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;