Perl Old Number of Element in Hash Assignment Error
I was learning Perl Objects. I wrote a simple constructor in a module file
my_module.pm:
#!/usr/bin/perl -w
#
package my_module;
use strict;
use warnings;
use diagnostics;
sub new {
my $class = shift;
my %params = @_;
my $self=bless{
_para1=>$params{'mypara1'},
_para2=>$params{'mypara2'}
},$class;
return $self;
}
1;
and I am creating an object in a main file main.pl:
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
use lib::my_module;
sub _start(){
print "Main Function Started\n";
create_schedules::new(
'mypara1' => 'This is mypara1',
'mypara2' => 'This is mypara2',
);
}
_start();
As soon as I run main.pl, I got following error:
Main Function Started
Odd number of elements in hash assignment at lib/create_schedules.pm line
9 (#1)
(W misc) You specified an odd number of elements to initialize a hash,
which is odd, because hashes come in key/value pairs.
No comments:
Post a Comment