#!/usr/bin/perl

use Module::CheckDeps qw(checkdeps);

use Getopt::Long;

use warnings;
use strict;

=head1 NAME

checkdeps - Check for code dependencies

=head1 VERSION

version 0.06

=head1 SYNOPSIS

  checkdeps [OPTIONS] file.pl

  Options:
    --format - set output format (optional)

=cut

my $format = "multiline";

my $getopt  = Getopt::Long::GetOptions(
	'format=s'  => \$format
);

my $file = $ARGV[0];

die "Specify a valid file.\n" if !$file;

open SCRIPT, $file or die "$!\n";
my $code = join "", <SCRIPT>;
close SCRIPT;

my $missing = checkdeps($code);

foreach my $module(@$missing) {

	if ($format eq 'oneline') {

		print "$module ";

	} elsif ($format eq 'multiline') {

		print "$module\n";

	}
}

print "\n" if $format eq 'oneline';

=head1 OPTIONS

=over 4

=item B<--format> FORMAT

Specifies the format of the output.
Must be:

=over 8

=item B<oneline>

Print every module in the same line.

=item B<multiline>

Print every module on a different line (default).

=back

=back

=head1 AUTHOR

Alessandro Ghedini, C<< <alexbio at cpan.org> >>

=head1 SEE ALSO

L<scandeps.pl>

=head1 LICENSE AND COPYRIGHT

Copyright 2010 Alessandro Ghedini.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

=cut