in reply to numbers with chainable comparisons
my $op = qr/[!=<>]+/; sub dechain { my @terms; while ($_[0] =~ /(.+?)($op)(?=((?:(?!$op).)+))/g) { push @terms, join '', $1, $2, $3; } join ' and ', @terms; } print dechain('3 < 4 < 5'), "\n"; print dechain('$x < $y <= $z'), "\n";
|
---|