So I'm learning oop through this tutorial I found.
Perl Objects Tutorial

I've gotten about half way down with the tutorial and I keep getting the same error "Can't find object method 'new' via ..."

I get the warning TutorialConfig is successfully loaded but the new method doesn't seem to be loading.

Here is the TutorialConfig.pm

#!/usr/bin/perl package TutorialConfig; warn "TutorialConfig is successfully loaded!\n"; 1; sub new { my ($class_name) = @_; my ($self) = {}; warn "We just created our new variable...\n "; bless ($self, $class_name); warn "and now it's a $class_name object!\n"; $self->{'_created'} = 1; return $self; } sub read { my ($self, $file) = @_; my ($line, $section); open (CONFIGFILE, $file) or return 0; # We'll set a special property # that tells what filename we just read. $self->{'_filename'} = $file; while ($line = <CONFIGFILE>) { # Are we entering a new section? if ($line =~ /^\[(.*)\]/) { $section = $1; } elsif ($line =~ /^([^=]+)=(.*)/) { my ($config_name, $config_val) = ($1, $2); if ($section) { $self->{"$section.$config_name"} = $config_val; } else { $self->{$config_name} = $config_val; } } } close CONFIGFILE; return 1; } sub get { my ($self, $key) = @_; return $self->{$key}; }
Here is the test.pl
use TutorialConfig; $tut = new TutorialConfig; $tut->read('tutc.txt') or die "Couldn't read config file: $!"; print "The author's first name is ", $tut->get('author.firstname'), ".\n";

In reply to Need help with objects by lv211

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.