Help for this page

Select Code to Download


  1. or download this
    my $n = 534587;
    print "even\n" if($n % 2 == 0);    # modulo operator of possibly a flo
    +at or possibly an integer (*)
    
  2. or download this
    use integer;
    my $n = 534587;
    print "even\n" if($n & 1 == 0);    # checking LSB with Bitwise And on 
    +an integer
    
  3. or download this
    my $n = "534587";
    print "even\n" if($n =~ /[02468]$/);    # reg exp
    
  4. or download this
    my $n = "534587";
    my $c = substr($n, -1, 1);          # last char
    print "even\n" if ( ($c == '0') || ($c == '2') || ($c == '4') || ($c =
    += '6') || ($c == '8') );    # no regexp