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