RE: Templates (again)
ivanwillsau wrote on Tue Oct 26 08:06:24 MEST 2004:
Here are the templates I use. I tend to use them to write standard sub's and basic file layouts. Hope this helps Ivanfor ( ${cursor}; ; ) { ; }foreach my $$item (@array) { ${cursor}; }=head2 function ( ${cursor}$$parameter_list ) @param $$param1: description @param : @return type: return values Long description =cutwhile ( ${cursor} ) { ; }if ( ${cursor} ) { ; }if ( ${cursor} ) { ; } else { ; }=head2 function ( $$param ) @param $$param: description @return type: return description Long description =cut sub function { ${cursor}; }package Q; =head1 NAME Q =head1 SYNOPSIS # include the module use Q; # create a new Q object my $$q = new Q(); # do something $$q->func(); =head1 DESCRIPTION what it does =cut use strict; use Exporter; use Data::Dumper qw/Dumper/; use Carp; use CGI; use DBI; use base qw/Exporter/; our $$VERSION = 0.1; our @EXPORT = qw//; our @EXPORT_OK = qw//; =head1 FUNCTIONS =cut =head2 new ( $$param ) @param $$param: description @return Q: return a new Q object Create a new Q object =cut sub new { my $$caller = shift; my $$class = (ref $$caller) ? ref $$caller : $$caller; my $$self = {}; ${cursor}; bless $$self, $$class; } 1; =head1 ALSO SEE Apollo:: =head1 AUTHORS and COPYRIGHT Ivan Wills Copyright ${year} Apollo Life Sciences Pty. Ltd. =cut __END__=head2 method ( $$param ) @param $$param: description @return type: return description Long description =cut sub method { my $$self = shift; ${cursor}#my $$dbh = $$self->{-dbh}; #my $$q = $$self->{-cgi}; }do { ; } while ( ${cursor} )unless ( ${cursor} );if ( ${cursor} );=head2 class_method ( $$param ) @param $$param: description @return type: return description Long description =cut sub class_method { my $$caller = shift; my $$class = (ref $$caller) ? ref $$caller : $$caller; ${cursor} }elsif ( ${cursor} ) { ; }else { ${cursor}; }unless ( ${cursor} ) { ; }sub find_files { my ($$directory, $$search) = @_; opendir DIR, $$directory or warn "Unable to open $$directory: $$!\n" and return; my @files = readdir DIR; close DIR; foreach my $$file (@files) { next if $$file =~ /^\.\.?$$/; # ignore the directories . and .. if ( -d "$$directory/$$file" ) { # recurse to sub directories find_files( "$$directory/$$file", $$search ); } else { # process the file ${cursor}; } } return ; }#!/usr/bin/perl -wT ## MENU ('Top Level Menu/Sub Menu/Menu item', 'System/Something/*', -display => 1, ) use strict; use warnings; use CGI; use Apollo::System::Session; use Apollo::System::HTML; ### creating CGI object my $$q = new CGI; my $$session_valid = 0; my $$session = new Apollo::System::Session; my $$html = new Apollo::System::HTML( -session => $$session, -cgi => $$q, -style => 'Main' ); if ( my $$text = $$html->start_session( "System/Something/*" ) ) { print $$text; exit; } print $$q->header( -type => "text/html" ), $$html->start_page( { -title => "Welcome to ALS" } ), $$html->top_of_page( { -heading => "Start Page" } ); # # # START YOUR CODE ${cursor} # END OF YOUR CODE # # print $$html->bottom_of_page(), $$q->end_html(); exit; __END__warn "${cursor}: $$DBI::errstr" if defined $$DBI::errstr;if ( defined $$DBI::errstr ) { warn "${cursor}: $$DBI::errstr"; }#!/usr/bin/perl use strict; __DATA__#!/usr/bin/perl use strict; use Getopt::Long; unless ( @ARGV ) { help(); exit(); } process_options(); exit(); sub process_options { my ( $$other, $$help, $$verbose ) = ( '', 0, 0 ); GetOptions( 'other=s' => \$$other, 'verbose!' => \$$verbose, help => \$$help, ); if ( $$help ) { help(); exit(); } # do stuff here } sub help { print <<HELP; Usage: script.pl [options] -o --other Other -h --help Show this file -v --verbose Show more detailed output Note: stuff HELP } __DATA__#!/usr/bin/perl use strict; use Apollo::Test; use Apollo::Module; my $$t = new Apollo::Test(); test_example($$t); $$t->display(); exit(); sub test_example { my ( $$t, ) = @_; $$t->test( "" ); # do test my $$r; $$t->result( "", $$r ); } __DATA__
Note: The above is an archived snapshot of a forum thread. Use the original thread at sf.net to post comments.