Sophie

Sophie

distrib > Fedora > 20 > x86_64 > by-pkgid > 68e3acea3a506395f00115630ac5653d > files > 27

perl-Filter-1.50-1.fc20.x86_64.rpm

package
  Count ;
 
use Filter::Util::Call ;

use strict ;
use warnings ;
 
sub import
{
    my ($self) = @_ ;
    my ($count) = 0 ;
    filter_add(
	sub 
	{
    	    my ($status) ;
	 
    	    if (($status = filter_read()) > 0 ) {
        	    s/Joe/Jim/g ;
        	    ++ $count ;
    	    }
    	    elsif ($count >= 0) { # EOF
        	$_ = "print q[Made $count substitutions\n] ;" ;
        	$status = 1 ;
		$count = -1 ;
    		}
 
    	    $status ;
	}) 
}
 
1 ;