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 "b" ) && do {
> >                print $fh_dblogsql "insert into dbmovelog (DEBENAME,
> MOVE, FELD1, FELD2, ERSTELL_TS) values ('".$db."', '".$mode."',
> '".$backup."', '".$dbvers."', sysdate);";
> >                last SWITCH;
> >            };
> >            ( $mode eq "t" ) && do {
> >                print $fh_dblogsql "insert into dbmovelog (DEBENAME,
> MOVE, FELD1, FELD2, ERSTELL_TS) values ('".$db."', '".$mode."',
> '".$sdb."', sysdate);";
> >                last SWITCH;
> >            };
> >        }
> >}

Correct.

> Depending on the value of $mode, you run two slightly different SQL
> statements. The second of them with the wrong number of values ;-)

Uhm, correct as well ... copy&paste accident ... sorry :)
 
> From the look of things, $backup and $sdb are really the same thing,
> namely input for the column FELD1.

Correct.

> My gut feeling is that you should pass $mode as an argument to the
> function since it's never nice to have a subroutine that does two
> different things without an obvious reason.

Right, I simply forgot about that. $mode isn't used as a global variable so I 
had to do that anyway. 

> I'd then coalesce $backup and $sdb into the variable $feld1 and
> suddenly you don't need your "switch" anymore.

No, can't do that. $backup is a dirname, $sdb is another, and I need them both 
separate.
 
> Apart from that, there's really no need to call a three argument
> function with three arguments when you know you don't need the third
> argument.
> 
> Just call it with two arguments in that case, and the troublesome
> variable will be set to undef.

I did as you suggested, and it works now, thank you :) 

Kind regards,
Nora


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to