text: use Scalar::Util(looks_like_number);
  sub comp {
  my ($a, $b) = @_;
  if (looks_like_number($a) && looks_like_number($b)) {
  return ($a == $b);
  }
  else {
  return ($a eq $b);
  }
  }
  [download]
  If your data can contain reals, you might want to think about whether 10.0 == 10.000000000000001, or not.
  when comparing numbers, I tend to avoid using == to go for something like:
  sub equality{
  my ($a, $b, $eps) = @_;
  abs( $a-$b ) < $eps ? return 1: return 0;
  }
  [download]
  where $eps is the desired precision
  Cheers,
  use strict;
  use warnings;
  use Scalar::Util qw(looks_like_number);
  my $x1 = '0x9';
  my $x2 = 0x9;
  my $x3 = '9';
  my $x4 = '9e0';
  my $x5 = 9e0;
  print "1: ", comp($x1, 9), "\n";
  print "2: ", comp($x2, 9), "\n";
  print "3: ", comp($x3, 9), "\n";
  print "4: ", comp($x4, 9), "\n";
  print "5: ", comp($x5, 9), "\n";
  sub comp {
  my ($a, $b) = @_;
  if (looks_like_number($a) && looks_like_number($b)) {
  return ($a == $b);
  }
  else {
  return ($a eq $b);
  }
  }
  __END__
  Outputs:
  1:
  2: 1
  3: 1
  4: 1
  5: 1
  [download]
  my $diff = diff \&reader1,\&reader2;
  [download]
  use strict;
  use warnings;
  use Scalar::Util qw(looks_like_number);
  my $c="11111111111111111e11111111111111111";
  my $d="22222222222222222e22222222222222222";
  if (looks_like_number($c) and
  looks_like_number($d) and
  $c == $d) {
  print "$c = $d\n";
  }
  [download]
  Since noone has mentioned it so far I'd just like to point out that for Perl versions >= 5.9.3 you can use the smart match operator ~~ for this. So for example, the following would work:
  use feature ":5.10";
  my $x=10;
  my $y="10.00";
  say "matches" if ($x ~~ $y);
  [download]
  $string = to_string($string) unless is_string($string);
  (pulled from)
  I am new to this so this is just a thought..
  With this you should be able to get it to at least the same variable type. If both become float types and and you compare 10.0 to 10.00, you should end up with equality... Another though that you can do is set up a tolerance for precision on number comparisons;
  Instead of if a == b
  do if (absolute value of (a - b)) > .0001 then .....
  Just some thoughts. I personally haven't done a lot with Perl yet.
  I'd argue that if you're bothering to mention precision at all, then 10.0 != 10.00.
  10.0 is really "somewhere between 9.95 and 10.05", and 10.00 is really "somewhere between 9.995 and 10.005". So if your 10.0 is really 9.97, it can't possibly be equal to 10.00.
  Is there a maximum precision which any of the numbers will ever be?
  If so, and you want any differences to be noted as you responded to BrowserUk, why not promote all things that look like numbers to some ridiculously high precision using sprintf() and then compare everything based on strings? (edit: fixed this sentence for grammar)
  printf "%1.20f\n", int(10.1) ;
  printf "%1.20f\n", 10 ;
  printf "%1.20f\n", 012 ;
  printf "%1.20f\n", "10" ;
  printf "%1.20f\n", 1e1 ;
  printf "%1.20f\n", 10.100 ;
  printf "%1.20f\n", 10.1 ;
  printf "%1.20f\n", '10.1' ;
  printf "%1.20f\n", 10.1000000000 ;
  printf "%1.20f\n", 10.1000000001 ;
  [download]
  You'll end up with roundoff errors on reals from the precision boost, but for perfectly equivalent values in the first place you should get the same roundoff errors. It's not like you're accumulating the errors through arithmetic with the values, since you're just promoting them and then immediately doing the comparison. The old adage about not testing floats for equality doesn't really apply here, unless you do want to allow a range of difference in the original inputs.
  The main issue with this as I see it is that while you should be okay for a single environment, you'll potentially be dealing with different values for the floats if you try to take the promoted values as output from more than one software environment.
  sub fromp {
  my ( $x, $y, $eps) = @_;
  ( abs( ($y - $x ) / ( $x || $y || return (1) ) ) < $eps );
  }
  [download]
  The chain of ||s ensures that either the divisor is non-zero or division is prevented by returning 1 where both are 0 (therefore equal).
  ^M Free your mind!
  # Begin quoting from <>]) }
  # end quoting...
  sub comp {
  use POSIX qw(strtol);
  my ($a, $b) = @_;
  if (is_numeric($a) && is_numeric($b)) {
  return (strtol($a * 100) == strtol($b * 100));
  } else {
  return ( $a eq 