in reply to Re^2: remove lending figures
in thread remove lending figures

tho with 1:00, isn't working

am getting this error Argument "1:00" isn't numeric in numeric gt (>) at HelloWorld.pl line 4.

$string = "1:00"; if (int ($string > 3)) { print "Yes true"; } else { print "Not true"; }

Replies are listed 'Best First'.
Re^4: remove lending figures
by ikegami (Patriarch) on Sep 18, 2025 at 20:10 UTC

    int( $string > 3 ) should be int( $string ) > 3.

    You'll still get the warning unless you turn it off, though.

    my $string = "1:00"; if ( do { no warnings qw( numeric ); int( $string ) } > 3 ) { say ">= 4"; } else { say "< 4"; }

    It would be clearer to use >= 4 than > 3. And if you do that, you don't even need int.

    my $string = "1:00"; if ( do { no warnings qw( numeric ); $string >= 4 } ) { say ">= 4"; } else { say "< 4"; }

      thanks, i appreciate

Re^4: remove leading figures
by LanX (Saint) on Sep 18, 2025 at 20:23 UTC
    > tho with 1:00, isn't working

    Because ":" is not "."

    Use  @digits = split /[:.]/, $string

    And pick what you need

    For anything more complicated, better consider a dedicated DateTime module.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery