CLI/POP3.pm

filter: Statementstmt 50.0% 7 / 14 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 1 / 2 Podpod 100% 1 / 1 totaltotal 34.6% 9 / 26 CC 5 SCAR 32.3
CC
5
Cov
33%
is_open
30.0
BEGIN
1.0
CRAP 25.2
↑ Summary CLI/POP3S.pm »
1 package IO::Socket::CLI::POP3;
2  
3 =head1 NAME
4  
5 IO::Socket::CLI::POP3 - Command-line interface to a POP3 server.
6  
7 =head1 VERSION
8  
9 Version 0.04
10  
11 =head1 SYNOPSIS
12  
13 use IO::Socket::CLI::POP3;
14 my $pop3 = IO::Socket::CLI::POP3->new(HOST => 'pop.mail.yahoo.com');
15 $pop3->read();
16 do {
17 $pop3->prompt();
18 $pop3->read();
19 } while ($pop3->is_open());
20  
21 =head1 DESCRIPTION
22  
23 C<IO::Socket::CLI::POP3> provides a command-line interface to
24 L<IO::Socket::INET6> and L<IO::Socket::SSL>.
25  
26 =for comment
27 =head1 EXPORT
28 None by default.
29  
30 =cut
31  
32 1 ▶use IO::Socket::CLI;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 @ISA = ("IO::Socket::CLI");
34  
35 1 $IO::Socket::CLI::PORT = '110';
36 1 $IO::Socket::CLI::BYE = qr'^\+OK(?: |\r?$)'; # string received when a POP3 server disconnects,
37 # or anything else goes right. hence, is_open() is overridden.
38  
39 =head1 METHODS
40  
41 See C<IO::Socket::CLI>.
42  
43 =head2 is_open()
44  
45 Returns if the server hung up according to the last server response.
46 Override as POP3 gives no special response for closing a connection, so this
47 verifies an C<+OK> response after sending a C<quit> command.
48  
49 =cut
50  
51 sub is_open {
52 0 ▶ my $self = shift;
Subroutine is_open: not called CC=5 SCAR=34.0
Pod documented
53 0 ▶ $self->{_OPEN} = ($self->{_SOCKET}->connected()) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_SOCKET'}->connected ? : 0 0 0
54 0 foreach (@{$self->{_SERVER_RESPONSE}}) {
55 0 ▶ $self->{_OPEN} = 0 if (/$BYE/ && $self->{_COMMAND} =~ /^quit$/i);
Branch: 1 branch
BranchTrueFalseTotal
if /$BYE/ and $self->{"_COMMAND"} =~ /^quit$/i 0 0 0
Condition0%0/3
/$BYE/ and $self->{"_COMMAND"} =~ /^quit$/i
!ll&&!rl&&r
000
MC/DC0%0/2
/$BYE/ and $self->{"_COMMAND"} =~ /^quit$/i
/$BYE/ $self->{"_COMMAND"} =~ /^quit$/i
Truth table0%0/3
A and B
A= /$BYE/B= $self->{"_COMMAND"} =~ /^quit$/i
ABresult
0X0
100
111
56 0 last;
57 }
58 0 return $self->{_OPEN};
59 }
60  
61 =head1 BUGS
62  
63 Does not verify SSL connections. Has not been tried with STARTTLS.
64  
65 =head1 SUPPORT
66  
67 =over 2
68  
69 =item * CPAN Bug Tracker
70  
71 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=IO-Socket-CLI>
72  
73 =item * Code, Pull Requests, alternative Issues Tracker
74  
75 L<https://gitable.org/ashley/IO-Socket-CLI.git>
76  
77 =back
78  
79 =head1 COPYRIGHT AND LICENSE
80  
81 Copyright (C) 2012 by Ashley Willis E<lt>ashleyw@cpan.orgE<gt>
82  
83 This library is free software; you can redistribute it and/or modify
84 it under the same terms as Perl itself, either Perl version 5.12.4 or,
85 at your option, any later version of Perl 5 you may have available.
86  
87 =head1 SEE ALSO
88  
89 L<IO::Socket::CLI>, L<IO::Socket::INET6>, L<IO::Socket::INET>,
90 L<IO::Socket::SSL>, L<IO::Socket>
91  
92 =cut
93  
94 1 1;
↑ Summary CLI/POP3S.pm »