LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   "Not a CODE" reference error perl v5.10.0, Deprecated assignment operation. (https://www.linuxquestions.org/questions/programming-9/not-a-code-reference-error-perl-v5-10-0-deprecated-assignment-operation-710294/)

skuletm 03-09-2009 01:09 PM

"Not a CODE" reference error perl v5.10.0, Deprecated assignment operation.
 
Perl v5.10. SLES 11. Deprecated assignment.
my( $sym ) = $AEDefines::{$def}; // doing such an assignment will results in a error as the bug will make ,$AEDefines::{$def}; to be interpreted as a scalar , which is deprecated (and causing testing to fail )
$rc = &ck_set( $ck_ref, CK_SERVER | CK_OS, &$sym ); <"Not a CODE reference, error hit here

this was fixed by changing to assignment as in the following:
elsif( $tempos =~ /LINUX/ )
{
# Scan through the list of Linuxes to pick out the
# correct one.
foreach $def ( sort( keys( %AEDefines:: ) ) )
{
if( $def =~ /^OS_(.*)/)
{
if( $tempos =~ /$1/ )
{
$sym = $def;
$rc = &ck_set( $ck_ref, CK_SERVER | CK_OS, &$sym );
}
}
}
}

taylor_venable 03-10-2009 10:16 PM

Was there a question here? If so could you please rephrase it and use code blocks around your source next time please.

Sergei Steshenko 03-11-2009 01:15 PM

Quote:

Originally Posted by skuletm (Post 3469903)
Perl v5.10. SLES 11. Deprecated assignment.
my( $sym ) = $AEDefines::{$def}; // doing such an assignment will results in a error as the bug will make ,$AEDefines::{$def}; to be interpreted as a scalar , which is deprecated (and causing testing to fail )
$rc = &ck_set( $ck_ref, CK_SERVER | CK_OS, &$sym ); <"Not a CODE reference, error hit here

this was fixed by changing to assignment as in the following:
Code:

elsif( $tempos =~ /LINUX/ )
        {
            # Scan through the list of Linuxes to pick out the
            # correct one.
            foreach $def ( sort( keys( %AEDefines:: ) ) )
            {
                if( $def =~ /^OS_(.*)/)
                {
                  if( $tempos =~ /$1/ )
                    {
                        $sym  = $def;
                        $rc = &ck_set( $ck_ref, CK_SERVER | CK_OS, &$sym );
                    }
                }
            }
        }


For starters, put

use strict;
use warnings;

in the beginning of your program - unless you've already done so.

And get rid of all error messages during compilation, and then get rid of all runtime warnings and errors before the one in question.

Where is the 'ck_set' function defined ?

Publish full code here.

skuletm 03-12-2009 12:21 AM

Thanks for getting to me on this. I actually got this resolved,
I was hoping "Not a CODE reference" was a perl error with
known list of causes. The ck_set (connection key set) method
was being passed an invalid value when setting
my( $sym ) = $AEDefines::{$def}
I'll keep the post cleaner next time :)


All times are GMT -5. The time now is 12:42 AM.