[OT] Perl woes

Ovid publiustemp-londonpm at yahoo.com
Wed Jan 28 11:23:47 GMT 2009


----- Original Message ----

> From: Jonathan Kimmitt <Jonathan.Kimmitt at csr.com>

>     The next time I use == instead of eq to compare two strings, I
> will know to expect it will always
>     evaluate to true. What other language does this (apart from C,
> which would invariably return false)
> ld be a trivial matter to return an error or warning if ==
> is used for items which aren't numbers

  #!/usr/bin/env perl

  use strict;
  use warnings;

  if ( 3 == "not a number" ) {
      print "Not a number!";
  }

  __END__
  Argument "not a number" isn't numeric in numeric eq (==) at test.pl line 6.

If you want a fatal error instead of a warnings:

  use warnings FATAL => 'numeric';

See 'perldoc perllexwarn' for more info.

Cheers,
Ovid




More information about the london.pm mailing list