in reply to result is not listening to if

What did you use as input? The if works correctly: it takes the $result, i.e. the $string repeated $num times, and compares it as a number to 100. So, to get the "Too big" message, you need to enter
101 1

then 101 x 1 is 101 which is greater or equal to 100.

You probably wanted to compare just the $num? Also, don't use double quotes around variables, especially when using numeric comparison or operators:

#!/usr/bin/perl use warnings; use strict; print 'Enter a string '; my $string = <STDIN>; print 'Enter value '; chomp( my $num = <STDIN> ); if ($num >= 100) { print "Too big, bye\n"; } else { my $result = $string x $num; print "The result is:\n$result"; }

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: result is not listening to if
by prospect (Acolyte) on Jul 14, 2017 at 12:30 UTC
    Thank you! I'm going to mess around with your example a bit more.