in reply to Strange saving behaviour

Warning: untested as for speed vs. your regex (though it's faster if you put it inline, since it's so simple =), but here's a sub one could use to test for 'integrality':

sub is_int { my $num = shift; $num == int($num); }

Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Replies are listed 'Best First'.
Re: Re: Strange saving behaviour
by ChOas (Curate) on Feb 01, 2001 at 19:37 UTC
    Hi!

    I should keep my mouth shut, but wouldn't that return 'true'
    for every number above 1 ?..

    I believe 'int' returns the integer part...

    is_int(6.66) would return 6... and not check if it's an int

    Sorry if I'm totally on the wrong track here...

    GreetZ!,
      ChOas

    print "profeth still\n" if /bird|devil/;

      I think you may have misread it: that's an equality test in the last line, not an assignment =)

      It returns the value of the last statement in the sub, i.e, the value of

      $num == int($num);

      Which is true (== 1) if $num and the integer part of $num are equal to each other, and false (==0)otherwise.

      Philosophy can be made out of anything. Or less -- Jerry A. Fodor

        *duck*...

        Totally right.. I missed the 2nd '=' there... SO sorry...

        GreetZ!,
          ChOas

        print "profeth still\n" if /bird|devil/;

      Umm... no. It works as advertised.

      is_int(6.66) returns the result of 6.66 == int(6.66) which is the same as 6.66 == 6 which is false.

      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me