More About Importing

Recall that each module has a default list of functions and variables to import. Some modules import many functions by default, others import none. Most import some.

Modules that have a lot of functions and variables to import frequently put them into groups. Groups can be specified using the ":group" syntax.

For example, the CGI::Pretty module has a group called ":standard", which imports a bunch of standard functions for creating HTML pages.
  
  #!/usr/bin/perl
  # file: html.pl
  
  use strict;
  use CGI::Pretty qw(:standard);

  print h1('This is a level one header');
  print p('This is a paragraph.');
  print p('Here is some',i('italicized'),'text.');

  % html.pl 
<h1>
	This is a level one header
</h1>
<p>
	This is a paragraph.
</p>
<p>
	Here is some <i>italicized</i> text.
</p>
  

The module's documentation will tell you what function groups are defined. To import the default functions, plus optional ones, use the group ":DEFAULT".

  use CGI::Pretty qw(:DEFAULT :standard start_html);


<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Wed Oct 27 11:01:00 EDT 2004