Hi Vish,
The problem here is probably a misunderstanding of how these element
trees work. Each time you create a new element and insert it into a tree
structure, it's a unique object in that structure that cannot appear in
more than one place in the tree.
So, for example, when you create your BOLD element and wrap it around
the year, you then proceed to use that same object reference to wrap
target days. Rather than simply wrapping those days in a bold element,
like you intended, you are wrapping the day in the bold element *plus
everything it contained* -- in essence, you keep wrapping elements with
larger and larger sub-trees.
The solution is to create a *new* HTML::Element on each iteration in the
loop. Think of HTML::Element objects as "use once" entities -- once they
are inserted into a tree, they cannot (easily) be reused.
Read the copius docs in the HTML::Element module for further information
on how to think about, and manipulate, these trees.
Cheers,
Matt