Quoth Peter Scott <>:
> On Thu, 11 Sep 2008 15:16:08 +0100, Ben Morrow wrote:
> > I would put the numbers to be matched in a hash:
> >
> > my %ok;
> > @ok{@a} = 1;
> >
> > and then split the string and match against the hash:
> >
> > my @split = split /\D/;
> > for (@split) {
> > $_ = "XX" unless $ok{$_};
> > }
> > $_ = join ",", @split;
>
> Not all of the inter-digit characters in the input string were commas.
I noticed that, but the OP mentioned split /,/ so I presumed they were
typos. If not, something like
my @split = split /(\D+)/;
for (@split) {
/\D/ and next;
$_ = "XX" unless $ok{$_};
}
$_ = join "", @split;
should do.
Ben
--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
The Levellers, 'Believers'