Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Dear perl -gurus: i am new to perl and really have begun to love this stuff very quickly .. I have a data structure:
my $room = ( { TEXT => $string, EXITS => $exits, THINGS => { %things }, ITEMS => { %items }, CMDS => { %cmds }, # EVENTS => \&events, } );
I have a function that pass this ref, and then read some data into the strucrture and push it onto an array several passes, that I then return a ref to .. But I end up with the last (pass) element in all places in the array .. the ref use the same memory again and again? How can I make the ref a new one in each pass? When I print it out I get the correct strings for each pass .. so it must be the push that creates a problem.
foreach (@rooms) { ($rr->{TITLE}, $rr->{TEXT}, $rr->{EXITS}, $rr->{THINGS +}, $rr->{ITEMS}) = split ":", $_; push @a, $rr; }; return \@a;
Please, anyone, how to approach this problem? Thanks .. ^^^theantler<<<

In reply to the ref use the same memory when i push structure onto array? Gahh .. please help me dear perl-gurus by theantler

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 browsing the Monastery: (4)
As of 2024-05-26 18:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found