develooper Front page | perl.beginners | Postings from April 2002

using strict and -w

Thread Next
From:
Robert "Beau" Link
Date:
April 30, 2002 17:21
Subject:
using strict and -w
Message ID:
02043017271400.13491@coventry.lbch.phaedral.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Howdy,

Thanks to Matt for pointing me in the right direction re: mod_perl.  
Here's my latest:  working through the perl tutorial docs at 
http://www.devshed.com/Server_Side/Perl/Perl101/Perl101_2/page3.html 
I've created the code that follows; typed in from the devshed example, 
sans comments, and with -w and use strict, (neither of which are part 
of the listing in the tutorial.)  Simply using the -w switch the script 
runs fine, but putting in use strict kills it.  The errors I get say: 

Global symbol "$foo" requires explicit package
 name at ./devshedperl.pl line ##

where $foo is each of the variables used in operations and ## is the 
corresponding line number of the operation.  Finally the thing quits, 
saying, "Execution of ./devshedperl.pl aborted due to compilation 
errors."  I am at a loss; what would I need to do to make this run 
under use strict?  And where might I have found that answer within 
perldoc?  I tried > perldoc -q strict and got "No documentation for 
perl FAQ keyword 'strict' found."  All pointers appreciated.

(code follows)

#!/usr/bin/perl -w

use strict;

print "Number, please...";
$alpha = <STDIN>;
print "Another, please...";
$beta = <STDIN>;
$sum= $alpha + $beta;
$diff = $alpha - $beta;
$product = $alpha * $beta;
$quotient = $alpha / $beta;
$remainder = $alpha % $beta;
$exponent = $alpha ** $beta;
#Show it
print "Sum: $sum\nDiference: $diff\nProduct: $product\n";
print "Quotient: $quotient\nRemainder: $remainder\nExponent: 
$exponent\n";

- -- 
beau
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8zzZnbMtNI7KvfxQRAlN+AKC7J6D7tuDtwcRquwH/k15hymLmKwCgvVog
TKm51rx4jb27yF2Z4Ohwp7g=
=cEUb
-----END PGP SIGNATURE-----

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About