
Borderline
Deleted
Jan 16, 2000, 9:25 PM
Post #2 of 5
(427 views)
|
Hi, The progma strict does several things. 1) Forces you to scope your variable or qualify them with there full package name. 2) Does not allow you to use symbolic references. 3) Does not allow barewords. There are two methods of scoping. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> # The perfered method my $loc = 'dummy'; # or local $loc = 'dummy'; </pre><HR></BLOCKQUOTE> The my operator declares one or more private variables to to exist only within the inner most enclosing block or file. The local operator declares one or more global variables to have localy scoped values within the innermost enclosing block or file. $_, %ENV, @ARGV erc... are all global variables that do not need to be scoped unders strict. In fact you can not scope them using the my operator. This is why it would compile using $_ instead of $loc. $_ is special. The alternative to scoping your variables is to fully qualify them with there pachage name. In this case it would be package main. So you would write all the variables you do not want to scope like this <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> $main::variable</pre><HR></BLOCKQUOTE> or you could declare the variables you want to use as global variables using the vars progma like this <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> use vars '$variable';</pre><HR></BLOCKQUOTE> Hope this helped Scott
|