Well Monsigneurs,
I thought I had it but my results are not what I expected. This sub does a SELECT in the mySQL db and comes creates a hash with the day (of the month) as key and the title (of an event) as value. Thing is that some days have multiple events so I wanted to concatenate the additional titles onto the end of the existing value. The code below is where I am now. It gives me 1 title, and not the one I was getting so I am triggering the else conditional but no matter what I do (including $events{ $ref->{$day} } = undef or ="boogers" ) seem to have no effect. Can some one point out what is going wrong and how I can concatenate the values of identical keys?
TIA
jg
sub month_events { $sth = $dbh->prepare("SELECT * FROM hno_calendar WHERE year = $yea +r AND month = $month"); $sth->execute(); while (my $ref = $sth->fetchrow_hashref()) { if ( !exists $events{ $ref->{day} } ) { $events{ $ref->{day} } = $ref->{title}; } else { $events{ $ref->{$day} } .=$ref->{title}; } } }
_____________________________________________________
Think a race on a horse on a ball with a fish! TG

In reply to Concatenating Identical Key's Values by jerrygarciuh

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.