| 1 | package IChing::Hexagram::Illuminatus; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | $IChing::Hexagram::Illuminatus::VERSION = "0.01"; | |||||||||||
| 4 | |||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use LWP::UserAgent; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use HTTP::Request; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | ▶ | use HTML::Summary; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 1 | ▶ | use HTML::TreeBuilder; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | =head1 NAME | ||||||||||||
| 13 | |||||||||||||
| 14 | IChing::Hexagram::Illuminatus - An IChing hexagram | ||||||||||||
| 15 | |||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||
| 17 | |||||||||||||
| 18 | use IChing::Hexagram::Illuminatus; | ||||||||||||
| 19 | |||||||||||||
| 20 | my $hex = IChing::Hexagram::Illuminatus->new; | ||||||||||||
| 21 | |||||||||||||
| 22 | my $hex = IChing::Hexagram::Illuminatus->new( | ||||||||||||
| 23 | { political => 'http://policital.site.com', | ||||||||||||
| 24 | economic => 'http://economic.ste.com', | ||||||||||||
| 25 | meterological => 'http://meterological.ste.com', | ||||||||||||
| 26 | astrological => 'http://astrological.ste.com', | ||||||||||||
| 27 | astronomical => 'http://astronomical.ste.com', | ||||||||||||
| 28 | technological => 'http://technoloigical.ste.com', | ||||||||||||
| 29 | } | ||||||||||||
| 30 | ); | ||||||||||||
| 31 | |||||||||||||
| 32 | my $political_reference = $hex->political; | ||||||||||||
| 33 | my $economic_reference = $hex->economic; | ||||||||||||
| 34 | my $meterological_reference = $hex->meterological; | ||||||||||||
| 35 | my $astrological_reference = $hex->astrological; | ||||||||||||
| 36 | my $astronomical_reference = $hex->astronomical; | ||||||||||||
| 37 | my $technological_reference = $hex->technological; | ||||||||||||
| 38 | |||||||||||||
| 39 | my $reading = $hex->throw; | ||||||||||||
| 40 | |||||||||||||
| 41 | =head1 DESCRIPTION | ||||||||||||
| 42 | |||||||||||||
| 43 | While reading the Illuminatus! Trilogy, there is a machine called FUCKUP, which | ||||||||||||
| 44 | stands for First Universal Cybernetic-Kinetic-Ultramicro-Programmer. And | ||||||||||||
| 45 | Hagbard Celine uses this to generate an IChing hexagram. | ||||||||||||
| 46 | |||||||||||||
| 47 | This modules attempts to do the same thing. | ||||||||||||
| 48 | |||||||||||||
| 49 | =head2 So what is an IChing hexagram then? | ||||||||||||
| 50 | |||||||||||||
| 51 | Honestly? I have no idea. | ||||||||||||
| 52 | |||||||||||||
| 53 | =head2 Alright then, how is it described in the book? | ||||||||||||
| 54 | |||||||||||||
| 55 | Glad you asked. | ||||||||||||
| 56 | |||||||||||||
| 57 | This will read a random open circuit as a broken (yin) line, then read a | ||||||||||||
| 58 | random closed circuit as a full (yang) line, until six such lines are | ||||||||||||
| 59 | round, then simulate an IChing hexagram being thrown. | ||||||||||||
| 60 | |||||||||||||
| 61 | This is fed into the IChing interpretation engine, and cross checked with | ||||||||||||
| 62 | the current day's political, economic, meterological, astrological, | ||||||||||||
| 63 | astronomical and technological news. | ||||||||||||
| 64 | |||||||||||||
| 65 | At the end of all this, you have a pseudo scientific/crackpot prediciton of | ||||||||||||
| 66 | the future. | ||||||||||||
| 67 | |||||||||||||
| 68 | =head2 So I get my fortune told. Is that it? | ||||||||||||
| 69 | |||||||||||||
| 70 | Not only your fortune, but a broad sweep of What Is To Come. | ||||||||||||
| 71 | |||||||||||||
| 72 | OK, I admit it. What a pile of old trousers. But I like the books, and | ||||||||||||
| 73 | this is part of my homage to them. | ||||||||||||
| 74 | |||||||||||||
| 75 | =head1 METHODS | ||||||||||||
| 76 | |||||||||||||
| 77 | =head2 new | ||||||||||||
| 78 | |||||||||||||
| 79 | my $hex = IChing::Hexagram::Illuminatus->new; | ||||||||||||
| 80 | |||||||||||||
| 81 | my $hex = IChing::Hexagram::Illuminatus->new( | ||||||||||||
| 82 | { political => 'http://policital.site.com', | ||||||||||||
| 83 | economic => 'http://economic.ste.com', | ||||||||||||
| 84 | meterological => 'http://meterological.ste.com', | ||||||||||||
| 85 | astrological => 'http://astrological.ste.com', | ||||||||||||
| 86 | astronomical => 'http://astronomical.ste.com', | ||||||||||||
| 87 | technological => 'http://technoloigical.ste.com', | ||||||||||||
| 88 | } | ||||||||||||
| 89 | ); | ||||||||||||
| 90 | |||||||||||||
| 91 | This will make a new IChing::Hexagram::Illuminatus object. All the values | ||||||||||||
| 92 | passed in with the hashref are optional. If nothing is passed in, defaults | ||||||||||||
| 93 | are used as defined by me. | ||||||||||||
| 94 | |||||||||||||
| 95 | =cut | ||||||||||||
| 96 | |||||||||||||
| 97 | 2 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 98 | 2 | my $self = {}; | |||||||||||
| 99 | 2 | bless $self, shift; | |||||||||||
| 100 | 2 | return $self->_init(@_); | |||||||||||
| 101 | } | ||||||||||||
| 102 | |||||||||||||
| 103 | 2 | ▶ | sub _init { | ||||||||||
|
Subroutine
_init: called CC=7 SCAR=20.5
| |||||||||||||
| 104 | 2 | my ($self, $ref) = @_; | |||||||||||
| 105 | |||||||||||||
| 106 | # | ||||||||||||
| 107 | # yes, I know I could contruct this differently. | ||||||||||||
| 108 | # | ||||||||||||
| 109 | 2 | ▶ | $self->{political} = $ref->{political} || 'http://www.stopworldwar3.com/News.rdf'; | ||||||||||
|
Condition50%1/2
$ref->{'political'} || 'http://www.stopworldwar3.com/News.rdf'
MC/DC0%0/1
$ref->{'political'} || 'http://www.stopworldwar3.com/News.rdf'
$ref->{'political'}
Truth table50%1/2
A
A= $ref->{'political'}
| |||||||||||||
| 110 | 2 | ▶ | $self->{economic} = $ref->{economic} || 'http://headlines.internet.com/internetnews/bus-news/news.rss'; | ||||||||||
|
Condition50%1/2
$ref->{'economic'} || 'http://headlines.internet.com/internetnews/bus-news/news.rss'
MC/DC0%0/1
$ref->{'economic'} || 'http://headlines.internet.com/internetnews/bus-news/news.rss'
$ref->{'economic'}
Truth table50%1/2
A
A= $ref->{'economic'}
| |||||||||||||
| 111 | 2 | ▶ | $self->{meterological} = $ref->{meterological} || 'http://weather.yahoo.com'; | ||||||||||
|
Condition50%1/2
$ref->{'meterological'} || 'http://weather.yahoo.com'
MC/DC0%0/1
$ref->{'meterological'} || 'http://weather.yahoo.com'
$ref->{'meterological'}
Truth table50%1/2
A
A= $ref->{'meterological'}
| |||||||||||||
| 112 | 2 | ▶ | $self->{astrological} = $ref->{astrological} || 'http://slashgoth.org/backend/weblog.rdf'; | ||||||||||
|
Condition50%1/2
$ref->{'astrological'} || 'http://slashgoth.org/backend/weblog.rdf'
MC/DC0%0/1
$ref->{'astrological'} || 'http://slashgoth.org/backend/weblog.rdf'
$ref->{'astrological'}
Truth table50%1/2
A
A= $ref->{'astrological'}
| |||||||||||||
| 113 | 2 | ▶ | $self->{astronomical} = $ref->{astronomical} || 'http://www.beyond2000.com/b2k.rdf'; | ||||||||||
|
Condition50%1/2
$ref->{'astronomical'} || 'http://www.beyond2000.com/b2k.rdf'
MC/DC0%0/1
$ref->{'astronomical'} || 'http://www.beyond2000.com/b2k.rdf'
$ref->{'astronomical'}
Truth table50%1/2
A
A= $ref->{'astronomical'}
| |||||||||||||
| 114 | 2 | ▶ | $self->{technological} = $ref->{technological} || 'http://www.slashdot.org/slashdot.rdf'; | ||||||||||
|
Condition100%2/2
$ref->{'technological'} || 'http://www.slashdot.org/slashdot.rdf'
MC/DC100%1/1
$ref->{'technological'} || 'http://www.slashdot.org/slashdot.rdf'
$ref->{'technological'}
Truth table100%2/2
A
A= $ref->{'technological'}
| |||||||||||||
| 115 | |||||||||||||
| 116 | 2 | return $self; | |||||||||||
| 117 | } | ||||||||||||
| 118 | |||||||||||||
| 119 | =head2 throw | ||||||||||||
| 120 | |||||||||||||
| 121 | my $reading = $hex->throw; | ||||||||||||
| 122 | |||||||||||||
| 123 | This will get you the hexagram. It is a string, on three lines, with | ||||||||||||
| 124 | a digit on each line, either a one or a zero. The one represents | ||||||||||||
| 125 | an unbroken yin line, while a zero gives the broken yang line. | ||||||||||||
| 126 | |||||||||||||
| 127 | For example, | ||||||||||||
| 128 | |||||||||||||
| 129 | 0 -- -- | ||||||||||||
| 130 | 1 would be read as _____ | ||||||||||||
| 131 | 1 _____ | ||||||||||||
| 132 | |||||||||||||
| 133 | But as well as the hexagram, it gets you the news from various sources. | ||||||||||||
| 134 | |||||||||||||
| 135 | From these two things, if you are skilled, and Know The Way, then you | ||||||||||||
| 136 | can interpret these and discover what is going on in the world. | ||||||||||||
| 137 | |||||||||||||
| 138 | =cut | ||||||||||||
| 139 | |||||||||||||
| 140 | 1 | ▶ | sub throw { | ||||||||||
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 141 | 1 | my $self = shift; | |||||||||||
| 142 | 1 | my $hex = $self->_hexagram; | |||||||||||
| 143 | 1 | my $text = $self->_get_headlines; | |||||||||||
| 144 | 1 | print "Your hexagram: $hex\n\nWorld info\n$text\n\n"; | |||||||||||
| 145 | } | ||||||||||||
| 146 | |||||||||||||
| 147 | 1 | ▶ | sub _hexagram { | ||||||||||
|
Subroutine
_hexagram: called CC=2 SCAR=6.9
| |||||||||||||
| 148 | 1 | my $self = shift; | |||||||||||
| 149 | # | ||||||||||||
| 150 | # TODO : Make this a better random number | ||||||||||||
| 151 | # | ||||||||||||
| 152 | |||||||||||||
| 153 | 1 | ▶ | my $bin = sub { int rand(2) }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 154 | 1 | my $pattern; | |||||||||||
| 155 | 1 | $pattern .= $bin->() for (1 .. 3); | |||||||||||
| 156 | 1 | return $pattern; | |||||||||||
| 157 | } | ||||||||||||
| 158 | |||||||||||||
| 159 | 1 | ▶ | sub _ua { | ||||||||||
|
Subroutine
_ua: called CC=2 SCAR=7.0
| |||||||||||||
| 160 | 1 | my $self = shift; | |||||||||||
| 161 | 1 | ▶ | unless (exists $self->{ua}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 162 | 1 | $self->{ua} = LWP::UserAgent->new; | |||||||||||
| 163 | } | ||||||||||||
| 164 | 1 | return $self->{ua}; | |||||||||||
| 165 | } | ||||||||||||
| 166 | |||||||||||||
| 167 | 1 | ▶ | sub _summary { | ||||||||||
|
Subroutine
_summary: called CC=2 SCAR=7.0
| |||||||||||||
| 168 | 1 | my $self = shift; | |||||||||||
| 169 | 1 | ▶ | unless (exists $self->{summary}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 170 | 1 | $self->{summary} = HTML::Summary->new( | |||||||||||
| 171 | LENGTH => 500, | ||||||||||||
| 172 | USE_META => 1, | ||||||||||||
| 173 | ); | ||||||||||||
| 174 | } | ||||||||||||
| 175 | 1 | return $self->{summary}; | |||||||||||
| 176 | } | ||||||||||||
| 177 | |||||||||||||
| 178 | 1 | ▶ | sub _get_headlines { | ||||||||||
|
Subroutine
_get_headlines: called CC=2 SCAR=6.9
| |||||||||||||
| 179 | 1 | my $self = shift; | |||||||||||
| 180 | 1 | my $ua = $self->_ua; my $summarizer = $self->_summary; | |||||||||||
| 181 | 1 | my $rubbish; | |||||||||||
| 182 | 1 | foreach my $category (qw/political economic meterological | |||||||||||
| 183 | astrological astronomical technological/) { | ||||||||||||
| 184 | 6 | my $response = $ua->request(HTTP::Request->new('GET', $self->$category)); | |||||||||||
| 185 | 6 | my $tree = HTML::TreeBuilder->new; | |||||||||||
| 186 | 6 | $tree->parse( $response->as_string ); | |||||||||||
| 187 | 6 | my ($summary, $throw) = split /HTTP/, $summarizer->generate( $tree ); | |||||||||||
| 188 | 6 | $rubbish .= "\n$category\n$summary\n" | |||||||||||
| 189 | } | ||||||||||||
| 190 | 1 | return $rubbish; | |||||||||||
| 191 | } | ||||||||||||
| 192 | |||||||||||||
| 193 | =head2 political | ||||||||||||
| 194 | |||||||||||||
| 195 | my $political_reference = $hex->political; | ||||||||||||
| 196 | |||||||||||||
| 197 | This will return the site from which the political information if gathered. | ||||||||||||
| 198 | |||||||||||||
| 199 | =cut | ||||||||||||
| 200 | |||||||||||||
| 201 | 1 | ▶ | sub political { shift->{political} } | ||||||||||
|
Subroutine
political: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 202 | |||||||||||||
| 203 | =head2 meterological | ||||||||||||
| 204 | |||||||||||||
| 205 | my $meterological_reference = $hex->meterological; | ||||||||||||
| 206 | |||||||||||||
| 207 | This will return the site from which the meterological information if gathered. | ||||||||||||
| 208 | |||||||||||||
| 209 | =cut | ||||||||||||
| 210 | |||||||||||||
| 211 | 1 | ▶ | sub meterological { shift->{meterological} } | ||||||||||
|
Subroutine
meterological: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 212 | |||||||||||||
| 213 | =head2 economic | ||||||||||||
| 214 | |||||||||||||
| 215 | my $economic_reference = $hex->economic; | ||||||||||||
| 216 | |||||||||||||
| 217 | This will return the site from which the economic information if gathered. | ||||||||||||
| 218 | |||||||||||||
| 219 | =cut | ||||||||||||
| 220 | |||||||||||||
| 221 | 1 | ▶ | sub economic { shift->{economic} } | ||||||||||
|
Subroutine
economic: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 222 | |||||||||||||
| 223 | =head2 astrological | ||||||||||||
| 224 | |||||||||||||
| 225 | my $mastrological_reference = $hex->astrological; | ||||||||||||
| 226 | |||||||||||||
| 227 | This will return the site from which the astrological information if gathered. | ||||||||||||
| 228 | |||||||||||||
| 229 | =cut | ||||||||||||
| 230 | |||||||||||||
| 231 | 1 | ▶ | sub astrological { shift->{astrological} } | ||||||||||
|
Subroutine
astrological: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 232 | |||||||||||||
| 233 | =head2 astronomical | ||||||||||||
| 234 | |||||||||||||
| 235 | my $mastronomical_reference = $hex->astronomical; | ||||||||||||
| 236 | |||||||||||||
| 237 | This will return the site from which the astronomical information if gathered. | ||||||||||||
| 238 | |||||||||||||
| 239 | =cut | ||||||||||||
| 240 | |||||||||||||
| 241 | 1 | ▶ | sub astronomical { shift->{astronomical} } | ||||||||||
|
Subroutine
astronomical: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 242 | |||||||||||||
| 243 | =head2 technologcal | ||||||||||||
| 244 | |||||||||||||
| 245 | my $technological_reference = $hex->technological; | ||||||||||||
| 246 | |||||||||||||
| 247 | This will return the site from which the technological information if gathered. | ||||||||||||
| 248 | |||||||||||||
| 249 | =cut | ||||||||||||
| 250 | |||||||||||||
| 251 | 3 | ▶ | sub technological { shift->{technological} } | ||||||||||
|
Subroutine
technological: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 252 | |||||||||||||
| 253 | =head1 TODO | ||||||||||||
| 254 | |||||||||||||
| 255 | o Perhaps include some interpretation engine? Which takes the hexagram and | ||||||||||||
| 256 | the headlines and predicts the future? | ||||||||||||
| 257 | o Stop thinking about this module | ||||||||||||
| 258 | |||||||||||||
| 259 | =head1 SHOWING YOUR APPRECIATION | ||||||||||||
| 260 | |||||||||||||
| 261 | There was a thread on london.pm mailing list about working in a vacumn | ||||||||||||
| 262 | - that it was a bit depressing to keep writing modules but never get | ||||||||||||
| 263 | any feedback. So, if you use and like this module then please send me | ||||||||||||
| 264 | an email and make my day. | ||||||||||||
| 265 | |||||||||||||
| 266 | All it takes is a few little bytes. | ||||||||||||
| 267 | |||||||||||||
| 268 | (Leon wrote that, not me!) | ||||||||||||
| 269 | |||||||||||||
| 270 | =head1 AUTHOR | ||||||||||||
| 271 | |||||||||||||
| 272 | Stray Toaster E<lt>F<coder@stray-toaster.co.uk>E<gt> | ||||||||||||
| 273 | |||||||||||||
| 274 | =head2 With Thanks | ||||||||||||
| 275 | |||||||||||||
| 276 | o Robert Shea and Robert Anton Wilson for giving me both the Illuminatus! | ||||||||||||
| 277 | and the Schrodinger Cat books! | ||||||||||||
| 278 | |||||||||||||
| 279 | =head1 COPYRIGHT | ||||||||||||
| 280 | |||||||||||||
| 281 | Copyright (C) 2002, mwk | ||||||||||||
| 282 | |||||||||||||
| 283 | This module is free software; you can redistribute it or modify it | ||||||||||||
| 284 | under the same terms as Perl itself. | ||||||||||||
| 285 | |||||||||||||
| 286 | =head1 SANITY CLAUSE | ||||||||||||
| 287 | |||||||||||||
| 288 | Ain't you heard? There is no Sanity Clause. Surely that is obvious?! | ||||||||||||
| 289 | |||||||||||||
| 290 | =head1 So why doesn't this live in the ACME:: namespace? | ||||||||||||
| 291 | |||||||||||||
| 292 | A good, and very valid, question. | ||||||||||||
| 293 | |||||||||||||
| 294 | Perhaps I have taken this all a bit lightly, but I am sure that there are | ||||||||||||
| 295 | those who think their lives should be lived by what the IChing readings tell | ||||||||||||
| 296 | them. And far be it for me to make a mockery of their beliefs, as I am sure | ||||||||||||
| 297 | some of mine are just as wacky in their eyes. | ||||||||||||
| 298 | |||||||||||||
| 299 | So, in the interest of community relations, I have decided to pollute the top | ||||||||||||
| 300 | level namespace. As, indeed, someone might want to (upon being inspired and | ||||||||||||
| 301 | spurred by this module) create an IChing::Hexagram::Real or something. | ||||||||||||
| 302 | |||||||||||||
| 303 | =cut | ||||||||||||
| 304 | |||||||||||||
| 305 | 1 | return qw/No secret message in this one. Sorry!/; | |||||||||||