Welcome to WebmasterWorld Guest from 3.80.4.76

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Printing largest number of two different ones.

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

Junior Member from PE 

10+ Year Member

joined:Mar 28, 2004
posts: 145
votes: 1



#!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!
4:55 am on Feb 23, 2016 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11822
votes: 236


try using quotes and semicolons on those last two print statements.
7:23 am on Feb 23, 2016 (gmt 0)

Junior Member from PE 

10+ Year Member

joined:Mar 28, 2004
posts: 145
votes: 1


I missed that. Thanks!
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members