winampctl.pl untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 50 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/perl
2 #
3 # Author: Murat Uenalan (muenalan@cpan.org)
4 #
5 # Copyright (c) 2002 Murat Uenalan. All rights reserved.
6 # Note: This program is free software; you can redistribute
7 # it and/or modify it under the same terms as Perl itself.
8
9 our $VERSION = '0.2.1';
10
11 use warnings; use strict;
12
13 ## Parse options and print usage if there is a syntax error,
14 ## or if usage was explicitly requested.
15
16 use Getopt::Long;
17
18 use Pod::Usage;
19
20 our %opts = ( host => 'localhost', port => 4800, passwd => undef );
21
22 GetOptions (\%opts, 'help|?', 'man', 'debug!', 'port=i', 'host=s', 'passwd=s' ) or pod2usage(2);
23
24 pod2usage(1) if $opts{help};
25
26 #pod2usage( -verbose => 2 ) if $opts{man};
27
28 qx{perldoc Winamp::Control} if $opts{man};
29
30 ##
31 ##
32
33 use Winamp::Control;
34
35 my $winamp = Winamp::Control->new( host => $opts{host}, port => $opts{port}, port => $opts{passwd} );
36
37 if( my $ver = $winamp->getversion )
38 {
39 printf "\nConnected to Winamp (Ver: %s)\n", $ver;
40
41 print "Current playlist:\n\t", join "\n\t", $winamp->getplaylisttitle(), "\n";
42
43 printf "\nCurrently playing: %s\n", $winamp->getcurrenttitle() if $winamp->isplaying();
44
45 print "File entry:\n\t", $winamp->getplaylistfile( a => $winamp->getlistpos ), "\n";
46
47 my $com = shift @ARGV;
48
49 print "Returned ($com): " , $winamp->$com( ), "\n" if $com;
50 }
51 else
52 {
53 warn 'Unable to connect to winamp/httpQ';
54 }
55
56 __END__