unit 53 { description 1234-rwan-1; vci x.yy; } unit 54 { description 45ff-rwan-1; vci x.yz; #### # $1 $2 while( $file =~ m/^\s+description\s(\w\w\w\w)(-\w+-\w+);/gm ) { #say $1, $2 if $opt{debug}; # Way to reset $1, $2, etc? my $prefix = $1; my $suffix = $2; my $old_name = $prefix.$suffix; if( $old_name ~~ @old_names ) { # Should only be processing each name once! say "ERROR: Already processed old_name $old_name."; reset; next; #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< NEXT } push @old_names, $old_name; my $new_name = my_rand(); # Update: my_rand now takes care of duplciates my $new_full_name = $new_name.$suffix; say "Replacing $old_name with $new_full_name..." if $opt{verbose}; # $file =~ s/$old_name/$new_full_name/g; reset; } #### Replacing 572l-rwan-1 with 4S1O-rwan-1... Replacing 25hu-rwan-1 with 9L8O-rwan-1... Replacing 51h2-rwan-1 with 2PDZ-rwan-1... #### Replacing 7301-rlab-b3f2 with 8SF6-rlab-b3f2... Replacing 8SF6-rlab-b3f2 with CAB7-rlab-b3f2... Replacing CAB7-rlab-b3f2 with 3X7L-rlab-b3f2...