/BackupManager/Config.pm
Perl | 57 lines | 35 code | 20 blank | 2 comment | 2 complexity | a5906daeb542675ba14472dfabbec100 MD5 | raw file
Possible License(s): GPL-2.0
1#!/usr/bin/perl 2package BackupManager::Config; 3 4=head1 NAME 5 6BackupManager::Config - BackupManager's configuration module 7 8=head1 DESCRIPTION 9 10Basically, it's a Getopt wrapper and a conffile reader. 11 12=cut 13 14use strict; 15use warnings; 16 17=head1 FUNCTIONS 18 19=head2 getopt() 20 21Comes from debconf, thanks joeyh ;) 22 23first arg : $usage (text to be written on STDERR if help is needed). 24 25@_ : GetOpt args. 26 27=cut 28 29our $usage; 30 31sub getopt ($@) { 32 my ($_usage, @args) = (@_); 33 $usage = $_usage; 34 35 my $showusage=sub { # closure 36 print STDERR $_usage."\n"; 37 exit 1; 38 }; 39 40 # don't load big Getopt::Long unless really necessary. 41 return unless grep { $_ =~ /^-/ } @ARGV; 42 43 require Getopt::Long; 44 Getopt::Long::GetOptions( 45 'help|h', $showusage, 46 @args, 47 ) || $showusage->(); 48} 49 50=head1 AUTHOR 51 52Alexis Sukrieh <sukria@sukria.net> 53 54=cut 55 561; 57