1d8bbbb0f52750fa5df297bbda47fa05f390eb9c
[pkg-perl] / deb-src / libfilter-perl / libfilter-perl-1.34 / examples / method / UUdecode.pm
1
2 package Filter::UUdecode ;
3
4 use Filter::Util::Call ;
5
6 use strict ;
7 use warnings ;
8
9 my $VERSION = '1.00' ;
10
11 sub import
12 {
13     my($self) = @_ ;
14     my ($count) = 0 ;
15
16     filter_add( \$count ) ;
17 }
18
19 sub filter
20 {
21     my ($self) = @_ ;
22     my ($status) ;
23
24     while (1) {
25
26         return $status 
27             if ($status = filter_read() ) <= 0;
28
29         chomp ;
30         ++ $$self ;
31
32         # Skip the begin line (if it is there)
33         ($_ = ''), next if $$self == 1 and /^begin/ ;
34
35         # is this the last line?
36         if ($_ eq " " or length $_ <= 1) {
37             $_ = '' ;
38             # If there is an end line, skip it too
39             return $status
40                 if ($status = filter_read() ) <= 0 ;
41             $_ = "\n" if /^end/ ;
42             filter_del() ;
43             return 1 ;
44         }
45
46         # uudecode the line
47         $_ = unpack("u", $_) ;
48
49         # return the uudecoded data
50         return $status ;
51     }
52 }
53
54 1 ;