Re: AW: Good/best practice - pre-declare variables

2010-05-21 Thread Brandon McCaig
On Fri, May 21, 2010 at 5:15 AM, Shlomi Fish wrote: > On Friday 21 May 2010 07:43:07 HACKER Nora wrote: >> I still have a (meta) question referring to your advice to set it up as >> a global variable: I read that "Global variables are bad [...] >> (http://perldoc.perl.org/perlfaq7.html) - so when

Re: AW: Good/best practice - pre-declare variables

2010-05-21 Thread Shlomi Fish
Hi Nora, On Friday 21 May 2010 07:43:07 HACKER Nora wrote: > Hi Shlomi, > > Thanks for your reply. > > > From a cursory look at your program, it seems that you can just set up > > $mode > > as a global variable, and keep it at that instead of just passing it > > around. > > Alternatively, maybe

AW: Good/best practice - pre-declare variables

2010-05-21 Thread HACKER Nora
Hi Thomas, > Let's see if I understand this correctly: > > You have a global variable $mode that's deciding the mode of operation > in your sub dblog(), to quote: > > > # DBLOG sub-function > > sub dblog { > >my ( $backup, $dbvers, $sdb ) = @_; > >SWITCH: { > >( $mode eq

AW: Good/best practice - pre-declare variables

2010-05-20 Thread Thomas Bätzler
HACKER Nora wrote: > Obviously, my point wasn't clear enough, I'm sorry for that. The > variable in the code extract that I'm really bothering about is the > $sdb: It is needed in the SWITCH of a sub-function, but this construct > only works if I pre-declare the $sdb in the calling function backup

AW: Good/best practice - pre-declare variables

2010-05-20 Thread HACKER Nora
Hi Shlomi, Thanks for your reply. > From a cursory look at your program, it seems that you can just set up > $mode > as a global variable, and keep it at that instead of just passing it > around. > Alternatively, maybe you'd like to define a class and keep the mode > variable > there as a propert

Re: Good/best practice - pre-declare variables

2010-05-20 Thread Shlomi Fish
On Thursday 20 May 2010 13:52:58 HACKER Nora wrote: > Hello, > > I have a programme for database backup / recovery / some other tasks > with several modes (e.g. ackup etc.) in wich a certain function is > called. In this function I do a SWITCH, depending on the mode that the > main programme is st

Good/best practice - pre-declare variables

2010-05-20 Thread HACKER Nora
Hello, I have a programme for database backup / recovery / some other tasks with several modes (e.g. ackup etc.) in wich a certain function is called. In this function I do a SWITCH, depending on the mode that the main programme is started with. In one of the cases of SWITCH (e.g. ecovery) I use a