File: Config.pm

package info (click to toggle)
backup-manager 0.7.7-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,284 kB
  • ctags: 202
  • sloc: sh: 3,711; perl: 978; makefile: 220
file content (57 lines) | stat: -rw-r--r-- 824 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
package BackupManager::Config;

=head1 NAME

BackupManager::Config - BackupManager's configuration module

=head1 DESCRIPTION

Basically, it's a Getopt wrapper and a conffile reader.

=cut

use strict;
use warnings;

=head1 FUNCTIONS

=head2 getopt()

Comes from debconf, thanks joeyh ;)

first arg : $usage (text to be written on STDERR if help is needed).

@_ : GetOpt args.

=cut

our $usage;

sub getopt ($@) {
	my ($_usage, @args) = (@_);
	$usage = $_usage;

	my $showusage=sub { # closure
		print STDERR $_usage."\n";
		exit 1;
	};

	# don't load big Getopt::Long unless really necessary.
	return unless grep { $_ =~ /^-/ } @ARGV;
	
	require Getopt::Long;
	Getopt::Long::GetOptions(
		'help|h',	$showusage,
		@args,
	) || $showusage->();
}

=head1 AUTHOR

Alexis Sukrieh <sukria@sukria.net>

=cut

1;