Re: How do I properly use global variables?

2007-10-23 Thread Matthew Whipple
Jeff Pang wrote: > On 10/23/07, monk <[EMAIL PROTECTED]> wrote: > >> I'm having problems accessing a variable outside its subroutine. >> I've tried several combinations too long to write here. Maybe I just >> can't see the forest for the trees. But I'm lost. I need your >> wisdom. >> >> I'd li

Re: How do I properly use global variables?

2007-10-23 Thread Jeff Pang
On 10/23/07, monk <[EMAIL PROTECTED]> wrote: > I'm having problems accessing a variable outside its subroutine. > I've tried several combinations too long to write here. Maybe I just > can't see the forest for the trees. But I'm lost. I need your > wisdom. > > I'd like my program below to change

Re: How do I properly use global variables?

2007-10-23 Thread Rob Coops
You might want to try the following call your script twice with the start argument, then look at the processes running (just send the output of the script to /dev/null or something like that for ease of use) You will see the script running twice, this is because you started the Perl interpreter t

How do I properly use global variables?

2007-10-23 Thread monk
I'm having problems accessing a variable outside its subroutine. I've tried several combinations too long to write here. Maybe I just can't see the forest for the trees. But I'm lost. I need your wisdom. I'd like my program below to change $status to zero to exit the loop. meaning...$> perl tes

Re: global variables

2006-01-11 Thread David Gama Rodrí­guez
David Gama Rodrí­guez wrote: Tom Phoenix wrote: On 1/10/06, David Gama Rodrí­guez <[EMAIL PROTECTED]> wrote: I made a module that loads when Apache starts, in my module I declare a hash as a global in order to be accesed in any place in my module, my $hash; Not to be picky about t

Re: global variables

2006-01-10 Thread Tom Phoenix
On 1/10/06, David Gama Rodrí­guez <[EMAIL PROTECTED]> wrote: > I made a module that loads when Apache starts, in my module I declare a > hash as a global in order to be accesed in any place in my module, > > my $hash; Not to be picky about terminology, but a "my" variable is a lexical variable, n

Re: global variables

2006-01-10 Thread vmalik
I think that a fresh new copy of the module is loaded into memory everytime it is called. That's why your module loses its value. If I want to do something like that, I'd consider storing the value on the hard drive somewhere. Vishal Quoting David Gama Rodrí­guez <[EMAIL PROTECTED]>: > Hello ev

global variables

2006-01-10 Thread David Gama Rodrí­guez
Hello everyone !! I'm really a newbie developing perl modules. I have and issue I made a module that loads when Apache starts, in my module I declare a hash as a global in order to be accesed in any place in my module, my $hash; sub x{ $foo = shift; .. .. $hash->{x} = $foo; } sub

Local and global variables

2005-06-28 Thread Andrew Black
Can someone explain the difference between use vars qw/$defined_by_vars/ ; our $defined_by_our ; $not_explicily_defined = 1 ; Are these all global to the package they are defined it. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Global variables / special variables / variable identifier with just one character

2004-10-08 Thread Bee
"Adam" <[EMAIL PROTECTED]> 在郵件 news:[EMAIL PROTECTED] 中撰寫... > Expected error message: "Global symbol "$b" requires explicit package name". > However, I get result: "test". > I've checked the special variables and it looks like $b is one of these. > > use warnings; > use strict; > zzz ($b); > prin

Re: Global variables / special variables / variable identifier with just one character

2004-10-08 Thread Steve Bertrand
> Expected error message: "Global symbol "$b" requires explicit package > name". > However, I get result: "test". > I've checked the special variables and it looks like $b is one of > these. > > use warnings; > use strict; > zzz ($b); > print "$b\n"; > sub zzz{ > $_[0] = "test"; > } > > Does it

Global variables / special variables / variable identifier with just one character

2004-10-08 Thread Adam
Expected error message: "Global symbol "$b" requires explicit package name". However, I get result: "test". I've checked the special variables and it looks like $b is one of these. use warnings; use strict; zzz ($b); print "$b\n"; sub zzz{ $_[0] = "test"; } Does it mean - that in general - we

Re: use strict, global variables, modules

2003-09-04 Thread John W. Krahn
Emil Perhinschi wrote: > > Hi! Hello, > I'm writing a rather complicated script, reading bibtex (my code) and > xml (XML::Grove) files etc. > > I have to "use strict" and "my $variable" in order to keep references in > check, as there are lo

use strict, global variables, modules

2003-09-04 Thread Emil Perhinschi
Hi! I'm writing a rather complicated script, reading bibtex (my code) and xml (XML::Grove) files etc. I have to "use strict" and "my $variable" in order to keep references in check, as there are lots of them. I want to define some "global" variables in the

Re: Global variables and a forked process

2003-08-14 Thread Paul Archer
Yesterday, Wiggins d'Anconia wrote: > Yes and no. There are multiple different implementations of threads all > of which have some good and bad points. You will need to look more into > them depending on your version of Perl and how complex the task is that > you wish to accomplish. (There is also

Re: Global variables and a forked process

2003-08-14 Thread wiggins
On Mon, 11 Aug 2003 08:11:07 -0500 (CDT), Paul Archer <[EMAIL PROTECTED]> wrote: > Yesterday, Wiggins d'Anconia wrote: > > > Yes and no. There are multiple different implementations of threads all > > of which have some good and bad points. You wi

Global variables and a forked process

2003-08-14 Thread Ahmed Moustafa
Does a forked process share the memory locations of the global variables from the parent process? Thanks in advance! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Global variables and a forked process

2003-08-14 Thread Ahmed Moustafa
Steve Grazzini wrote: On Sat, Aug 09, 2003 at 01:04:26PM -0700, Ahmed Moustafa wrote: Does a forked process share the memory locations of the global variables from the parent process? Changes made after the fork() won't be visible in the other process, if that's what you're

Re: Global variables and a forked process

2003-08-11 Thread Steve Grazzini
On Sat, Aug 09, 2003 at 01:04:26PM -0700, Ahmed Moustafa wrote: > Does a forked process share the memory locations of the global > variables from the parent process? Changes made after the fork() won't be visible in the other process, if that's what you're wonderin

Re: Global variables and a forked process

2003-08-11 Thread Wiggins d'Anconia
. So, is there a way to assign values to the global variables in the parent process? No. You'd need to switch to threads or keep the fork and use some kind of IPC. % perldoc perlipc Are there threads in Perl? Yes and no. There are multiple different implementations of threads all of whi

Re: Global variables and a forked process

2003-08-10 Thread Ahmed Moustafa
assign values to the global variables in the parent process? No. You'd need to switch to threads or keep the fork and use some kind of IPC. % perldoc perlipc Are there threads in Perl? What is your application doing? It scans FTP home directories, once it finds a file, it validates

Re: Global variables and a forked process

2003-08-10 Thread Steve Grazzini
On Sat, Aug 09, 2003 at 05:14:34PM -0700, Ahmed Moustafa wrote: > Steve Grazzini wrote: >> Changes made after the fork() won't be visible in the other >> process, if that's what you're wondering. > > Yes, that's exactly what I am wondering. So, is the

RE: HOWTO:Dynamically getting all of the global variables and their v alues

2003-07-01 Thread Charles K. Clarkson
Ken Lehman <[EMAIL PROTECTED]> wrote: : : I would like to write a function that will get : all the global variables that are declared in : my script plus their values( which will all : be strings if that matters). This is what I : have so far: : : my ( $varName, $globValue ); : :

RE: HOWTO:Dynamically getting all of the global variables and their v alues

2003-07-01 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Ken Lehman wrote: > I would like to write a function that will get all the global > variables that are declared in my script plus their values( which > will all be strings if that matters). This is what I have so far: > Why use global variables when you could use a hash which

HOWTO:Dynamically getting all of the global variables and their v alues

2003-07-01 Thread Ken Lehman
I would like to write a function that will get all the global variables that are declared in my script plus their values( which will all be strings if that matters). This is what I have so far: my ( $varName, $globValue ); while ( ($varName, $globValue) = each %main:: ) { print "\$$va

Re: How bad is it to use global variables?

2003-01-23 Thread Rob Dixon
Nils-Anders Persson wrote: > Hello, > > I've seen many discussions regarding the use of "use strict". > > What i wonder is why is it so bad using global variables? > It's not. It's bad to use global variables /all the time/, even if you don't nee

RE: How bad is it to use global variables?

2003-01-23 Thread wiggins
On Thu, 23 Jan 2003 08:52:01 -0500, "Kipp, James" <[EMAIL PROTECTED]> wrote: there is a article called > "coping with scoping" you might want to read. I don't have the URl handy, > but a google search will find it. > I keep it handy: http://per

RE: How bad is it to use global variables?

2003-01-23 Thread wiggins
Just 'use' it. :-) > > What i wonder is why is it so bad using global variables? > Memory usage, modularity, debugging, are three good reasons. > And another question how do you define constants in perl? > use constant CONSTANT_NAME => 5; perldoc constant (f

RE: How bad is it to use global variables?

2003-01-23 Thread Kipp, James
> > I've seen many discussions regarding the use of "use strict". > > What i wonder is why is it so bad using global variables? > > And another question how do you define constants in perl? > use strict does not disallow global variables, it simply enforc

How bad is it to use global variables?

2003-01-23 Thread Nils-Anders Persson
Hello, I've seen many discussions regarding the use of "use strict". What i wonder is why is it so bad using global variables? And another question how do you define constants in perl? regards, Nils-Anders -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,

Re: Global variables

2002-08-21 Thread Connie Chan
uot; <[EMAIL PROTECTED]> Sent: Wednesday, August 21, 2002 6:34 AM Subject: Global variables > What would be the preferred method of creating global variables that can be > used in several different cgi scripts. For example, I'd like to create the > variables $database, $use

Re: Global variables

2002-08-20 Thread david
#-- prints db print $DBString::user,"\n"; #-- prints user print $DBString::psw,"\n"; #- -prints psw for more info, check out perldoc david Dan Fish wrote: > What would be the preferred method of creating global variables that can > be > used in several different cgi scrip

Global variables

2002-08-20 Thread Dan Fish
What would be the preferred method of creating global variables that can be used in several different cgi scripts. For example, I'd like to create the variables $database, $user, $pass that I only have to change in one place, but can use in many different scripts. In C of course I'

Re: Global variables in forked processes

2002-05-10 Thread drieux
On Friday, May 10, 2002, at 09:20 , Chas Owens wrote: [..] > In many operating systems fork is implemented using copy-on-write. This > means that when you fork both processes refer to the same memory > locations until one of them tries to change the bytes stored there. At > that time the change

Re: Global variables in forked processes

2002-05-10 Thread Chas Owens
On Fri, 2002-05-10 at 00:12, Ahmed Moustafa wrote: > Thanks a lot. I understand that. > > I was thinking that variable 'x' of a forked process 'p2' would point at > the same memory location of variable 'x' of a parent process 'p1'. That > can't be true. If that was true, 'p1' and 'p2' would be

Re: Global variables in forked processes

2002-05-09 Thread Ahmed Moustafa
Thanks a lot. I understand that. I was thinking that variable 'x' of a forked process 'p2' would point at the same memory location of variable 'x' of a parent process 'p1'. That can't be true. If that was true, 'p1' and 'p2' would be identitcal (no need to fork!). -- Ahmed Moustafa http://po

Re: Global Variables: 'my' vs 'use vars'

2002-03-28 Thread Chas Owens
On Thu, 2002-03-28 at 14:55, [EMAIL PROTECTED] wrote: > Hello, All: > > I've never been very good at scoping so it it's no surprise that this > confuses me: > > When declaring variables at the beginning of a script, what is the > difference between 'my' and 'use vars'? > > -- > Eric P. >

Global Variables: 'my' vs 'use vars'

2002-03-28 Thread eric-perl
Hello, All: I've never been very good at scoping so it it's no surprise that this confuses me: When declaring variables at the beginning of a script, what is the difference between 'my' and 'use vars'? -- Eric P. Los Gatos, CA -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additiona

Re: [Q]Setting global variables.

2002-02-22 Thread Jonathan E. Paton
> Perl Gurus, > > How can I set global variables in perl.? I'm trying > to do something like.. The logic is broken, I believe this is more appropriate: my $myvar = param("myvar"); unless ($myvar) { # Show form } else { # Pro

[Q]Setting global variables.

2002-02-22 Thread Bhanu Prakash
Perl Gurus, How can I set global variables in perl.? I'm trying to do something like.. if(param()) { my $myvar=param("myvar"); if(param("myvar2"){ use $myvar here.. Has some script to show a form.. } else { On submitting the form, user enters here.. someother use of

Re: Defining Global Variables w/use strict;

2001-11-08 Thread Jeff 'japhy' Pinyan
On Nov 8, Arul, Rex said: >Import is redundant because, whenever you say, "use Defaults" it is akin >to a directive. Yes, use Module; becomes BEGIN { require Module; Module->import; } but we weren't use()ing the file. The bigger problem is that I called the import method from

[Fwd: Re: Defining Global Variables w/use strict;]

2001-11-08 Thread Arul, Rex
Jeff , Import is redundant because, whenever you say, "use Defaults" it is akin to a directive. So what it does implicitly is to invoke the "import" method of the module named "Defaults" . So when you say, "use strict;" or "use warnings;" , implicitly the "import" method of those modules are

Re: Defining Global Variables w/use strict;

2001-11-08 Thread Jeff 'japhy' Pinyan
On Nov 8, Peter Scott said: >> use DBI; >> use strict; >> require "defs.pl"; >> >> print "Welcome to $DOMAIN, $ADMIN\n"; > >Global symbol $DOMAIN requires explicit package name... Oops, that require() should have been inside a BEGIN { } block. >> package Defaults; >> require Exporte

Re: Defining Global Variables w/use strict;

2001-11-08 Thread Peter Scott
At 11:06 AM 11/8/01 -0500, Jeff 'japhy' Pinyan wrote: >On Nov 8, Tomasi, Chuck said: > > >I have a series of related programs that need global definitions ($DOMAIN, > >$ADMIN, $DBNAME, etc). My code looks something like this: > >Global variables aren't

Global Variables and use strict;

2001-11-08 Thread Tomasi, Chuck
ould be cumbersome if the variable list gets long, and could cause conflicts between exported package variables (globals) and locals of the same name. --or-- Reference the package (global) variables as $pkgname::variable, typing a little more, but avoiding abmiguity. I've used these from oth

Re: Defining Global Variables w/use strict;

2001-11-08 Thread Jeff 'japhy' Pinyan
On Nov 8, Tomasi, Chuck said: >I have a series of related programs that need global definitions ($DOMAIN, >$ADMIN, $DBNAME, etc). My code looks something like this: Global variables aren't declared with my(). It sounds like you want to use the Exporter module. Your base program

RE: Defining Global Variables w/use strict;

2001-11-08 Thread Tomasi, Chuck
als I should have learned years ago. Thanks. > -Original Message- > From: dan radom [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 08, 2001 9:50 AM > To: '[EMAIL PROTECTED]' > Subject: Re: Defining Global Variables w/use strict; > > > just a thou

Re: Defining Global Variables w/use strict;

2001-11-08 Thread Jos I. Boumans
ovember 08, 2001 4:45 PM Subject: Defining Global Variables w/use strict; > System: Sun Ultra 2, Solaris 7 (11/99) > Perl: 5.6.0 > > I have a series of related programs that need global definitions ($DOMAIN, > $ADMIN, $DBNAME, etc). My code looks something like this: > >

Re: Defining Global Variables w/use strict;

2001-11-08 Thread Etienne Marcotte
He want's to take then in his global variables list.. where $DOMAIN is plexus.com and ADMIN is Chuck Etienne dan radom wrote: > > just a thought, but how can you print a variable that hasn't been defined yet? > > dan > > * Tomasi, Chuck ([EMAIL PROTECTED]) wr

Re: Defining Global Variables w/use strict;

2001-11-08 Thread Etienne Marcotte
> -- > #!/usr/local/bin/perl -w > > use strict; > use DBI; > > require "defs.pl"; > > print "Welcome to $DOMAIN, $ADMIN\n"; > -- #!/usr/local/bin/perl -w use strict; use DBI; use defs; print "Welcome to defs::$DOMAIN, defs::$ADMIN\n"; --

Re: Defining Global Variables w/use strict;

2001-11-08 Thread dan radom
just a thought, but how can you print a variable that hasn't been defined yet? dan * Tomasi, Chuck ([EMAIL PROTECTED]) wrote: > System: Sun Ultra 2, Solaris 7 (11/99) > Perl: 5.6.0 > > I have a series of related programs that need global definitions ($DOMAIN, > $ADMIN, $DBNAME, etc). My code l

Defining Global Variables w/use strict;

2001-11-08 Thread Tomasi, Chuck
System: Sun Ultra 2, Solaris 7 (11/99) Perl: 5.6.0 I have a series of related programs that need global definitions ($DOMAIN, $ADMIN, $DBNAME, etc). My code looks something like this: -- #!/usr/local/bin/perl -w use strict; use DBI; require "defs.pl"; print "Welcome t

Re: using global variables in other files

2001-10-22 Thread Martin
Transform your pl file in a package and then use use to get variables, or qualify the full name : $modname:varname. define this variables global in modul or export the vars . take a look on Exporter Modul hope it helps martin ÷ÁÓÉÌØÞÅÎËÏ îÁÔÁÌØÑ áÎÁÔÏÌØÅ×ÎÁ wrote: > Hello, all! > > I have som

using global variables in other files

2001-10-19 Thread Васильченко Наталья Анатольевна
Hello, all! I have some variables defined in file $user_ip = $ENV{'REMOTE_ADDR'}; $user_name = $ENV{'AUTH_USER'}; . Now I want to use these values in other files. unless ($user_ip =~ /^10\./)... # #etc. What should I do? use 'require userinfo.pl;' or use 'package' or some

'global' variables

2001-09-27 Thread Martijn van Exel
Hi all, I stuff all subroutines for my current perl experiment in a separate file, which i 'require' when needed. I would like to set a number of global variables in this file, which would then be imported together with the subroutines. How would I go about doing this? -- martij

Re: global variables

2001-09-24 Thread _brian_d_foy
In article <001201c144fb$4a1ba3d0$ec00a8c0@boxx>, [EMAIL PROTECTED] (Sascha Kersken) wrote: > Perl 5.6 provides the 'our' statement as opposite to 'my': it makes a > variable global to a file in which it's used. it declares a package variable, actually. if you aren't in its package, then you h

Re: global variables

2001-09-24 Thread _brian_d_foy
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Ruth Albocher) wrote: > I would like to use a global variable in my perl application, but since > everything in perl is in a package, it will always belong to some > package. what can I do? stay away from global variables. :

Re: global variables

2001-09-24 Thread Sascha Kersken
Hi! Perl 5.6 provides the 'our' statement as opposite to 'my': it makes a variable global to a file in which it's used. HTH Sascha - Original Message - From: "Ruth Albocher" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, Septe

global variables

2001-09-24 Thread Ruth Albocher
Hi. I would like to use a global variable in my perl application, but since everything in perl is in a package, it will always belong to some package. what can I do? thanks, ruthie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: global variables in subroutines..?

2001-07-18 Thread Brett W. McCoy
{ my (@failedFields); > my ($validForm)="1"; > > #validate job selection > if (!$job) { > $job="job "; > push (@failedFields, $job); > > } > > my question is, I remember someone a while bac

global variables in subroutines..?

2001-07-18 Thread Stephanie Stiavetti
e job selection if (!$job) { $job="job "; push (@failedFields, $job); } my question is, I remember someone a while back mentioning that you should NOT redefine global variables in your subroutines... what can I do as

Re: Inheritance of package global variables

2001-06-29 Thread Michael Fowler
On Fri, Jun 29, 2001 at 12:14:23AM -0400, Richard J. Barbalace wrote: > I don't really want to export the variables; I'm not modifying them in > the parent package, just copying and expanding them in the inheriting > package. Well then, you are copying and modifying as simply as it can be done.

Re: Inheritance of package global variables

2001-06-28 Thread Me
> [inherited attributes] > [get/set accessor methods] > [regex validation of set] > [better way?] I'm not sure about there being a *better* way, but I'm sure there are a lot of *other* ways. Various thoughts... Perl has the concept of tied data items. The basic operations on those data items, l

Re: Inheritance of package global variables

2001-06-28 Thread Richard J. Barbalace
Michael Fowler <[EMAIL PROTECTED]> replies: > Exporting is usually a bad idea when dealing with classes, it breaks > encapsulation. You should probably setup a class method for this. > > That being said, you can export variables just like you export any other > data type, with Exporter; perldoc

Re: Inheritance of package global variables

2001-06-28 Thread Michael Fowler
MyPackage is > rather verbose, and I'm wondering if there is a better or terser way > of doing that. What's the recommended way of inheriting package > global variables? Exporting is usually a bad idea when dealing with classes, it breaks encapsulation. You should probably setu

Inheritance of package global variables

2001-06-28 Thread Richard J. Barbalace
Hi. I feel like I'm asking a lot of questions lately, but this list has been extremely helpful. :) I'm writing some packages that inherit from a base class, which has some fields and some global variables that I want inherited. I have code like: # La/De/Da/MyBase.pm pack

Re: Global Variables Question

2001-04-25 Thread Paul
ire config.pl; > > use vars ($G_ROOTPATH); > # at this point, G_ROOTPATH is inherited from config.pl and has the > value of > /home/warren > > <<<<<<< > On the first run of the script G_ROOTPATH in test.pl has the value of > home/warren... subsequent runs,