Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^4: Class::Accessor attributes

by perldiverx (Beadle)
on Mar 07, 2014 at 14:00 UTC ( #1077390=note: print w/replies, xml ) Need Help??

in reply to Re^3: Class::Accessor attributes
in thread Class::Accessor attributes

No package by that name. transaction_type is an attribute of my object. Hence:
has transaction_type => { is => 'rw', };

Replies are listed 'Best First'.
Re^5: Class::Accessor attributes
by McA (Priest) on Mar 07, 2014 at 14:08 UTC

    I think there is a misunderstanding on your side. What do you think does the line


    for you? What do you expect?

    The line says that the class/package 'Monro::CC' is inheriting from class/package 'transaction_type'. But I assume you don't want this.


      From what I understand it should load the transaction_type class. But, when I do not include this, I get an error stating 'Can't locate object method "_mk_accessors" via package "Monro::CC" at C:/Perl/lib/Class/ line 36.' When I originally came across this error I consulted the documentation for Class::Accessor, and in the 'Moose!' subsection it says you should use extends instead of changing @ISA directly. Why this is: I have no idea, but it does result in not getting the aforementioned error message.

        Okay, I think I got this...

        What I did was remove all of the extends and all of the Exporter stuff altogether. New code:

        package Monro::CC; use strict; use warnings; use Class::Accessor "antlers"; has 'transaction_type' => ( is => 'rw', );

        And the script:

        #!/usr/bin/perl use strict; use warnings; use Monro::CC; my $trans_obj = Monro::CC->new({ 'transaction_type' => $transaction_info[0], });

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1077390]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2018-02-20 14:18 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (271 votes). Check out past polls.