Perl module: Difference between revisions

Content deleted Content added
Schwern (talk | contribs)
m Add some "Further Reading" to POD man pages and CPAN.
Schwern (talk | contribs)
m Add some wiki headers to the examples.
Line 6:
 
The language of Perl is defined by the single implementation (referred to as "perl") and is added to (and in rare occassions taken away from) each new release. For this reason it is important for a module author to be aware what features they're making use of and what the minimum required version of perl is. The code on this page requires perl 5.6.0 which is considered rather old by now.
 
 
== Examples ==
 
What follows is examples of "Hello, World" implemented in different styles of modules. It must be understood that a module is not necessary in Perl, functions and code can be defined and used anywhere, this is just for example purposes. Contrast with Java where a class is always necessary. A real "Hello, World" function would be written like so:
Line 15 ⟶ 18:
 
print "Hello, world!\n";
 
 
=== Procedural Example ===
 
Here is "Hello, World" implemented as a procedural module with a customizable target for the greeting, just to make things interesting.
Line 108 ⟶ 114:
----
 
 
=== Object-Oriented Example ===
 
And now here's an example of the same thing done in an object oriented
style. The advantage of an OO module is each object can be configured
independent of other objects.
 
 
''hello_world.pl''