Skip to content

Commit

Permalink
Only load YAML and Data::Dumper modules if required.
Browse files Browse the repository at this point in the history
Per complaint from Alvaro Herrera.
  • Loading branch information
adunstan committed Apr 3, 2012
1 parent ff101b8 commit f825e44
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions dumpToc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
=cut

use strict;
use YAML;
use Data::Dumper;
use IO::Handle;
use Getopt::Long;
use File::Path qw(make_path);
Expand Down Expand Up @@ -63,15 +61,29 @@
$inh = IO::Handle->new_from_fd(fileno(STDIN),"r");
}

# load optional output modules
if ($format eq 'YAML')
{
require YAML;
}
elsif ($format eq 'Dumper')
{
require Data::Dumper;
}

# get the actual data
# fills in @$result and @$toc

read_data();

# output the data
if ($format eq 'YAML')
{
print Dump($result);
print YAML::Dump($result);
}
elsif ($format eq 'Dumper')
{
print Dumper($result);
print Data::Dumper::Dumper($result);
}
else
{
Expand Down

0 comments on commit f825e44

Please sign in to comment.