Hello,
I have this snippet:

use strict; use lib ("./Lib"); use Datum; my $datum = new Datum;
and, in ./Lib/Datum.pm
package Datum; use strict; use warnings; use Data::Dumper; use Class::Struct; struct Datum => { heights_agl => '@', }; sub heights_agl { my $self = shift; if (@_) { $self->set_values(Variable=>'heights_agl',@_); } } sub set_values { my $self = shift; my %args = @_; die Dumper \@_; } 1;
This gives me an error when run with Perl versions after 5.16.
It seems to me that after V 5.16 the override function is called when creating the Class, thus giving the error, while it is not before V5.16

With Perl V5.16:

C:\Tmp\debug.4>perl driver.pl function 'heights_agl' already defined, overrides struct accessor meth +od at Lib/Datum.pm line 8. C:\Tmp\debug.4>perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x +64-multi-thread
And with Perl V5.26:

$ perl driver.pl function 'heights_agl' already defined, overrides struct accessor meth +od at Lib/Datum.pm line 8. Odd number of elements in hash assignment at Lib/Datum.pm line 25. $VAR1 = [ 'Variable', 'heights_agl', [] ]; $ perl -v This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-li +nux-gnu-thread-multi (with 67 registered patches, see perl -V for more detail)
Is this hypothesis correct and is there a way to have it working again?
Thank you

In reply to Class::Struct accessor function after Perl V5.16 by Anonymous Monk

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.