Re: Scope

2006-10-02 Thread Chad Perrin
On Mon, Oct 02, 2006 at 07:15:38AM -0700, Derek B. Smith wrote: > > For a complete understanding of scope (not listerine) > : ) > please read the following: > http://perl.plover.com/local.html#2_Localized_Filehandles > > and > http://www.perlmonks.org/?node_id=564448 > > Wow...opened my eyes and

RE: Scope

2006-10-02 Thread Derek B. Smith
-- "Charles K. Clarkson" <[EMAIL PROTECTED]> wrote: > John Ackley wrote: > > > : while( ($service) = $SERVICE->fetchrow_array ) { > > According to the DBI docs: > >"If there are no more rows or if an error occurs, > then fetchrow_array returns an empty list." > > When a value

RE: Scope

2006-10-01 Thread Charles K. Clarkson
John Ackley wrote: : while( ($service) = $SERVICE->fetchrow_array ) { According to the DBI docs: "If there are no more rows or if an error occurs, then fetchrow_array returns an empty list." When a value is returned, $service is set to that value. When we get to the end of the l

Re: scope of the variable?

2006-02-03 Thread Bob Showalter
[EMAIL PROTECTED] wrote: ... My question is how to access $dbaccess variable (object) defined and initialized in test.pm within test2.pm module? If $dbaccess is delared with 'my' in test.pm, you cannot directly access it from another file. You have two basic options: 1. Provide an accessor

Re: scope of the variable?

2006-02-03 Thread Jeff Pang
I think the '$dbaccess' in your test.pm should be declared as perl's global var as 'our $dbaccess;' or 'use vars qw($dbaccess);'. Then in your test2.pm,you can access it as: use vars qw($dbaccess); print $test::dbaccess; or: use vars qw($dbaccess); *dbaccess = \$test::dbaccess; print $dbacces

Re: Scope

2005-08-14 Thread John Doe
tmatsumoto am Samstag, 13. August 2005 19.06: > Hi, > > Thanks for the help. I've made the necessary changes. One error came up > at runtime on the "use warnings;". I gather the module is not installed > on the server I'm using. Strange; the pragma module warnings.pm is AFAIK part of the core per

Re: Scope

2005-08-13 Thread tmatsumoto
Hi, Thanks for the help. I've made the necessary changes. One error came up at runtime on the "use warnings;". I gather the module is not installed on the server I'm using. I've gone through and made changes to the script calling the package. I understand the syntax however the nothing is

Re: Scope

2005-08-13 Thread John Doe
tmatsumoto am Samstag, 13. August 2005 11.13: > Hi Beginners, Hello, > I a new Perl programmer dealing with issues of scope. I'm trying to > write a simple library using strict. The script that runs the library > is also strict. I can get the two to work without using strict, but I > understand t

RE: scope of variable carrying 'for ($n1..$n2){}'

2003-07-23 Thread Ed Christian
> -Original Message- > From: West, William M [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 23, 2003 9:21 AM > To: [EMAIL PROTECTED] > Subject: scope of variable carrying 'for ($n1..$n2){}' > > > for (1..19){ > for (1..19){ > print $_ > }} > > prints out the numbers 1 to 19 nin

Re: scope of perlvars?

2002-07-18 Thread Jeff 'japhy' Pinyan
On Jul 18, Nikola Janceski said: >I was wondering what the scope of perlvars (ie. $! and $?) are across >modules? Those variables are true globals. They are seen everwhere. >In module: >open file || return -1; > >In script: >Can I use $! here? and will it contain the reason open didn't open (i

Re: Scope of my() declared variables

2002-04-17 Thread A. Arnstein
At 12:47 PM 4/17/2002 -0700, you wrote: >On Wednesday, April 10, 2002, at 04:42 , Elaine -HFB- Ashton wrote: ^ is this supposed to be funny? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional command

Re: Scope of my() declared variables

2002-04-17 Thread drieux
On Wednesday, April 10, 2002, at 04:42 , Elaine -HFB- Ashton wrote: > I always found the local, my, our mess pretty confusing and the best > explanation is MJD's "Coping with Scoping" > > http://perl.plover.com/FAQs/Namespaces.html > > Make good note of the text in red :) ok, I get the followin

Re: Scope of my() declared variables WAS( Re: -e $filename...)

2002-04-14 Thread Jenda Krynicky
From: Ahmed Moustafa <[EMAIL PROTECTED]> > Elaine -Hfb- Ashton wrote: > > I always found the local, my, our mess pretty confusing and the best > > explanation is MJD's "Coping with Scoping" > > > > http://perl.plover.com/FAQs/Namespaces.html > > > > Make good note of the text in red :) > > Elai

Re: Scope of my() declared variables WAS( Re: -e $filename...)

2002-04-13 Thread drieux
On Saturday, April 13, 2002, at 04:45 , Ahmed Moustafa wrote: > Elaine -Hfb- Ashton wrote: >> I always found the local, my, our mess pretty confusing and the best >> explanation is MJD's "Coping with Scoping" >> http://perl.plover.com/FAQs/Namespaces.html >> Make good note of the text in red :)

Re: Scope of my() declared variables WAS( Re: -e $filename...)

2002-04-13 Thread Ahmed Moustafa
Elaine -Hfb- Ashton wrote: > I always found the local, my, our mess pretty confusing and the best > explanation is MJD's "Coping with Scoping" > > http://perl.plover.com/FAQs/Namespaces.html > > Make good note of the text in red :) Elaine, thanks a lot for MJD's article. There is a great differ

Re: Scope of my() declared variables WAS( Re: -e $filename...)

2002-04-10 Thread Elaine -HFB- Ashton
Timothy Johnson [[EMAIL PROTECTED]] quoth: *> *>Here's the part I still don't understand, and maybe some of you can show me *>the light. What is the difference between local() and my()? I have never *>used local(), the only examples I've ever been given involve scoping $_, and *>if I am ever tem

RE: Scope of my() declared variables WAS( Re: -e $filename...)

2002-04-10 Thread David Gray
> Here's the part I still don't understand, and maybe some of > you can show me the light. What is the difference between > local() and my()? I have never used local(), the only > examples I've ever been given involve scoping $_, and if I am > ever tempted to do that, I can usually trace it

Re: Scope of variables. Lost in subs

2002-04-09 Thread drieux
On Tuesday, April 9, 2002, at 11:13 , Jenda Krynicky wrote: [..] > So if a module defines several classes it has to contain several > packages. > > Jenda yes I think I would modify that slightly it is simpler to deliver one long file as a singular 'package' that carries with

RE: Scope of variables. Lost in subs

2002-04-09 Thread Jeff 'japhy' Pinyan
On Apr 9, Gary Hawkins said: >> From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] >> >> Perhaps you're missing the point. > >Gee, maybe that was the reason for the question. Ya think? Why do you >hammer people for asking questions, that's what this place is for. I wasn't. I was saying that

RE: Scope of variables. Lost in subs

2002-04-09 Thread Gary Hawkins
> -Original Message- > From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, April 09, 2002 11:58 AM > To: Gary Hawkins > Cc: [EMAIL PROTECTED] > Subject: RE: Scope of variables. Lost in subs > > Perhaps you're missing the point.

RE: Scope of variables. Lost in subs

2002-04-09 Thread Jeff 'japhy' Pinyan
On Apr 9, Gary Hawkins said: >I was thinking there might be an instance where 'package bar' is >essential, or the best way to go. Perhaps you're missing the point. The package directive allows you to change namespaces. Your Perl program operates in package 'main'. Most modules operate in thei

RE: Scope of variables. Lost in subs

2002-04-09 Thread Jenda Krynicky
From: "Gary Hawkins" <[EMAIL PROTECTED]> > > > How many "things" can packages be? Is this foo a file? > > > > No this "foo" doesn't have to be a file. You can "have" several > > packages in one file and "switch" between them. > > > > I don't know how to explain what ARE packages though. > > Try

RE: Scope of variables. Lost in subs

2002-04-09 Thread Gary Hawkins
> > How many "things" can packages be? Is this foo a file? > > No this "foo" doesn't have to be a file. You can "have" several > packages in one file and "switch" between them. > > I don't know how to explain what ARE packages though. > Try if > perldoc perlmod > makes sense to you. After

RE: Scope of variables. Lost in subs

2002-04-09 Thread Jenda Krynicky
From: "Gary Hawkins" <[EMAIL PROTECTED]> > > #!perl -w > > my $x = 'Ahoj'; > > print "$x\n"; > > package foo; > > print "$x\n"; > > __END__ > > > > I believe packages are completely irrelevant to lexical (declared > > with my()) variables. > > > > I was following it up un

RE: Scope of variables. Lost in subs

2002-04-09 Thread Gary Hawkins
> > > If you declare a variable with my() its scope will be from the > > > declaration to the end of the enclosing block. Which for variables > > > declared outside any {} block or eval"" means ... to the end of the > > > file. > > > > > > > Wrong. > > > > You forgot about 'package'. > > What do y

Re: Scope of variables. Lost in subs

2002-04-08 Thread Tor Hildrum
Thanks to everyone who replied. I got enough information to solve the problem, and then some more :) Tor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Scope of variables. Lost in subs

2002-04-08 Thread Jenda Krynicky
From: "Jonathan E. Paton" <[EMAIL PROTECTED]> > Jonathan... nul point - my Eurovision song contest > attempt would be less than that though. Yes, Jenda is > right, and I'm wrong (again). Oh well, I do remember > reading that. A it feels so god to be right ;-) And well ... I used to sin

RE: Scope of variables. Lost in subs

2002-04-08 Thread Jonathan E. Paton
--- Jenda Krynicky <[EMAIL PROTECTED]> wrote: > From: "Jonathan E. Paton" <[EMAIL PROTECTED]> > > > > It loses > > > > scope in subroutines. > > > > > > Wrong. > > > > > > If you declare a variable with my() its scope will be from the > > > declaration to the end of the enclosing block. Whic

RE: Scope of variables. Lost in subs

2002-04-08 Thread Timothy Johnson
Yep. I guess I'm still a little groggy. I think this whole "Spring Forward" thing is a bit of a misnomer. -Original Message- From: drieux [mailto:[EMAIL PROTECTED]] Sent: Monday, April 08, 2002 8:07 AM To: [EMAIL PROTECTED] Subject: Re: Scope of variables. Lost in su

RE: Scope of variables. Lost in subs

2002-04-08 Thread Timothy Johnson
Oops. My bad. I wonder how much extra work that one's cost me... -Original Message- From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] Sent: Monday, April 08, 2002 8:49 AM To: Timothy Johnson Cc: [EMAIL PROTECTED] Subject: RE: Scope of variables. Lost in subs From: "Timot

RE: Scope of variables. Lost in subs

2002-04-08 Thread Jenda Krynicky
From: "Jonathan E. Paton" <[EMAIL PROTECTED]> > > > It loses > > > scope in subroutines. > > > > Wrong. > > > > If you declare a variable with my() its scope will be from the > > declaration to the end of the enclosing block. Which for variables > > declared outside any {} block or eval"" mea

RE: Scope of variables. Lost in subs

2002-04-08 Thread Jonathan E. Paton
> > It loses > > scope in subroutines. > > Wrong. > > If you declare a variable with my() its scope will be from the > declaration to the end of the enclosing block. Which for variables > declared outside any {} block or eval"" means ... to the end of the > file. > Wrong. You forgot abo

RE: Scope of variables. Lost in subs

2002-04-08 Thread Jenda Krynicky
From: "Timothy Johnson" <[EMAIL PROTECTED]> > Another thing to remember is that declaring a variable with my() at > the top of your script does NOT make the variable global. Right. > It loses > scope in subroutines. Wrong. If you declare a variable with my() its scope will be from the decl

Re: Scope of variables. Lost in subs

2002-04-08 Thread drieux
On Monday, April 8, 2002, at 07:28 , Timothy Johnson wrote: [..] > If you just pass the value, > then any operations performed on your variable in the subroutine will be > destroyed when the sub exits. This way you will be performing all > operations on the original variable, allowing you to cha

RE: Scope of variables. Lost in subs

2002-04-08 Thread Timothy Johnson
$var PrintSub(\$var); #@_ now contains (\$var) print "\$var is now $var.\n"; sub PrintSub{ my $subvar = ${$_[0]); #dereference the reference you passed. print "\$subvar is now $subvar.\n"; } -Original Message- From: zentara To: [EMAIL PROTECTED] Sent: 4/8/02

Re: Scope of variables. Lost in subs

2002-04-08 Thread zentara
On Mon, 08 Apr 2002 11:00:54 +0200, [EMAIL PROTECTED] (Tor Hildrum) wrote: >On 8/4/02 9:15, "Tor Hildrum" <[EMAIL PROTECTED]> wrote: > >> Here are some of the error messages I get: >> Use of uninitialized value in concatenation (.) at script.cgi line 55. >> Use of uninitialized value in concatena

Re: Scope of variables. Lost in subs

2002-04-08 Thread Tor Hildrum
On 8/4/02 9:15, "Tor Hildrum" <[EMAIL PROTECTED]> wrote: > Here are some of the error messages I get: > Use of uninitialized value in concatenation (.) at script.cgi line 55. > Use of uninitialized value in concatenation (.) at script.cgi line 55. > Can't open : No such file or directory Full so

Re: Scope, priority or bug?

2001-08-10 Thread Ivan Adzhubei
Hello Bob, > I think the answer can be found in the following statement in the persub > manpage > under the heading "Private Variables via (my)": Yes, I read this (sorry for typing error, perlsub should be cited in my initial message instead of perlvar). Unfortunately, the following passage

Re: Scope, priority or bug?

2001-08-10 Thread Ivan Adzhubei
Hello Jos, "Jos I. Boumans" wrote: > > let's see if i can shed some light on this. > > your statement: > print("Defined: <<$z>>\n") if defined(my $z="x"); > > this will be evaluated like this if i'm not mistaken: > ( print("Defined: <<$z>>\n") ) && defined(my $z="x"); > > or a simplistic

RE: Scope, priority or bug?

2001-08-10 Thread Bob Showalter
> -Original Message- > From: Ivan Adzhubei [mailto:[EMAIL PROTECTED]] > Sent: Friday, August 10, 2001 7:24 AM > To: [EMAIL PROTECTED] > Subject: Scope, priority or bug? > > > Hi! > > Isn't this weird? > > #!/usr/bin/perl -w > print("Defined: <<$z>>\n") if defined(my $z="x"); > print "A

Re: Scope, priority or bug?

2001-08-10 Thread Jos I. Boumans
let's see if i can shed some light on this. your statement: print("Defined: <<$z>>\n") if defined(my $z="x"); this will be evaluated like this if i'm not mistaken: ( print("Defined: <<$z>>\n") ) && defined(my $z="x"); or a simplistic version: (print $z) && (my $z = 'bar'); try and 'use strict'

Re: scope

2001-06-19 Thread Me
> If I define a function just in the freespace of a file and have included in > that file two packages which are bracketed in like: > > sub function {} > > package 1; > {} > > package 2; > {} > > > > How do I access the function (make a function call) from within one of the > packages? > > is it m