Uner the same assumption, I prefer a regular expression. The Common module will match any valid number. The /e option will do the subtraction. The /r option returns the result without modifying the original string.
use strict; use warnings; use Regexp::Common; my $NUMBER = qr/$RE{num}{real}/; my @array = ('31:15'); print $array[0] =~ s/($NUMBER):($NUMBER)/$1-$2/er;
In reply to Re^2: Comapring two values of a scalar
by BillKSmith
in thread Comapring two values of a scalar
by bonny
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |