What does the command "use strict" do and why should you
use it?

Answer Posted / savitha sridhar

strict is a pragma that can be used to enforce Strict
programming practices while you write your programs.

Eg: You can write a program like this:

$x=100
print $x

But if you use strict pragma, then you have to be very
specific while using variables

use strict;
my $x=100; ##look at the usage of scope like my,local,our
print $x;

Pragma usage can also be used as a toggle

use strict;
my $x=100;
print $x;
no strict; # to toggle strict to "No"
$y=200; ##no need to use scope as strict is disabled
print $y;

Is This Answer Correct ?    17 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is use of ‘->’ symbol?

539


Elaborate on perl bite-wise operators.

524


How to read from a pipeline with Perl

549


What is the function of virtual documents in cgi programs?

528


How can you call a subroutine and identify a subroutine?

506






Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.

636


What are numeric operators in perl?

544


What are the various uses of perl?

530


What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)

545


What is the use of -w, -t and strict in Perl?

567


Can we load binary extension dynamically?

581


What does the qx{ } operator do?

509


How to create a package?

526


Explain the meaning of perl one-liner?

514


what is the function of Return Value?

568