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

variable scope

2010-02-06 Thread 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 have them visible in the main:: scope as loc

Re: problem with variable scope

2007-10-22 Thread Jenda Krynicky
From: "Siva Prasad" <[EMAIL PROTECTED]> > while(<$FILE_H>) > > { > > next unless /()/; > > my @Rows=grep(/()/,<$FILE_H>); > > return(@Rows); use HTML::TableExtract; Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed t

Re: problem with variable scope

2007-10-22 Thread Tom Phoenix
On 10/22/07, Siva Prasad <[EMAIL PROTECTED]> wrote something resembling: > sub GET_Values > { > my $Rows; > my $cate; What are those variables used for? > my $self=shift; > print "$self->{InputFile}\n"; > (open my $FILE_H '<', $self->{InputFile}) || die"cannot open the input > file"; > while(<$F

RE: problem with variable scope

2007-10-22 Thread Siva Prasad
Hi Gurus, I got the mistake which I was doing. Thanks a lot PP. _ From: Siva Prasad [mailto:[EMAIL PROTECTED] Sent: Monday, October 22, 2007 8:01 PM To: 'beginners@perl.org' Subject: problem with variable scope Hi Gurus, I have written a packag

Re: problem with variable scope

2007-10-22 Thread Jeff Pang
On 10/22/07, Siva Prasad <[EMAIL PROTECTED]> wrote: > > while(<$FILE_H>) > > { > > next unless /()/; > > my @Rows=grep(/()/,<$FILE_H>); > > return(@Rows); > > close $FILE_H; > > } > Well,the first error I have noticed,you have lost a "}" in the code above. Have you run `perl -c parseSite.pm` befor

problem with variable scope

2007-10-22 Thread Siva Prasad
Hi Gurus, I have written a package as below. __PACKAGE package parseSite; use strict; use warnings; sub new { my $class = shift; my $Input_file=shift;

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

Variable scope

2007-10-02 Thread Beginner
Hi, 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 any one sub routi

Re: comparing and contrasing two approaches to variable scope

2006-05-03 Thread Paul Johnson
On Wed, May 03, 2006 at 09:17:21AM -0500, Rance Hall wrote: > Assuming you had a script configuration variable that was used numerous > places in your script, further assume that you have "use strict;" in > your perl script. > > You could declare the variable "my" and pass that variable to any

comparing and contrasing two approaches to variable scope

2006-05-03 Thread Rance Hall
Assuming you had a script configuration variable that was used numerous places in your script, further assume that you have "use strict;" in your perl script. You could declare the variable "my" and pass that variable to any subroutines that needed it with @_. Or you could declare that varia

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

Variable scope in wanted function

2004-10-10 Thread Ron Goral
Greetings All - 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

RE: Help with Variable Scope, Regular Expressions

2004-04-15 Thread Charles K. Clarkson
William Martell <[EMAIL PROTECTED]> wrote: : : Hi Charles. Thank you very much for the code and the lesson. : Works perfectly! It wasn't meant to be a finished product. Just an example to learn from. You need to, at least, add some error checking, but I am glad it works. :) : I am trying t

RE: Help with Variable Scope, Regular Expressions

2004-04-15 Thread William Martell
Hi Charles. Thank you very much for the code and the lesson. Works perfectly! I am trying to add the address portion to this but I am still having some trouble. I wanted to see if I could ask you questions regarding your code for even more insight. Thanks in advance for your time and consider

RE: Help with Variable Scope, Regular Expressions

2004-04-08 Thread Charles K. Clarkson
William Martell <[EMAIL PROTECTED]> wrote: NOTE: This response is long. If you want to ask a question be responsible and delete anything that is not relevant to your question. Do NOT top post and repeat the entire messa

Re: Help with Variable Scope, Regular Expressions

2004-04-08 Thread William Martell
099","location: Casa View ","paper: The Dallas Morning News","date: 04/04/2004", [/RESULT] My desired result is this, (I want to be able to import this data into excel) [DESIRED] price: beds: bath: phone: address: location: paper: date: data, data, data, data, d

RE: Help with Variable Scope, Regular Expressions

2004-04-08 Thread Charles K. Clarkson
William Martell <[EMAIL PROTECTED]> wrote: : : I am trying to get this code to write the variables in : a specific order, even if they are undefined or blank. : I would like each row seperated by newline. What is a row? What specific order? : I am running into a problem with the scope of the

RE: Help with Variable Scope, Regular Expressions

2004-04-08 Thread Jayakumar Rajagopal
n - indicates you are sorting on the field [ that comes after ] 'n' th "," -- sorry for typo. -Original Message- From: Jayakumar Rajagopal Sent: Thursday, April 08, 2004 2:31 PM To: William Martell; [EMAIL PROTECTED] Subject: RE: Help

RE: Help with Variable Scope, Regular Expressions

2004-04-08 Thread Jayakumar Rajagopal
u are sorrting on the field 'n' th "," . thanks, Jay -Original Message- From: William Martell [mailto:[EMAIL PROTECTED] Sent: Thursday, April 08, 2004 1:15 PM To: [EMAIL PROTECTED] Subject: Help with Variable Scope, Regular Expressions Hello All. Thank you for rea

Help with Variable Scope, Regular Expressions

2004-04-08 Thread William Martell
Hello All. Thank you for reading my email :) I am trying to get this code to write the variables in a specific order, even if they are undefined or blank. I would like each row seperated by newline. I am running into a problem with the scope of the variable being limited to the block of code it

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

variable scope over multiple files

2001-08-10 Thread Birgit Kellner
I am using a script to manage flatfile databases which consists of several perl files: a central perl script contains all subroutines for data manipulation, another script prints out html code, and a configuration file sets all global variables like for instance $db_script_path for the directo

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

Variable Scope

2001-07-03 Thread Michael Dube
Ok... can someone give me a clue about the issue of variable scoping? I have a program that uses a logging module (Log::LogLite), and so I have an object $log that has a ->write method. I have a few custom packages that I wrote that I want to be able to also write to the logfile. What is the syn

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

Variable scope

2001-06-26 Thread David Gilden
Quick question, 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? Thanks Dave ## not seen by the sub, $emailLog = 'logs/email_log'; # Send E-Mail &send_mail; # Append email lo

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

Variable scope behavior in foreach loop

2001-06-07 Thread Robin Lavallee (LMC)
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 time. This means that the scope of $item in the second example is actually a