Add the following packages libalgorithm-diff-perl libspiffy-perl libtext-diff-perl...
[pkg-perl] / deb-src / libfilter-perl / libfilter-perl-1.34 / examples / method / NewSubst.pm
1 package NewSubst ;
2  
3 use Filter::Util::Call ;
4 use Carp ;
5  
6 use strict ;
7 use warnings ;
8
9 sub filter
10 {
11     my ($self) = @_ ;
12     my ($status) ;
13  
14     if (($status = filter_read()) > 0) {
15  
16         $self->{Found} = 1
17             if $self->{Found} == 0 and  /$self->{Start}/ ;
18  
19         if ($self->{Found}) {
20             s/$self->{From}/$self->{To}/ ;
21             filter_del() if /$self->{Stop}/ ;
22         }
23  
24     }
25     $status ;
26 }
27  
28 sub import
29 {
30     my ($self, @args) = @_ ;
31     croak("usage: use Subst qw(start stop from to)")
32         unless @args == 4 ;
33  
34     filter_add( { Start => $args[0],
35                   Stop  => $args[1],
36                   From  => $args[2],
37                   To    => $args[3],
38                   Found => 0 }
39               ) ;
40 }
41  
42 1 ;
43