Question about variable scope
- From: nospam <no@xxxxxxxx>
- Date: Tue, 29 Jul 2008 22:54:29 -0400
In the code snippet below, why can't I access the $nntp variable, unless I
instantiate it within the ListGroups() subroutine?
-Thanks
#!/usr/bin/perl -w
#This nntp instance cannot be used in ListGroups()
#sub below:
# $nntp = Net::NNTP->new($newshost);
# $nntp->authinfo($username,$password);
..
..
..
sub ListGroups()
{
#Need to instantiate $nntp here for this to work:
$nntp = Net::NNTP->new($newshost);
$nntp->authinfo($username,$password);
my $groups = $nntp->list() or die "Cannot get group list";
print join("\n", keys %$groups), "\n";
$nntp->quit();
return(0);
}
.
- Follow-Ups:
- Re: Question about variable scope
- From: John W. Krahn
- Re: Question about variable scope
- Prev by Date: Re: Which NNTP module to use?
- Next by Date: Re: what is the expression mean?
- Previous by thread: FAQ 3.8 Is there a pretty-printer (formatter) for Perl?
- Next by thread: Re: Question about variable scope
- Index(es):