Re: variable scope

2010-02-07 Thread Dr.Ruud
Eric wrote: I have a program that requests many config values from an ini file using Config::IniFiles. I import all of these values into my main:: script but it's pretty ugly. Is there a way to import my value definitions int variables in a sub or another module and have them visible in the main

Re: variable scope

2010-02-07 Thread Eric
On Feb 6, 11:01 pm, jeffp...@netzero.net (Jeff Peng) wrote: > 在 2010-02-05五的 06:27 -0800,Eric写道: > > > I have a program that requests many config values from an ini file > > using Config::IniFiles. I import all of these values into my main:: > > script but it's pretty ugly. Is there a way to import

Re: variable scope

2010-02-06 Thread Jeff Peng
在 2010-02-05五的 06:27 -0800,Eric写道: > I have a program that requests many config values from an ini file > using Config::IniFiles. I import all of these values into my main:: > script but it's pretty ugly. Is there a way to import my value > definitions int variables in a sub or another module and h

Re: Variable scope

2007-10-02 Thread Chas. Owens
On 10/2/07, Beginner <[EMAIL PROTECTED]> wrote: snip > > > $| = 1; > > I wasn't aware this only applied to STDOUT. My log messages all > appear at once, when the script has exited and I was hoping for some > 'realtime' messages. snip It applies to stdout because it is the currently selected fileh

Re: Variable scope

2007-10-02 Thread Chas. Owens
On 10/2/07, Bob McConnell <[EMAIL PROTECTED]> wrote: snip > > > > $| = 1; > > > > I wasn't aware this only applied to STDOUT. My log messages all > > appear at once, when the script has exited and I was hoping for some > > 'realtime' messages. > > It used to be possible to turn off buffering on sp

RE: Variable scope

2007-10-02 Thread Bob McConnell
> -Original Message- > From: Beginner [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 02, 2007 10:39 AM > To: perl beginners > Subject: Re: Variable scope > > On 2 Oct 2007 at 15:23, Rob Dixon wrote: > > > > > > > $| = 1; > > I

Re: Variable scope

2007-10-02 Thread Beginner
On 2 Oct 2007 at 15:23, Rob Dixon wrote: > Hi Dermot. You're a little confused, but you're not far out! Your being kind. > > > > $| = 1; I wasn't aware this only applied to STDOUT. My log messages all appear at once, when the script has exited and I was hoping for some 'realtime' messages.

Re: Variable scope

2007-10-02 Thread Tom Phoenix
On 10/2/07, Beginner <[EMAIL PROTECTED]> wrote: > Ideally I want to create the log file outside any sub routines so > that $log to be available to any sub I have created and hence not > scoped to any one sub routine. In other words, $log needs to be a global variable, so that it's available every

Re: Variable scope

2007-10-02 Thread Rob Dixon
Beginner wrote: I thought that the code snip below should work but I am not getting my text into the the file. The file is created but it's empty. Ideally I want to create the log file outside any sub routines so that $log to be available to any sub I have created and hence not scoped to an

RE: Variable scope in wanted function

2004-10-12 Thread Ron Goral
> -Original Message- > From: Jenda Krynicky [mailto:[EMAIL PROTECTED] > Sent: Monday, October 11, 2004 10:39 AM > To: [EMAIL PROTECTED] > Subject: Re: Variable scope in wanted function > > > From: Gunnar Hjalmarsson <[EMAIL PROTECTED]> > > Ron

Re: Variable scope in wanted function

2004-10-11 Thread Gunnar Hjalmarsson
Ron Goral wrote: Gunnar Hjalmarsson wrote: One possible solution is to move the ProcessFile() function out from FindPath(), so the former is no longer a nested sub: sub ProcessFile { my ($a_files, $file_name) = @_; push @$a_files, $File::Find::name if $_ eq $file_name; } and

RE: Variable scope in wanted function

2004-10-11 Thread Ron Goral
> -Original Message- > From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] > Sent: Sunday, October 10, 2004 6:32 PM > To: [EMAIL PROTECTED] > Subject: Re: Variable scope in wanted function > > > Ron Goral wrote: > > I am having some difficulty with a m

Re: Variable scope in wanted function

2004-10-11 Thread Jenda Krynicky
From: Gunnar Hjalmarsson <[EMAIL PROTECTED]> > Ron Goral wrote: > > I am having some difficulty with a module that is using File::Find. > > The method is below. > > > > The idea is to enter this method feeding it a file name and > > beginning directory and then looking for all occasions of > > $fi

Re: Variable scope in wanted function

2004-10-10 Thread Gunnar Hjalmarsson
Ron Goral wrote: I am having some difficulty with a module that is using File::Find. The method is below. The idea is to enter this method feeding it a file name and beginning directory and then looking for all occasions of $file_name and push those addresses into @a_files. This works fine until I

Re: variable scope question

2002-06-20 Thread Felix Geerinckx
on Thu, 20 Jun 2002 12:41:34 GMT, Martin A. Hansen wrote: > i will elaborate the question: > > > i have a huge script with many global variables and subroutines. > > several variable names are reused, but lexically scoped to > subroutines and everything works fine. > > but if you forget (bug

Re: variable scope question

2002-06-20 Thread Peter Scott
At 02:41 PM 6/20/02 +0200, Martin A. Hansen wrote: >i will elaborate the question: > > >i have a huge script with many global variables and subroutines. > >several variable names are reused, but lexically scoped to subroutines >and everything works fine. > >but if you forget (bugs do occur!) to d

Re: variable scope over multiple files

2001-08-10 Thread Brett W. McCoy
On Fri, 10 Aug 2001, Birgit Kellner wrote: > If I have one script that requires another and I want to make the former's > global variables available in the latter, and have use strict NOT complain, > what should I do? Perhaps I should not use "require", but "use"? IMHO, the proper way to do this

RE: Variable scope and definition

2001-07-20 Thread Mooney Christophe-CMOONEY1
er $test/; and then define them later. -Original Message- From: perl newbie [mailto:[EMAIL PROTECTED]] Sent: Friday, July 20, 2001 3:25 PM To: [EMAIL PROTECTED] Subject: Re: Variable scope and definition I am trying to understand the correct way to define variables and their scope. Here

Re: Variable scope and definition

2001-07-20 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 20, perl newbie said: >I am trying to understand the correct way to define >variables and their scope. > >Here are two simple PERL ( test1.pl and test2.pl >)scripts. test1.pl work fine, while test2.pl does not. > >Would appreciate any help in understanding why >test2.pl is complaining abo

Re: Variable scope and definition

2001-07-20 Thread perl newbie
I am trying to understand the correct way to define variables and their scope. Here are two simple PERL ( test1.pl and test2.pl )scripts. test1.pl work fine, while test2.pl does not. Would appreciate any help in understanding why test2.pl is complaining about "Global symbols" Thanks PN test

Re: Variable Scope

2001-07-03 Thread Jeff 'japhy' Pinyan
On Jul 3, Michael Dube said: >I tried scoping the variable to the parent by calling it >parent::$log->write... no luck. > parent::$log->write("Got Here"); Variables are made up of a sigil ($, @, %, &, *), an optional namespace (CGI::, main::, :: (which is main::)), and the symbol name (foo

Re: Variable scope

2001-06-27 Thread Geraint Jones
> I think I see where Geraint is coming from, but a my'd > variable is the only type of variable that is NOT a "global", > using the term as it is used in "official" perl documentation. Must have missed that part - you learn something new every minute with this list ; )

Re: Variable scope

2001-06-26 Thread Me
> > I could not get the following sub to work until > > I had to move $emailLog inside the sub to get this > > to work on the server. > > > > What did I miss or not understand? More on that in a moment. First... > Try putting a "my" (without quotes) before the variable. > What that will do

Re: Variable scope

2001-06-26 Thread Michael Fowler
On Tue, Jun 26, 2001 at 10:08:35AM -0700, Gregg Williams wrote: > When "use strict 'vars'" is in effect and you are using a global variable > (such as $emailLog), Perl will issue a warning alerting you to that > fact--for example: > > Global symbol "$emailLog" requires explicit package name at

RE: Variable scope

2001-06-26 Thread Gregg Williams
so has the effect of documenting your intent to use a global variable to anyone who reads the code. If you have multiple variables you want to declare, separate them by spaces: use vars qw($myScalar @myArray %myHash) --greggw > -Original Message----- > From: Maxim Berlin [mailto:[EMA

Re: Variable scope

2001-06-26 Thread Maxim Berlin
Hello David, Tuesday, June 26, 2001, David Gilden <[EMAIL PROTECTED]> wrote: DG> Quick question, DG> I could not get the following sub to work until DG> I had to move $emailLog inside the sub to get this DG> to work on the server. DG> What did I miss or not understand? i suggest you always

Re: Variable scope

2001-06-26 Thread Geraint Jones
Try putting a "my" (without quotes) before the variable. What that will do is to make it global so any function as well as the main part of your code will be able to access it (then you won't need to put it within sub addEmail). Sometimes though, you want only the function to be able to access a

Re: Variable scope behavior in foreach loop

2001-06-07 Thread Peter Scott
At 01:08 PM 6/7/01 -0400, Robin Lavallee (LMC) wrote: > I have a small conceptual problem. I have been >told that doing: > >my $item; >foreach $item (@arr) { ... } > >is more efficient than: >foreach my $item (@arr) { ... } Even if it is, this is the wrong thing to optimize for. If you'r

Re: Variable scope behavior in foreach loop

2001-06-07 Thread Jeff 'japhy' Pinyan
On Jun 7, Paul said: >--- "Robin Lavallee (LMC)" <[EMAIL PROTECTED]> wrote: >> Then can someone explains why the following code: >> >> #---Begin Code--- >> use strict; >> my $par="50"; >> print "$par\n"; >> >> my @arr = ('first', 'second', 'third'); >> foreach $par (@arr) >> { >> print "$p

Re: Variable scope behavior in foreach loop

2001-06-07 Thread Paul
--- "Robin Lavallee (LMC)" <[EMAIL PROTECTED]> wrote: > Then can someone explains why the following code: > > #---Begin Code--- > use strict; > my $par="50"; > print "$par\n"; > > my @arr = ('first', 'second', 'third'); > foreach $par (@arr) > { > print "$par\n"; > } > print "$par\n"; > #

Re: Variable scope behavior in foreach loop

2001-06-07 Thread Paul
--- "Robin Lavallee (LMC)" <[EMAIL PROTECTED]> wrote: > > Hi, > > I have a small conceptual problem. I have been > told that doing: > > my $item; > foreach $item (@arr) { ... } > > is more efficient than: > foreach my $item (@arr) { ... } > > Because it does not reallocate memory each