JohnLucania
Programmer
What is this error about and how to fix?
Can't modify constant item in scalar assignment at line 16, near "}"
#! /usr/bin/perl
use strict;
use warnings;
package Protein;
our %attrib;
sub new {
my( $class , %attribs ) = ( @_ );
my $obj = {
_name = $attrib{name} || die "need 'name'!",
_manu = $attrib{manufacturer} || die "need 'manufacturer'!",
_seq = $attrib{sequence} || die "need 'sequence'!",
};
return bless $obj , $class;
}
my $prot = Protein->new(
name => 'BsrDI',
manufacturer => 'Boehringer Mannheim',
sequence => 'GGCCTACCCTGGGTAAGGGCCTGGAGCAGGA',
);
sub get_name {
my( $self ) = ( @_ );
return $self->{_name};
}
sub get_manu {
my( $self ) = ( @_ );
return $self->{_manu};
}
sub get_seq {
my( $self ) = ( @_ );
return $self->{_seq};
}
my $name = $prot->get_name;
my $manufacturer = $prot->get_manu;
my $sequence = $prot->get_seq;
print $name;
print $manufacturer;
print $sequence;
print "\n";
Can't modify constant item in scalar assignment at line 16, near "}"
#! /usr/bin/perl
use strict;
use warnings;
package Protein;
our %attrib;
sub new {
my( $class , %attribs ) = ( @_ );
my $obj = {
_name = $attrib{name} || die "need 'name'!",
_manu = $attrib{manufacturer} || die "need 'manufacturer'!",
_seq = $attrib{sequence} || die "need 'sequence'!",
};
return bless $obj , $class;
}
my $prot = Protein->new(
name => 'BsrDI',
manufacturer => 'Boehringer Mannheim',
sequence => 'GGCCTACCCTGGGTAAGGGCCTGGAGCAGGA',
);
sub get_name {
my( $self ) = ( @_ );
return $self->{_name};
}
sub get_manu {
my( $self ) = ( @_ );
return $self->{_manu};
}
sub get_seq {
my( $self ) = ( @_ );
return $self->{_seq};
}
my $name = $prot->get_name;
my $manufacturer = $prot->get_manu;
my $sequence = $prot->get_seq;
print $name;
print $manufacturer;
print $sequence;
print "\n";