Babale Fongo wrote:
> 
> Hello guy!

Hello,

> I would like to know why I need to declare global variables with "my".

So that they won't be global.  Using global variables is not bad per se,
however most professional programmers try to avoid using them.


> My script looks something like thing:
> Use strict;
> $strg = "A string";
> $strg2 = "a second string";
> 
> I get a warning:
> "Global symbol require explicit package name."

The warning is telling you to add the package name to the variable which
in this case is probably main.

use strict;
$main::strg  = 'A string';
$main::strg2 = 'a second string';

Which can be shortened to:

use strict;
$::strg  = 'A string';
$::strg2 = 'a second string';


> unless I declare the variables like:
> my $strg = "A string";
> my $strg2 = "a second string";

Perhaps this article may help you understand.

http://perl.plover.com/FAQs/Namespaces.html


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to