You don't want an equals sign there.
my $Q=Games::QuizTaker->new(FileName => "File", Delimitor => ",");
If anyone else is going to use your code, you probably should correct your spelling. Both 'delimiter' and 'filelength' are misspelled.
I can also see the _Print_Object method breaking if any values are references. Try this:
sub _Print_Object{ my $self=shift; require Data::Dumper; print Data::Dumper::Dumper $self; }
I also noticed that you weren't using the two argument form of bless. Why is that? If you don't bless your referent into the class passed as the first argument, you're going to break inheritance, which you will find very difficult to debug later if you want to use this as a base class. Also, the first argument should probably not be called $self because this is probably not an object method.
sub new { my ($class,%arg)=@_; bless{ _FileName => $arg{FileName}||croak"No FileName Given", _Delimiter => $arg{Delimiter}|| "|", _FileLength => "0", }, $class }
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
In reply to (Ovid) Re: Unable to put default value in object hash
by Ovid
in thread Unable to put default value in object hash
by TStanley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |