Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

First, I would recommend using <readmore> tags around your code section, long posts make it difficult to get help.

Regarding your question, I believe Moose does not have anything related to your task at hand but I may be wrong. Did you try searching CPAN first?

Anyway, you should use "regular" code to deal with your array references. Moose will help you only with the type checking that you used when creating the attribute. Create methods to deal with the array references, and just be sure to assign the proper value when writing back to the attribute.

Anyway, since you're dealing with references, you could change the data inside it without accessing the attribute anyway, but this might be dangerous if done outside the class methods.

Looks like that you're expecting Moose to validate the data, but to have that you would need to invoke the set or whatever you have defined as writer for the arr2d attribute.

If you're not trying to improve performance by using array references, I would suggest you to create classes to represent the data structure that you want instead of plain data. That would help using an easier way to change data inside the structure and being able to check for problems during the process.

I would also suggest you to choose better names for the attribute and methods, but maybe you're justing experimenting.

Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

In reply to Re: How do I work with multidimensional arrays in Moose? by glasswalk3r
in thread How do I work with multidimensional arrays in Moose? by paulymer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-16 19:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found