John Constable wrote:
> This email is subject to the disclaimer set out below
> *****************************************************
>
> Hi Guys,
>
> first of all, I hope I'm posting to the right list, if not, my apologies
> (while I'm apologising, let me apologise for my company disclaimer, which I
> cant change..:-).
>
> Its a basic perl question, but I'm a relative newbie, so bear with me if the
> answer is obvious..
> I'm running a for loop that compares two variables. if one if bigger than
> the other, it gets made the new "big" variable, until the array is
> exhausted.. the problem is, perl seems to be treating the numbers rather
> weird.."11" for example, seems to be treated as "1", so is less than most
> numbers etc...
>
> I've posted the code below, can you tell me what I'm doing wrong?
>
> $check = 0;
> $biggest = 0;
>
> for $check (@results) {
> if ($check gt $biggest) {
Try a numerical comparison:
if ($check > $biggest) {
> $biggest = $check;
> }
> }
> print "Largest Die roll is $biggest\n";
>
> and the array (in this case) was:
> @results = (
> '7',
> '7',
> '5',
> '11'
> );
>
> my printing output gives me:
> Largest Die roll is 7
> 11 5 7 7
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs