Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

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

Monks, I'm seeing some very odd behavior I think might be a bug (in Moose?) but maybe I'm missing something more basic.

So I've got this line of code:

$event->polished_data->{start} = $event->start_time;

$event is an object created with Moose, polished_data is an attribute and isa HashRef. $event->start_time is a Time::Piece object. Yes, I am copying the Time::Piece from one part of the object to another.

Here's where the weirdness comes in. After the assignment, when I Dumper the event, sometime the value indexed by the start is the Time::Piece object and and the value of $event->start_time looks like this: $VAR1->{'polished_data'}{'start'}. What's really weird is the rest of the time (about 50% of the time), $event->start_time is the Time::Piece object and the indexed value in the hash is $VAR1->{'polished_data'}{'start'}. Witness:

$VAR1 = bless( { 'event_id' => '2927', 'post_id' => 0, 'polished_data' => { 'start' => bless( [ 0, 0, 19, 28, 2, 116, 1, 87, 1, 1459206000, 1 ], 'Time::Piec +e' ), }, 'start_time' => $VAR1->{'polished_data'}{'start'}, }, 'Event' ); $VAR1 = bless( { 'start_time' => bless( [ 0, 0, 18, 11, 3, 116, 1, 101, 1, 1460412000, 1 ], 'Time::Piece' ), 'polished_data' => { 'start' => $VAR1->{'start_time'} +, }, }, 'Event' );

If anyone can explain what's going on and help me workaround this issue, I'd greatly appreciate it.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks


In reply to Very odd behavior assigning Time::Piece object to hash reference inside of an object by nysus

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 goofing around in the Monastery: (5)
As of 2024-04-19 07:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found