in reply to AoA Selective Element Substitution

Your problem is the regex you are using. Firstly, you need to negate the character class as [0-9] is going to match numbers, not the other was round. What you need is [^0-9]. Secondly, you should change the iterator from * (zero or more) to + (one or more). This is because zero or more digits will match at the beginning of the "null" element so you will get a replacement there resulting in "xraynull" and you will also change the "6" in the next array to "xray". Correcting the character class but leaving the iterator ([^0-9]*) will start to do the right thing with "null" but will make a mull of the first element of the next array resulting in "xray6".

Incorporating both changes with [^0-9]+ does the right thing. Refactoring your code to incorporate strictures and create the data structure in one go

use strict; use warnings; use Data::Dumper; my $raStruct = [ [ qw{null 44 4} ], [ qw{6 24 6} ], ]; print Data::Dumper->Dump([$raStruct], [q{raStruct}]); my $test = q{xray}; map { $_->[0] =~ s/[^0-9]+/$test/ } @$raStruct; print Data::Dumper->Dump([$raStruct], [q{raStruct}]);

gives the following output

$raStruct = [ [ 'null', '44', '4' ], [ '6', '24', '6' ] ]; $raStruct = [ [ 'xray', '44', '4' ], [ '6', '24', '6' ] ];

I hope this is of use.

Cheers,

JohnGG