in reply to Re: unicode string comparison (perl 5.26)
in thread unicode string comparison (perl 5.26)

A string is almost certainly an integer if it does not contain any non-digits ("\D").

Almost:

>perl -e 'for ("1", "22", "abc", "1e4", "0xABCD", "") { /\D/ or print +"\"$_\" is an integer\n" }' "1" is an integer "22" is an integer "" is an integer >

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^3: unicode string comparison (perl 5.26)
by BillKSmith (Monsignor) on Nov 02, 2019 at 18:52 UTC
    I intentionally ignored unlikely exceptions such as a null string or any 'integer' which cannot be represented exactly in perl's floating point format.
    Bill