http://www.perlmonks.org?node_id=1210509


in reply to regex problem

Taking our anonymous brother's spec literally, here is a solution which produces the actual output he says is desired:

use strict; use warnings; while (my $line = <DATA>) { my ($key, @nums) = split /[\s-]+/, $line; $key =~ s/f$/d/; print "$key $_\n" for @nums; } __DATA__ abcd 723-724 abcde 552-554-553 abcdef 756