jmmitc06 has asked for the wisdom of the Perl Monks concerning the following question:
Perl Monks:
I have a problem changing from 'Class::Accessor::Fast' to 'Class::Accessor::Faster'. From what I understood, simply changing from Fast to Faster should have required no code modification; however, when a script invokes and tries to use this module I receive the error:
"Not an ARRAY reference at /usr/local/bin.../Class/Accessor/Faster.pm"
The code for the module:
#!/usr/bin/perl #Atom.pm #Contains the methods for Atom, an object that represents an atom with +in a compound. package Atom; use base 'Class::Accessor::Faster'; use strict; #use warnings; #The following hashes to allow for conversion of mol file charge code +to accepted numerical representations of charge and oxidation. my %SDF_charge_conversion = (2 => 2, 3 => 1, 4 => "Doublet Radical", 5 + => -1, 6 => -2, 7 => -3, 0 => 0); my %SDF_oxidation_modification = (2 => 2, 3 => 1, 4 => 1, 5 => 1, 6 => + 2, 7=> 3, 0 => 0); #Create prototypical atom object my @atom_fields = ( "element" => 0, #a string representing the element type +of the atom "SDF_charge" => 0, #an integer representing the SDF_charge +code of the atom "index" => 0, #an integer representing the index of th +e atom in the Atoms array of the molecule "bond_count" => 0, #an integer representing the number of b +onds that contain the atom "bond_order_count" => 0, #an integer representing the sum of all +bond orders of the bonds that contain the atom "oxidation_modifier" => 0, #an integer representing the oxidation s +tate of the atom (calculated from charge) "charge" => 0, #an integer representing the charge of t +he atom (calculated from charge) ); Atom->mk_accessors( grep { $_ ne "0"; } (@atom_fields)); #Name: new #Description: Creates a new 'atom' object #Options: None #Input: @_ - @(element, SDF_charge, index, bond_count, bond_order_coun +t, oxidation_modifier, charge) #Output: $self - Atom Object sub new { my $proto = shift @_; my $self = { @atom_fields, @_ }; $self = bless ($self, ref($proto) || $proto); $self->oxidation_modifier($SDF_oxidation_modification{$self->SDF_cha +rge}); $self->charge($SDF_charge_conversion{$self->SDF_charge}); return $self; } 1;
The only change I made was changing Fast to Faster to receive the error. I thought the differences were internal. If any one could help me figure out why I get this error and what modifications I need to make it work, I would greatly appreciate it. I can post the script that envokes the module if needed, but its large and I don't think it would help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with Class::Accessor::Faster
by kcott (Archbishop) on Jul 30, 2013 at 06:20 UTC | |
|
Re: Problem with Class::Accessor::Faster
by tobyink (Canon) on Jul 30, 2013 at 06:54 UTC | |
by McA (Priest) on Jul 30, 2013 at 07:44 UTC | |
by tobyink (Canon) on Jul 30, 2013 at 08:30 UTC | |
|
Re: Problem with Class::Accessor::Faster
by zork42 (Monk) on Jul 30, 2013 at 04:25 UTC | |
|
Re: Problem with Class::Accessor::Faster
by jmmitc06 (Beadle) on Jul 31, 2013 at 02:51 UTC |