J
jaredsubman
The code I have to do this so far is:
#!/usr/bin/env perl
use strict;
use warnings;
my $string = 'ABCDEFG8IJK2MNOPbRST7VW5YZ';
print "$string\n";
# grab first 5 characters
my $match1=substr($string,0,5);
# grab from the 6th character to the end of the string
my $match2=substr($string,5);
# replace all of the 2nd set of matched chars with asterisks
$match2 =~ tr/[0-9][a-z][A-Z]/*/;
# join both parts
my $new_string = "$match1$match2";
print "$new_string\n";
But surely, there must be a better way to do this, preferably a one-
liner. Any ideas?
Thanks in advance.
#!/usr/bin/env perl
use strict;
use warnings;
my $string = 'ABCDEFG8IJK2MNOPbRST7VW5YZ';
print "$string\n";
# grab first 5 characters
my $match1=substr($string,0,5);
# grab from the 6th character to the end of the string
my $match2=substr($string,5);
# replace all of the 2nd set of matched chars with asterisks
$match2 =~ tr/[0-9][a-z][A-Z]/*/;
# join both parts
my $new_string = "$match1$match2";
print "$new_string\n";
But surely, there must be a better way to do this, preferably a one-
liner. Any ideas?
Thanks in advance.