~ubuntu-branches/ubuntu/trusty/freeguide/trusty

« back to all changes in this revision

Viewing changes to xmltv/share/perl/5.8.8/XMLTV/Version.pm

  • Committer: Bazaar Package Importer
  • Author(s): Shaun Jackman
  • Date: 2007-09-11 16:52:59 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070911165259-4r32oke21i1ezbmv
Tags: 0.10.5-1
* New upstream release.
* Update the watch file.
* Change Debian policy to version 3.7.2.2. No changes necessary.
* Add ant-optional to build dependencies. Closes: #441762.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
=head1 NAME
 
2
 
 
3
XMLTV::Version
 
4
 
 
5
=head1 DESCRIPTION
 
6
 
 
7
Add a --version argument to your program, eg
 
8
 
 
9
  use XMLTV::Version '$Id: Version.pm,v 1.2 2006/11/30 19:13:37 mattiasholmlund Exp $';
 
10
 
 
11
If a --version parameter is supplied on the command-line, it will
 
12
be caught already by the "use" statement, a message will be printed
 
13
to STDOUT and the program will exit.
 
14
 
 
15
It is best to put the use XMLTV::Version statement before other module 
 
16
imports, so that even if they fail --version will still work.
 
17
 
 
18
=head1 SEE ALSO
 
19
 
 
20
L<XMLTV::Options>
 
21
 
 
22
=cut
 
23
 
 
24
package XMLTV::Version;
 
25
 
 
26
my $opt = '--version';
 
27
sub import( $$ ) {
 
28
    die "usage: use $_[0] <version-string>" if @_ != 2;
 
29
    my $seen = 0;
 
30
    foreach (@ARGV) {
 
31
        # This doesn't handle abbreviations in the GNU style.
 
32
        last if $_ eq '--';
 
33
        if ($_ eq $opt) {
 
34
            $seen++ && warn "seen '$opt' twice\n";
 
35
        }
 
36
    }
 
37
    return if not $seen;
 
38
 
 
39
    eval {
 
40
        require XMLTV;
 
41
        print "XMLTV module version $XMLTV::VERSION\n";
 
42
    };
 
43
    print "could not load XMLTV module, xmltv is not properly installed\n"
 
44
      if $@;
 
45
    for ($_[1]) {
 
46
        if (m!\$Id: ([^,]+),v (\S+) ([0-9/: -]+)!) {
 
47
            print "This is $1 version $2, $3\n";
 
48
        }
 
49
        else {
 
50
            print "This program version $_\n";
 
51
        }
 
52
    }
 
53
 
 
54
    exit();
 
55
}
 
56
 
 
57
1;