You basic code works just fine on Win10 using Active State Perl v5.24.3.
Get to a native Win10 command line and try it.

Update: If you are running some kind of Unix variant under Windows. I would favor using a regex instead of chomp for line ending removal. A regex will always work, not matter which direction you move input files around. $line =~ s/^\s*|\s*$//g removes leading and trailing whitespaces (including any CR or LF characters) and is faster than 2 separate regexes for that purpose.

use strict ; use warnings ; my $numClients ; use Scalar::Util qw(looks_like_number) ; print "How many Clients are you entering?" ; $numClients = <STDIN> ; chomp($numClients) ; if ( !looks_like_number($numClients) ) { print " Your input is NOT a numeric\n" ; exit(1) ; } print "$numClients\n"; __END__ C:\PerlProjects\Monks>perl getposinteger3.pl How many Clients are you entering?0 0 C:\PerlProjects\Monks>perl getposinteger3.pl How many Clients are you entering? -12 -12 C:\PerlProjects\Monks>perl getposinteger3.pl How many Clients are you entering? 0005 0005 C:\PerlProjects\Monks>perl getposinteger3.pl How many Clients are you entering?14.3 14.3
I would code a loop like this as below.....
It loops until a valid number is entered instead of aborting.
Instead of "looks like a number" which allows fractions and exponentials, the code below looks for a non-zero positive integer although leading zeroes are allowed.
In this scenario, parens around the print statement are required to get the print to happen "in the middle" of the while statement. Try with and without the parens to see what I mean.
use strict; use warnings; my $numClients; while ( (print "Enter Number of Clients: "), $numClients=<STDIN>, $numClients !~ /^\s*(?:[0]*)?[1-9]\d*\s*$/) { print "Your input is NOT a positive integer!\n"; } $numClients += 0; #optional conversion to numeric print "Number of Clients: $numClients\n"; __END__ C:\PerlProjects\Monks>perl getposinteger2.pl Enter Number of Clients: 5 Number of Clients: 5 C:\PerlProjects\Monks>perl getposinteger2.pl Enter Number of Clients: -23 Your input is NOT a positive integer! Enter Number of Clients: 2 3 Your input is NOT a positive integer! Enter Number of Clients: 14.3 Your input is NOT a positive integer! Enter Number of Clients: -12 23 Your input is NOT a positive integer! Enter Number of Clients: 5 Number of Clients: 5 C:\PerlProjects\Monks>perl getposinteger2.pl Enter Number of Clients: 00003 Number of Clients: 3
You can add extra error checking like this:
use strict; use warnings; my $numClients; while ( (print "Enter Number of Clients: "), $numClients=<STDIN>, $numClients !~ /^\s*(?:[0]*)?[1-9]\d*\s*$/ or $numClients >=1 +00) { print "Your input is NOT a positive integer less than 100!\n"; } $numClients += 0; #optional conversion to numerio print "Number of Clients: $numClients\n"; __END__ C:\PerlProjects\Monks>perl getposinteger2.pl Enter Number of Clients: 123 Your input is NOT a positive integer less than 100! Enter Number of Clients: 5 Number of Clients: 5

In reply to Re: not working in Win10 by Marshall
in thread not working in Win10 by Boschman

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.