badbanana has asked for the wisdom of the Perl Monks concerning the following question:
Global symbol "$x" requires explicit package name (did you forget to declare "my $x"?) at ./two.pl line 6.
Global symbol "$y" requires explicit package name (did you forget to declare "my $y"?) at ./two.pl line 7.
Global symbol "$x" requires explicit package name (did you forget to declare "my $x"?) at ./two.pl line 10.
Global symbol "$y" requires explicit package name (did you forget to declare "my $y"?) at ./two.pl line 13.
Global symbol "$x" requires explicit package name (did you forget to declare "my $x"?) at ./two.pl line 15.
Global symbol "$y" requires explicit package name (did you forget to declare "my $y"?) at ./two.pl line 15.
Execution of ./two.pl aborted due to compilation errors.
and this is file 2:#!/usr/bin/perl use warnings; use strict; $a=0; chomp($a=<STDIN>); print $a, "\n";
i can't seem to figure out what's causing the errors for file 2. the declaration is the same in both files.#!/usr/bin/perl use warnings; use strict; $x=0; $y=0; print "enter first number "; chomp($x=<STDIN>); print "enter second number "; chomp($y=<STDIN>); print "Product ",$x*$y, "\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: question on declaring variables
by toolic (Bishop) on Nov 22, 2018 at 12:03 UTC | |
by badbanana (Novice) on Nov 22, 2018 at 12:15 UTC |