wrote:
) 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?
To keep most in line with your program:
substr($string, 5) =~ tr/[0-9][a-z][A-Z]/*/;
You see, you can use the result of subsrt as an lvalue.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT