Forum Moderators: coopster & phranque

Message Too Old, No Replies

Printing largest number of two different ones.

         

rominosj

1:05 am on Feb 23, 2016 (gmt 0)

10+ Year Member




#!D:/perl/perl/bin/perl.exe
# Script name = exercisechap2.pl

use strict;
use warnings;
use diagnostics;
use CGI::Carp 'fatalsToBrowser';
use CGI qw(-debug);
print "Content-type: text/html\n\n";

my $number1 = 50;
my $number2 = 80;

if ($number1 > $number2)
{print $number1 is greater than $number2}
else
{print $number2 is greater than $number1}


Hello, above is the script I am using to get the largest number between $number1, and $number2. Can someone tell me why I get this error below? I am using 80 as a number with no single or double quotes, but error still says that it is a string, why?

##########
Software error:

Can't use string ("80") as a symbol ref while "strict refs" in use at D:/wamp/www/perl/exercisechap2.pl line 18.
##########

Thanks!

phranque

4:55 am on Feb 23, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



try using quotes and semicolons on those last two print statements.

rominosj

7:23 am on Feb 23, 2016 (gmt 0)

10+ Year Member



I missed that. Thanks!