in reply to match-time pattern interpolation

This seems too easy, so it probably means I'm missing some boundary conditions or something??

$number_set = "6 7 8 9 10"; $number_set =~ s/^(\d+\b).*(\b\d+)$/$1-$2/ and print $number_set; 6-10

Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

Replies are listed 'Best First'.
Re: Re: match-time pattern interpolation
by perlguy (Deacon) on Nov 27, 2002 at 20:26 UTC

    Oops. To clarify, the string could contain any number of numbers, some that are subsequent and some that are not.

    For example, $number_set could be "6 7 8 9 10 15 20 21", which after regex substitution would be "6-10 15 20-21".