in reply to AoA Selective Element Substitution
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
|
|---|