Mega Code Archive

 
Categories / Perl / Language Basics
 

Using the strict Pragma

#A pragma is a module that triggers a compiler to behave in a certain way.  #The strict pragma can be used to prevent the use of global variables in a program.  #The 'our' built-in is used when you need a global variable but still want to use the strict pragma use strict "vars"; my $name = "Tom";               # my (lexical) variables are okay @friends = qw(Tom A B C);       # global variables not allowed local $newspaper = "The Globe"; # local variables are not allowed print "My name is $name and our friends are @friends.\n";