New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
perl_standard.html in vendors/fcm/current/doc/standards – NEMO

source: vendors/fcm/current/doc/standards/perl_standard.html @ 1977

Last change on this file since 1977 was 1977, checked in by flavoni, 14 years ago

importing fcm vendor

File size: 5.3 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
4<html xmlns="http://www.w3.org/1999/xhtml">
5<head>
6  <meta name="generator" content=
7  "HTML Tidy for Linux/x86 (vers 1st December 2004), see www.w3.org" />
8
9  <title>Perl coding standard for FCM</title>
10  <meta name="author" content="FCM development team" />
11  <meta name="descriptions" content="Perl coding standard for FCM" />
12  <meta name="keywords" content="Perl, coding standard, FCM" />
13  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
14  <link rel="stylesheet" type="text/css" href="style.css" />
15<script type="text/javascript" src="fcm.js">
16</script>
17</head>
18
19<body onload="javascript: FCM.load('doc/standards/', 'perl-standard');">
20  <div id="ukmo-logo">
21    <img src="logo.png" alt="UK Met Office" />
22  </div>
23
24  <h1>Perl coding standard for FCM</h1>
25
26  <address>
27    Latest content update: 22 January 2010. <span id=
28    "fcm-js-maintenance"></span>
29  </address>
30
31  <address>
32    Questions regarding this document or permissions to quote from it should be
33    directed to:
34  </address>
35
36  <address>
37    <a href="mailto:iprmanager@metoffice.gov.uk">IPR Manager</a><br />
38    Met Office<br />
39    FitzRoy Road<br />
40    Exeter, Devon<br />
41    EX1 3PB<br />
42    United Kingdom
43  </address>
44
45  <address>
46    &copy; Crown Copyright 2005-10
47  </address>
48
49  <address id="fcm-js-pdf"></address>
50  <hr />
51
52  <div id="fcm-content"></div>
53
54  <h2 id="introduction">1. Introduction</h2>
55
56  <p>Perl (Practical Extraction and Report Language) is the language we use to
57  implement the in-house components of the FCM system. This document contains
58  some basic guidelines that are followed by the Perl code in FCM.</p>
59
60  <h2 id="style">2. Style</h2>
61
62  <p>There are many Perl style guides available online. Some are listed
63  below:</p>
64
65  <ul>
66    <li><a href="http://perldoc.perl.org/perlstyle.html">perlstyle</a></li>
67
68    <li><a href=
69    "http://perldoc.perl.org/perlmodstyle.html">perlmodstyle</a></li>
70
71    <li><a href=
72    "http://www.kulnet.kuleuven.ac.be/perlcourse/perlingo.html">Perlingo</a></li>
73
74    <li><a href="http://perltidy.sourceforge.net/">Perltidy</a></li>
75
76    <li><a href=
77    "http://perl.apache.org/docs/2.0/devel/core/coding_style.html">mod_perl
78    Coding Style Guide</a></li>
79
80    <li>Damian Conway's <a href=
81    "http://books.google.co.uk/books?id=gJf9tI2mytIC&amp;dq=perl+best+practices&amp;printsec=frontcover&amp;source=bn&amp;hl=en&amp;ei=rnFZS7DPB4j80wTxi-T9BA&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=4&amp;ved=0CBQQ6AEwAw#v=onepage&amp;q=&amp;f=false">
82    Perl Best Practices</a> at Google Books</li>
83  </ul>
84
85  <p>The <cite>Perl Best Practices</cite> book is the most comprehensive of
86  all. In FCM, we have begun to write new modules to follow its advice.
87  However, we recognise that it may not be possible to strictly follow every
88  detail, as Perl is a language designed to do things in different ways. The
89  most important point is that the style within a source file should be
90  consistent and easy to follow, so the next person who reads it will not have
91  to struggle with it. It is also worth nothing that many older modules in the
92  FCM source tree are still written to an old style which was derived before we
93  found out about this book.</p>
94
95  <h2 id="boilerplates">3. Boilerplates</h2>
96
97  <p>A typical Perl executable in FCM looks like:</p>
98  <pre>
99#!/usr/bin/env perl
100#-------------------------------------------------------------------------------
101# (C) Crown copyright Met Office. All rights reserved.
102# For further details please refer to the file COPYRIGHT.txt
103# which you should have received as part of this distribution.
104#-------------------------------------------------------------------------------
105
106use strict;
107use warnings;
108
109use FindBin;
110use lib "$FindBin::Bin/../lib";
111
112if (!caller()) {
113    main(@ARGV);
114}
115
116sub main {
117    local(@ARGV) = @_;
118    # ...
119}
120
1211;
122__END__
123
124=head1 NAME
125
126fcm-example
127
128=head1 SYNOPSIS
129
130    fcm-example [OPTIONS] [ARGS]
131
132=head1 OPTIONS
133
134...
135
136=head1 ARGUMENTS
137
138...
139
140=head1 DESCRIPTION
141
142An example boiler plate for an FCM Perl executable.
143
144=head1 DIAGNOSTICS
145
146...
147
148=head1 CONFIGURATION AND ENVIRONMENT
149
150...
151
152=head1 COPYRIGHT
153
154(C) Crown copyright Met Office. All rights reserved.
155
156=cut
157</pre>
158
159  <p>A typical Perl module in FCM looks like:</p>
160  <pre>
161#-------------------------------------------------------------------------------
162# (C) Crown copyright Met Office. All rights reserved.
163# For further details please refer to the file COPYRIGHT.txt
164# which you should have received as part of this distribution.
165#-------------------------------------------------------------------------------
166
167use strict;
168use warnings;
169
170#-------------------------------------------------------------------------------
171package FCM::Example;
172
173# For example...
174sub example {
175    my ($message) = @_;
176    sprintf('E.g. %s.', $message);
177}
178
179#-------------------------------------------------------------------------------
1801;
181__END__
182
183=head1 NAME
184
185FCM::Example
186
187=head1 SYNOPSIS
188
189    use FCM::Example;
190    # ... do something with it
191
192=head1 DESCRIPTION
193
194This class/module does ...
195
196=head1 METHODS
197
198... This section should be renamed FUNCTIONS for non-OO modules.
199
200=head1 DIAGNOSTICS
201
202...
203
204=head1 CONFIGURATION AND ENVIRONMENT
205
206...
207
208=head1 COPYRIGHT
209
210(C) Crown copyright Met Office. All rights reserved.
211
212=cut
213</pre>
214</body>
215</html>
Note: See TracBrowser for help on using the repository browser.