Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Class::Accessor attributes

by perldiverx (Sexton)
on Mar 07, 2014 at 13:06 UTC ( #1077374=perlquestion: print w/ replies, xml ) Need Help??
perldiverx has asked for the wisdom of the Perl Monks concerning the following question:

I've created a module using Class::Accessor and I've used the 'antlers' pragma to use the Moose style interface for creating attributes, but I'm having a problem exporting these attributes. Per the documentation I've used extends on the attributes, but I can't seem to get them into the script that I'm using them in. I get a message stating that Perl 'Can't locate package transaction_type for @Monro::CC::ISA at C:/Perl/lib/Class/Accessor.pm line 36 (#1)'. Sample:
package Monro::CC; use strict; use warnings; use Class::Accessor "antlers"; extends(qw/transaction_type/); has transaction_type => ( is => 'rw', );
And part of the script that utilizes this:
#!/usr/bin/perl use strict; use warnings; use Monro::CC; my $transaction_info = read_psin(); my @transaction_info = @{$transaction_info}; my $trans_obj = Monro::CC->new( transaction_type => $transaction_info[0], );

Comment on Class::Accessor attributes
Select or Download Code
Re: Class::Accessor attributes
by McA (Priest) on Mar 07, 2014 at 13:42 UTC

    Hi,

    with the line

    extends(qw/transaction_type/);

    you say that you want to inherit from a package with name transaction_type. And the error message stats

    'Can't locate package transaction_type for @Monro::CC::ISA at C:/Perl +/lib/Class/Accessor.pm line 36 (#1)'

    which says that you don't have a module called transaction_type in the INC path.

    McA

      I thought about that when I created this initially, however the documentation on CPAN tells me to replace  @ISA = qw /Foo Bar/; with extends qw(/Foo Bar/);
      Even when I change this to your recommendation the script still warns that it cannot locate the package.

        Do you have a package called transaction_type? There must be something like transaction_type.pm somewhere in your INC path.

        McA

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1077374]
Approved by rnewsham
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2014-12-27 22:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls