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
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
在 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
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
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
> -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
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.
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
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
> -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
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
> -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
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
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
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
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
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
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
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
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
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
> 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 ; )
> > 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
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
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
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
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
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
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
--- "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";
> #
--- "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
31 matches
Mail list logo