Regarding:

a) Thanks.

b) I did not understand what you said.

c) I found nothing in the cookbook about explicit "reader" and "writer" attribute modifiers as described in the Moose Manual about Attributes

For example, I'd like to do something like this (which does not work with Moose even though one is supposed to be able to explicitly specify "reader" and "writer" accessors by name):
package QuackLog; use Moose; use namespace::autoclean; use strict; my +@log_string_parts = qw(timestamp foo bar baz qux norf quack honk woof + meow blerf); has $_=> (is => 'rw') for(@log_string_parts); has log_s +tring => ( is => 'rw', reader=> 'get_log_string', writer => 'set_log_ +string', ); sub get_log_string{ my ($self) = shift; return(join ' ',m +ap {$self->can($_);$self->$_} @log_string_parts); } sub set_log_strin +g{ my ($self,$s)=@_; my @part_values=split / /,$s; for my $method (@l +og_string_parts){ $self->can($method); $self->$method(shift @part_val +ues); } $self; } __PACKAGE__->meta->make_immutable();

This, however, produces a compile time error:

You are overwriting a locally defined method (get_log_string) with an +accessor...

PS: I did try the symbolic $method lookup, having used it many times before in Perl objects, but for some reason it didn't work, and I attributed the failure to my lack of understanding of Moose rather than the more likely explanation which was just a bad choice of syntax.


In reply to Re^2: Moose log string class by jabowery
in thread Moose log string class by jabowery

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.