Why does Perl complain "Can't modify constant item in scalar assignment"?

ldap, perl

Solution

I think your code should be;

my $self = {
                _ldap => $ldap_obj,
                _dn =>'dc=users,dc=ldap,dc=company,dc=com',
                _dn_login => 'dc=login,dc=ldap,dc=company,dc=com',
                _description =>'company',
};

Change it and try with `$perl -c module.pm`

Problem

I have this Perl subroutine that is causing a problem: ``` sub new { my $class = shift; my $ldap_obj = Net::LDAP->new( 'test.company.com' ) or die "$@"; my $self = { _ldap = $ldap_obj, _dn ='dc=users,dc=ldap,dc=company,dc=com', _dn_login = 'dc=login,dc=ldap,dc=company,dc=com', _description ='company', }; # Print all the values just for clarification. bless $self, $class; return $self; } ``` what is wrong on this code : i got this error Can't modify constant item in scalar assignment at Core.pm line 12, near "$ldap_obj,"

Original source