#!/usr/bin/perl use strict; my $numrgx = qr/^-?[\d.]+(?:e[+-]\d{2})?$/; my @try_these = ( "0.2000000000000001", "0.3000000000000001" ); for ( @try_these ) { my $x = my $y = $_; $y .= "1"; my $same = ( $x eq $y ); if ( ! $same and ( $x =~ /^-?\.?\d/ and $x =~ /$numrgx/ ) and ( $y =~ /^-?\.?\d/ and $y =~ /$numrgx/ )) { $same = ( $x == $y ); } my $cmp = ( $same ) ? "is the same as" : "differs from"; print "$x $cmp $y\n"; }