You could use a constant instead. -- code --
use strict; use constant INDEX => 5; # I'm assuming $i refers to an index. Use more descriptive variable names... print ("Value of index" . INDEX . "\n"); INDEX = 6; -- end code -- Run that and you will get the following error. Can't modify constant item in scalar assignment at test.pl line 6, near "6;" Execution of test.pl aborted due to compilation errors. Remove that line and it will work. HTH John -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 28 January 2002 16:03 To: [EMAIL PROTECTED] Subject: How to prevent redefining a variable with use strict? Friends, When we use strict pragma, is there a way to "prevent" redefining a variable? use strict; my ($i) = 5; # $i defined print ("Val of i = $i"); my ($i) = 6; # $i redefined?Could this be tagged as an error? print ("Val of i = $i"); Thanks, Rex --------------------------Confidentiality--------------------------. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]