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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.