TStanley has asked for the wisdom of the Perl Monks concerning the following question:
Now if I create a new object with the following code:package Games::QuizTaker; use strict; use Carp; sub new{ my($self,%arg)=@_; bless{ _FileName => $arg{FileName}||croak"No FileName Given", _Delimitor => $arg{Delimitor}|| "|", _FileLenght => "0", } } sub _Print_Object{ my $self=shift; foreach my $key(keys %$self){ print"$key = $$self{$key}\n"; } }
All of the variables in the object print out. However, if I remove the Delimitor from the new function, the only thing that prints out is the name of the file. Needless to say I am rather confused. I would be grateful if any one could shed some light on this.#!/opt/perl5/bin/perl -w use strict; use Games::QuizTaker; my $Q=Games::QuizTaker->new(FileName="File",Delimitor=","); $Q->_Print_Object();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: Unable to put default value in object hash
by Ovid (Cardinal) on Nov 14, 2001 at 23:13 UTC | |
by TStanley (Canon) on Nov 15, 2001 at 04:24 UTC | |
by Ovid (Cardinal) on Nov 15, 2001 at 04:33 UTC |