summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2000-10-18 17:21:54 +0000
committerjoe <joe@FreeBSD.org>2000-10-18 17:21:54 +0000
commitd1eac60c8c3f82fa56915dc5615fc4edd3323b84 (patch)
tree1684e4e8a75e1e66443c10b018f7a0ebdb8d7e6d /share
parent440545207b3ae09182709e03c58387bfc5f8cd16 (diff)
downloadFreeBSD-src-d1eac60c8c3f82fa56915dc5615fc4edd3323b84.zip
FreeBSD-src-d1eac60c8c3f82fa56915dc5615fc4edd3323b84.tar.gz
Make subroutine prototypes mandatory.
The main code should be wrapped in a MAIN:{ ... } declaration. Suggested by: des
Diffstat (limited to 'share')
-rw-r--r--share/man/man7/style.perl.720
1 files changed, 20 insertions, 0 deletions
diff --git a/share/man/man7/style.perl.7 b/share/man/man7/style.perl.7
index ae253e9..c1a03d0 100644
--- a/share/man/man7/style.perl.7
+++ b/share/man/man7/style.perl.7
@@ -66,6 +66,26 @@ is documented in
#!/usr/bin/perl -wT
.Ed
.Pp
+The main program should be placed in a block labeled MAIN:. This
+makes it easier to identify the entry point in a large perl script,
+and provides a scope for variables which are used in the main
+program but nowhere else.
+.Bd -literal -offset 0i
+ MAIN:{
+ print(foo("/usr/bin/man", "7", "style.perl"));
+ exit(0);
+ }
+.Ed
+.Pp
+All subroutines should be defined using argument prototypes as defined in
+.Xr perlsub 1 .
+.Bd -literal -offset 0i
+ sub foo($@) {
+ my $cmd = shift;
+ my @args = @_;
+ }
+.Ed
+.Pp
All variables should be defined before use; this is enforced if operating
under
.Fa use strict .
OpenPOWER on IntegriCloud