in reply to Shifting themes

Just a thought I had about the shifting themes - why not tie the scalars to a shifting array (I knew that book on OO Perl would come in useful for something...)
Not sure whether that ugly OO code has any place in a perl poem - what do you think?
# words and concept by alakaboo # Tied OO implementation of shifting themes # by Osfameron (hakim@earthling.net) our @themes = qw( fuel fire flame hot air water earth spirit desire love happiness peace ); tie $heart, 'Theme', \@themes; tie $soul, 'Theme', \@themes; print <<POEM; from $heart comes $soul thus the $heart is truly $soul for without $heart one cannot have $soul and without $soul one returns to the $heart one $soul, one $heart no $heart, no $soul POEM package Theme; sub TIESCALAR { bless @_[1], @_[0] }; sub FETCH { shift @{@_[0]} };
Update: On thinking about it, it seems churlish not to mention that that the OO book in question is Damian Conway's excellent Object Oriented Perl.

Cheerio!
Osfameron

Replies are listed 'Best First'.
RE: RE: shifting themes
by mwp (Hermit) on Jul 31, 2000 at 21:55 UTC

    This is one of those occasions where I wish I could ++ a post twice. :)

    This is an elegant solution to an otherwise inelegant problem. I've been reading about Tie() off and on since I started learning object oriented Perl programming, about two months ago, and this really brings it together for me. Ironic, dontcha think?

    Thanks for the help!!

    Alakaboo
    I am the lurker that spams in the night.