#!/usr/bin/perl -l # https://perlmonks.org/?node_id=1224264 use strict; use warnings; my $line = '
test1 test2 test3 test4'; my @replacements = 'xxx0001' .. 'xxx0100'; $line =~ s/)/ shift @replacements /gie; print $line;