use strict; while(1) { print "please enter a guess from 1 to 100: "; chomp(my $guess = <STDIN>); if ($guess =~ /quit|exit|^s*$/i) { print " sorry you gave up.the number was $secret.\n"; last; } elsif ($guess < $secret) { no strict; print "you failed \n"; } }
- but why?
Just leave it enabled. In normal coding you always want to have it; in fact, there are only few situations where some strictness must be disabled, such as hacking perl internals. As the strict documentation states, it is a "pragma to restrict unsafe constructs" - and it is always better to be on the safe side.
BTW, had you indented your code properly, you would have seen that you missed the last right curly... ;)
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: how to enable, disable strict
by shmem
in thread how to enable, disable strict
by elsiddik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |