$chars will just contain a list of those you want to expose, everything else is converted to an asterisk or what ever you want. You may want to keep an original as I did with $info. Then use something like $known to expose the letters as desired. Notice, I included a space in the reveal chars to match your example.
I hope this helps :-)
#!/usr/bin/perl -w use strict; my $info = "I am a brown icecube"; my $chars = 'a '; my $known = $info; $known =~ s/[^$chars]/\*/g; print "$info\n"; print "$known\n";
In reply to Re: Re: string matching/replacing
by knexus
in thread string matching/replacing
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |