Acme-Test-Pr0n

 view release on metacpan or  search on metacpan

Pr0n.pm  view on Meta::CPAN

package Acme::Test::Pr0n;

use 5.006;
use strict;
use warnings;
use Carp;

our $VERSION = '0.01';

use vars qw($AUTOLOAD);

sub new {
	 my ($proto,$conf) = @_;
	 my $class = ref($proto) || $proto;
	 my $self = {};
	 bless($self,$class);

	 croak "File not supplied" unless defined $conf->{'filename'};
	 croak "Could not read $conf->{filename}" unless -r $conf->{'filename'};

	 $self->{'filename'} = $conf->{'filename'};

	 # should use IO::File or something
	 local undef $/;
	 open(FH,$self->{'filename'}) or croak("Could not open file $!");
	 $self->{'file'} = <FH>;
	 close(FH);

	 return $self;
}

sub DESTROY{}

sub AUTOLOAD {
	my $self = shift;
	my $flags = shift || undef;
	my $name = $AUTOLOAD;
	$name =~ s/.*://;

	my $clean_string; # store file with all other chars removed
	my $num;

	if($flags && $flags eq 'i') {
 		($clean_string = $self->{'file'}) =~ s/([^$name]+)//gi;
		if($clean_string) {
			$num = ($clean_string =~ s/$name/x/gi);
		}
	} else {
 		($clean_string = $self->{'file'}) =~ s/([^$name]+)//g;
		if($clean_string) {
			$num = ($clean_string =~ s/$name/x/g);
		}
	}

	return 0 unless $num;
	return $num;
}

1;
__END__

=head1 NAME

Acme::Test::Pr0n - Perl extension for wasteing your time.

=head1 SYNOPSIS

  use Test::More tests => 3;
  use Acme::Test::Pr0n;

  my $filename = '/any/old/text/file.txt';

  my $pr0n_test = Acme::Test::Pr0n->new({
    'filename' => $filename,
  });



( run in 1.007 second using v1.01-cache-2.11-cpan-5a3173703d6 )