I am working with an old Perl Library (program module) written in Perl4 and Perl  5 depending who was "hacking the code". My program that calls it, uses -w and strict and has identified many syntax errors and so forth in the old library which I fixed. My problem is that this library needs two variables passed as globals to it to use in one of the subroutines, One of them is the $dbh variable created when the database is open. Another is a hash. Both these variables were initiated at the Main top most level of the program with "my". Unfortunately, this causes an error and the libraries does not see the global. If I turn off strict and the -w options and remove the "my" from these variables assignments, the program works. What is going on? I might point out that the start of the subroutine that is causing the problem starts like this.

sub SelectReport (@) {
    my ($var,$val) = @_;
    # Here is the order in which we try to get the reports:
    # matching userid -> matching group permission -> matching role_id -> userid empty (for everybody)
    my $querystr = "select * from report where $var = '$val' and user_id='$user{userid}'";
    print "QS=$querystr\n";
    debug("SelectReport1: Q=$querystr");
    my $my_error = '';
    my $sth = $dbh->query($querystr) || ($my_error="$querystr: ". $dbh->errmsg);
......
......
......

I already found a call in the library that looks like this

my $sth = SelectReport('report_id',$report_id);

Yes it is a hack issue, but the program has worked for years and the client does not want the code rewritten at present. Does anyone know what is causing this unstable results with "my" at the global level not being passed?

One other note. Yes the all the client programs run with strict and -w turn off. They think it runs faster with the compiler fixing all the errors when it is executed.


--

Michael Barto
Software Architect

LogiQwest Circle
LogiQwest Inc.
16458 Bolsa Chica Street, # 15
Huntington Beach, CA  92649
http://www.logiqwest.com/

    [EMAIL PROTECTED]
Tel:  714 377 3705
Fax: 714 840 3937
Cell: 714 883 1949

'tis a gift to be simple
This e-mail may contain LogiQwest proprietary information and should be treated as confidential.

Reply via email to