in reply to extract numbers from unformatted text strings
use strict; use warnings; my $min = 1000000; my $max = 0; while (<DATA>) { m/(\d+)\D+(\d+)/; $min = $1 if $1 < $min; $max = $2 if $2 > $max; } print "$min-$max"; __DATA__ 6-7 1 - 5 3 to 24 6 thru 9 2 through 11
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: extract numbers from unformatted text strings
by fishbot_v2 (Chaplain) on May 23, 2005 at 17:54 UTC |