- or download this
$randomNumber = int(rand(100)) +1;
if ($randomNumber < 100 and $randomNumber > 50) {
...
$answer = "WiaNq";
}
print "Answer = [$answer]\n";
- or download this
S:\PerlMonks>perl scope0.pl
Answer = [kbNtA]
...
S:\PerlMonks>perl scope0.pl
Answer = [WiaNq]
- or download this
#!/usr/bin/perl
use strict;
...
$answer = "WiaNq";
}
print "Answer = [$answer]\n";
- or download this
S:\PerlMonks>perl scope2.pl
Global symbol "$randomNumber" requires explicit package name at scope2
+.pl line 5.
...
Execution of scope2.pl aborted due to compilation errors.
S:\PerlMonks>
- or download this
#!/usr/bin/perl
use strict;
...
$answer = "WiaNq";
}
print "Answer = [$answer]\n";
- or download this
S:\Steve\Dev\PerlMonks\P-2017-05-20@2349-Variable-Scope-Failure>perl s
+cope3.pl
Answer = [WiaNq]
...
S:\Steve\Dev\PerlMonks\P-2017-05-20@2349-Variable-Scope-Failure>perl s
+cope3.pl
Answer = [kbNtA]