use strict;
use warnings;
use Test::More;
my @tests = (
{ have => '"654321_1111"', want => '654321_1111' },
);
plan tests => 5 * @tests;
for my $t (@tests) {
is billksmith ($t->{have}), $t->{want}, 'BillKSmith';
is syphilis ($t->{have}), $t->{want}, 'syphilis';
is grandfather ($t->{have}), $t->{want}, 'GrandFather';
is rsfalse ($t->{have}), $t->{want}, 'rsFalse';
is hippo ($t->{have}), $t->{want}, 'hippo';
}
sub billksmith {
my $string = shift;
my $regex = qr/^\"(.+)\"$/;
my ($got) = $string =~ m/$regex/;
return $got;
}
sub syphilis {
my $str = shift;
substr ($str, 0, 1, '');
chop $str;
return $str;
}
sub grandfather {
my $str = shift;
$str =~ s/^"|"$//g;
return $str;
}
sub rsfalse {
my $string = shift;
for (1 .. 2) {
$string = reverse $string;
chop $string;
}
return $string;
}
sub hippo {
my $str = shift;
$str =~ tr/"//d;
return $str;
}
|