Your comments suggest that you are trying to determine whether or not the string in $last is a valid number. Neither of your attempts will do this (Not even with the syntactic corrections already posted). It is not clear what you mean by 'number'. If you mean an unsigned decimal integer, your first try is on the right track. A string is almost certainly an integer if it does not contain any non-digits ("\D").

if($last =~ m/\D/) { ... # Process as a non-integer string else { ... # Process the integer }

For any other definition of 'number', you probably should use a module.

Your error message is almost certainly from an unrelated problem. Fix this much and then post the offending code.

Bill

In reply to Re: unicode string comparison (perl 5.26) by BillKSmith
in thread unicode string comparison (perl 5.26) by md351

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.