CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [sdebeaubien] Unix - Thread issue?: Edit Log



FishMonger
Veteran / Moderator

Dec 16, 2009, 4:40 PM


Views: 1299
Re: [sdebeaubien] Unix - Thread issue?


Quote
When I made them all into basically just declarations, then set them explicitly elsewhere, that seemed to do the trick.


That's because you ended up declaring them in a parent scope. Vars declared with the my keyword are accessible within their enclosing block, not outside of that block.

It's a very good bet that you're not using the strict pragma, which would have given you a compilation error message.

If you want to show us your before and after code, we can give you a more detailed explanation.

For example:

Code
#!/usr/bin/perl 

use strict;
use warnings;

{
# this var is not accessable outside of this block
my $name = 'FishMonger';
}

print $name;

That code will generate this compilation error:

Quote
Global symbol "$name" requires explicit package name at ...


You probably should read this: http://search.cpan.org/~dapm/perl-5.10.1/pod/perlfunc.pod#my


(This post was edited by FishMonger on Dec 16, 2009, 4:44 PM)


Edit Log:
Post edited by FishMonger (Veteran) on Dec 16, 2009, 4:44 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives