From bcbf441e09fb502cf64924ff2530fa144bdf52c5 Mon Sep 17 00:00:00 2001 From: Andreas Brachold Date: Mon, 13 Aug 2007 18:41:27 +0000 Subject: * Move files to trunk --- lib/Attribute/Handlers.pm | 845 +++ lib/Benchmark/Timer.pm | 618 ++ lib/Bundle/Xxv.pm | 81 + lib/CGI.pm | 7318 ++++++++++++++++++++++ lib/CGI/Apache.pm | 26 + lib/CGI/Carp.pm | 524 ++ lib/CGI/Cookie.pm | 478 ++ lib/CGI/Fast.pm | 230 + lib/CGI/Pretty.pm | 275 + lib/CGI/Push.pm | 328 + lib/CGI/Switch.pm | 27 + lib/CGI/Util.pm | 317 + lib/Class/MakeMethods.pm | 1520 +++++ lib/Class/MakeMethods/Attribute.pm | 143 + lib/Class/MakeMethods/Autoload.pm | 182 + lib/Class/MakeMethods/Basic.pm | 98 + lib/Class/MakeMethods/Basic/Array.pm | 422 ++ lib/Class/MakeMethods/Basic/Global.pm | 298 + lib/Class/MakeMethods/Basic/Hash.pm | 362 ++ lib/Class/MakeMethods/Composite.pm | 218 + lib/Class/MakeMethods/Composite/Array.pm | 794 +++ lib/Class/MakeMethods/Composite/Global.pm | 588 ++ lib/Class/MakeMethods/Composite/Hash.pm | 719 +++ lib/Class/MakeMethods/Composite/Inheritable.pm | 613 ++ lib/Class/MakeMethods/Composite/Universal.pm | 150 + lib/Class/MakeMethods/Docs/Catalog.pod | 888 +++ lib/Class/MakeMethods/Docs/Changes.pod | 661 ++ lib/Class/MakeMethods/Docs/Examples.pod | 554 ++ lib/Class/MakeMethods/Docs/ReadMe.pod | 279 + lib/Class/MakeMethods/Docs/RelatedModules.pod | 962 +++ lib/Class/MakeMethods/Docs/ToDo.pod | 296 + lib/Class/MakeMethods/Emulator.pm | 165 + lib/Class/MakeMethods/Emulator/AccessorFast.pm | 102 + lib/Class/MakeMethods/Emulator/Inheritable.pm | 162 + lib/Class/MakeMethods/Emulator/MethodMaker.pm | 676 +++ lib/Class/MakeMethods/Emulator/Singleton.pm | 85 + lib/Class/MakeMethods/Emulator/Struct.pm | 154 + lib/Class/MakeMethods/Emulator/accessors.pm | 122 + lib/Class/MakeMethods/Emulator/mcoder.pm | 116 + lib/Class/MakeMethods/Evaled.pm | 97 + lib/Class/MakeMethods/Evaled/Hash.pm | 349 ++ lib/Class/MakeMethods/Standard.pm | 68 + lib/Class/MakeMethods/Standard/Array.pm | 555 ++ lib/Class/MakeMethods/Standard/Global.pm | 405 ++ lib/Class/MakeMethods/Standard/Hash.pm | 501 ++ lib/Class/MakeMethods/Standard/Inheritable.pm | 428 ++ lib/Class/MakeMethods/Standard/Universal.pm | 336 ++ lib/Class/MakeMethods/Template.pm | 1255 ++++ lib/Class/MakeMethods/Template/Array.pm | 102 + lib/Class/MakeMethods/Template/Class.pm | 103 + lib/Class/MakeMethods/Template/ClassInherit.pm | 144 + lib/Class/MakeMethods/Template/ClassName.pm | 330 + lib/Class/MakeMethods/Template/ClassVar.pm | 178 + lib/Class/MakeMethods/Template/Flyweight.pm | 43 + lib/Class/MakeMethods/Template/Generic.pm | 2349 ++++++++ lib/Class/MakeMethods/Template/Global.pm | 97 + lib/Class/MakeMethods/Template/Hash.pm | 229 + lib/Class/MakeMethods/Template/Inheritable.pm | 154 + lib/Class/MakeMethods/Template/InsideOut.pm | 218 + lib/Class/MakeMethods/Template/PackageVar.pm | 168 + lib/Class/MakeMethods/Template/Ref.pm | 207 + lib/Class/MakeMethods/Template/Scalar.pm | 80 + lib/Class/MakeMethods/Template/Static.pm | 41 + lib/Class/MakeMethods/Template/Struct.pm | 41 + lib/Class/MakeMethods/Template/StructBuiltin.pm | 148 + lib/Class/MakeMethods/Template/Universal.pm | 415 ++ lib/Class/MakeMethods/Utility/ArraySplicer.pm | 243 + lib/Class/MakeMethods/Utility/DiskCache.pm | 165 + lib/Class/MakeMethods/Utility/Inheritable.pm | 126 + lib/Class/MakeMethods/Utility/Ref.pm | 171 + lib/Class/MakeMethods/Utility/TextBuilder.pm | 207 + lib/Config/Tiny.pm | 248 + lib/Date/Manip.pm | 7362 +++++++++++++++++++++++ lib/Digest/HMAC.pm | 111 + lib/Digest/HMAC_MD5.pm | 71 + lib/Digest/HMAC_SHA1.pm | 71 + lib/Event/File.pm | 92 + lib/Event/File/tail.pm | 675 +++ lib/GD/Graph/Data.pm | 725 +++ lib/GD/Graph/Error.pm | 346 ++ lib/GD/Graph/FAQ.pod | 130 + lib/GD/Graph/area.pm | 112 + lib/GD/Graph/axestype3d.pm | 787 +++ lib/GD/Graph/bars.pm | 372 ++ lib/GD/Graph/bars3d.pm | 349 ++ lib/GD/Graph/colour.pm | 371 ++ lib/GD/Graph/cylinder.pm | 126 + lib/GD/Graph/cylinder3d.pm | 30 + lib/GD/Graph/hbars.pm | 71 + lib/GD/Graph/lines.pm | 182 + lib/GD/Graph/lines3d.pm | 522 ++ lib/GD/Graph/linespoints.pm | 46 + lib/GD/Graph/mixed.pm | 99 + lib/GD/Graph/pie.pm | 446 ++ lib/GD/Graph/pie3d.pm | 331 + lib/GD/Graph/points.pm | 183 + lib/GD/Graph/utils.pm | 49 + lib/GD/Graph3d.pm | 157 + lib/HTML/TextToHTML.pm | 5266 ++++++++++++++++ lib/Locale/Maketext/Extract.pm | 502 ++ lib/Locale/Maketext/Extract/Run.pm | 83 + lib/Locale/Maketext/Lexicon.pm | 461 ++ lib/Locale/Maketext/Lexicon/Auto.pm | 59 + lib/Locale/Maketext/Lexicon/Gettext.pm | 251 + lib/Locale/Maketext/Lexicon/Msgcat.pm | 123 + lib/Locale/Maketext/Lexicon/Tie.pm | 67 + lib/MP3/Icecast.pm | 727 +++ lib/MP3/Info.pm | 1563 +++++ lib/Mail/SendEasy.pm | 743 +++ lib/Mail/SendEasy/AUTH.pm | 171 + lib/Mail/SendEasy/Base64.pm | 103 + lib/Mail/SendEasy/IOScalar.pm | 95 + lib/Mail/SendEasy/SMTP.pm | 365 ++ lib/MediaLibParser.pm | 310 + lib/MediaLibParser/DVDPalace.pm | 330 + lib/MediaLibParser/IMDb.pm | 74 + lib/Module/Reload.pm | 79 + lib/Net/Amazon.pm | 1255 ++++ lib/Net/Amazon/Attribute/Review.pm | 104 + lib/Net/Amazon/Attribute/ReviewSet.pm | 137 + lib/Net/Amazon/Property.pm | 320 + lib/Net/Amazon/Property/Book.pm | 152 + lib/Net/Amazon/Property/DVD.pm | 156 + lib/Net/Amazon/Property/Music.pm | 161 + lib/Net/Amazon/Request.pm | 221 + lib/Net/Amazon/Request/ASIN.pm | 139 + lib/Net/Amazon/Request/Artist.pm | 86 + lib/Net/Amazon/Request/Blended.pm | 80 + lib/Net/Amazon/Request/BrowseNode.pm | 137 + lib/Net/Amazon/Request/Exchange.pm | 91 + lib/Net/Amazon/Request/Keyword.pm | 90 + lib/Net/Amazon/Request/Manufacturer.pm | 78 + lib/Net/Amazon/Request/Power.pm | 95 + lib/Net/Amazon/Request/Seller.pm | 84 + lib/Net/Amazon/Request/Similar.pm | 95 + lib/Net/Amazon/Request/Sort.pm | 246 + lib/Net/Amazon/Request/TextStream.pm | 76 + lib/Net/Amazon/Request/UPC.pm | 94 + lib/Net/Amazon/Request/Wishlist.pm | 89 + lib/Net/Amazon/Response.pm | 214 + lib/Net/Amazon/Response/ASIN.pm | 28 + lib/Net/Amazon/Response/Artist.pm | 29 + lib/Net/Amazon/Response/Blended.pm | 73 + lib/Net/Amazon/Response/BrowseNode.pm | 29 + lib/Net/Amazon/Response/Exchange.pm | 81 + lib/Net/Amazon/Response/Keyword.pm | 29 + lib/Net/Amazon/Response/Manufacturer.pm | 29 + lib/Net/Amazon/Response/Power.pm | 28 + lib/Net/Amazon/Response/Seller.pm | 78 + lib/Net/Amazon/Response/Similar.pm | 28 + lib/Net/Amazon/Response/TextStream.pm | 28 + lib/Net/Amazon/Response/UPC.pm | 40 + lib/Net/Amazon/Response/Wishlist.pm | 29 + lib/Net/Amazon/Result/Seller.pm | 130 + lib/Net/Amazon/Result/Seller/Listing.pm | 146 + lib/Net/IP/Match/Regexp.pm | 293 + lib/Paths.pm | 3 + lib/Proc/Killfam.pm | 83 + lib/SOAP/Transport/HTTP/Event.pm | 76 + lib/Template.pm | 961 +++ lib/Template/Base.pm | 314 + lib/Template/Config.pm | 467 ++ lib/Template/Constants.pm | 287 + lib/Template/Context.pm | 1570 +++++ lib/Template/Directive.pm | 1004 ++++ lib/Template/Document.pm | 492 ++ lib/Template/Exception.pm | 254 + lib/Template/FAQ.pod | 329 + lib/Template/Filters.pm | 1448 +++++ lib/Template/Grammar.pm | 6179 +++++++++++++++++++ lib/Template/Iterator.pm | 456 ++ lib/Template/Library/HTML.pod | 316 + lib/Template/Library/PostScript.pod | 78 + lib/Template/Library/Splash.pod | 1030 ++++ lib/Template/Manual.pod | 180 + lib/Template/Manual/Config.pod | 2122 +++++++ lib/Template/Manual/Credits.pod | 188 + lib/Template/Manual/Directives.pod | 2179 +++++++ lib/Template/Manual/Filters.pod | 529 ++ lib/Template/Manual/Internals.pod | 556 ++ lib/Template/Manual/Intro.pod | 295 + lib/Template/Manual/Plugins.pod | 552 ++ lib/Template/Manual/Refs.pod | 171 + lib/Template/Manual/Syntax.pod | 306 + lib/Template/Manual/VMethods.pod | 529 ++ lib/Template/Manual/Variables.pod | 868 +++ lib/Template/Manual/Views.pod | 642 ++ lib/Template/Modules.pod | 448 ++ lib/Template/Namespace/Constants.pm | 205 + lib/Template/Parser.pm | 1446 +++++ lib/Template/Plugin.pm | 409 ++ lib/Template/Plugin/Autoformat.pm | 242 + lib/Template/Plugin/CGI.pm | 168 + lib/Template/Plugin/DBI.pm | 947 +++ lib/Template/Plugin/Datafile.pm | 198 + lib/Template/Plugin/Date.pm | 361 ++ lib/Template/Plugin/Directory.pm | 410 ++ lib/Template/Plugin/Dumper.pm | 179 + lib/Template/Plugin/File.pm | 416 ++ lib/Template/Plugin/Filter.pm | 436 ++ lib/Template/Plugin/Format.pm | 124 + lib/Template/Plugin/GD/Constants.pm | 138 + lib/Template/Plugin/GD/Graph/area.pm | 148 + lib/Template/Plugin/GD/Graph/bars.pm | 191 + lib/Template/Plugin/GD/Graph/bars3d.pm | 166 + lib/Template/Plugin/GD/Graph/lines.pm | 178 + lib/Template/Plugin/GD/Graph/lines3d.pm | 166 + lib/Template/Plugin/GD/Graph/linespoints.pm | 158 + lib/Template/Plugin/GD/Graph/mixed.pm | 176 + lib/Template/Plugin/GD/Graph/pie.pm | 141 + lib/Template/Plugin/GD/Graph/pie3d.pm | 145 + lib/Template/Plugin/GD/Graph/points.pm | 155 + lib/Template/Plugin/GD/Image.pm | 184 + lib/Template/Plugin/GD/Polygon.pm | 155 + lib/Template/Plugin/GD/Text.pm | 140 + lib/Template/Plugin/GD/Text/Align.pm | 147 + lib/Template/Plugin/GD/Text/Wrap.pm | 183 + lib/Template/Plugin/HTML.pm | 197 + lib/Template/Plugin/Image.pm | 425 ++ lib/Template/Plugin/Iterator.pm | 118 + lib/Template/Plugin/Pod.pm | 116 + lib/Template/Plugin/Procedural.pm | 170 + lib/Template/Plugin/String.pm | 796 +++ lib/Template/Plugin/Table.pm | 464 ++ lib/Template/Plugin/URL.pm | 236 + lib/Template/Plugin/View.pm | 127 + lib/Template/Plugin/Wrap.pm | 162 + lib/Template/Plugin/XML/DOM.pm | 841 +++ lib/Template/Plugin/XML/RSS.pm | 194 + lib/Template/Plugin/XML/Simple.pm | 124 + lib/Template/Plugin/XML/Style.pm | 357 ++ lib/Template/Plugin/XML/XPath.pm | 284 + lib/Template/Plugins.pm | 1041 ++++ lib/Template/Provider.pm | 1449 +++++ lib/Template/Service.pm | 775 +++ lib/Template/Stash.pm | 1040 ++++ lib/Template/Stash/Context.pm | 791 +++ lib/Template/Stash/XS.pm | 176 + lib/Template/Test.pm | 711 +++ lib/Template/Tools/tpage.pod | 76 + lib/Template/Tools/ttree.pod | 332 + lib/Template/Tutorial.pod | 109 + lib/Template/Tutorial/Datafile.pod | 461 ++ lib/Template/Tutorial/Web.pod | 801 +++ lib/Template/View.pm | 752 +++ lib/Term/ReadLine/Perl.pm | 144 + lib/Term/ReadLine/readline.pm | 4054 +++++++++++++ lib/Text/ASCIITable.pm | 1037 ++++ lib/Text/ASCIITable/Wrap.pm | 97 + lib/Text/Wrap.pm | 106 + lib/Tools.pm | 607 ++ lib/URI.pm | 1019 ++++ lib/URI/Escape.pm | 218 + lib/URI/Heuristic.pm | 224 + lib/URI/QueryParam.pm | 200 + lib/URI/Split.pm | 96 + lib/URI/URL.pm | 305 + lib/URI/WithBase.pm | 171 + lib/URI/_foreign.pm | 6 + lib/URI/_generic.pm | 249 + lib/URI/_ldap.pm | 140 + lib/URI/_login.pm | 10 + lib/URI/_query.pm | 81 + lib/URI/_segment.pm | 20 + lib/URI/_server.pm | 106 + lib/URI/_userpass.pm | 51 + lib/URI/data.pm | 139 + lib/URI/file.pm | 329 + lib/URI/file/Base.pm | 80 + lib/URI/file/FAT.pm | 23 + lib/URI/file/Mac.pm | 120 + lib/URI/file/OS2.pm | 28 + lib/URI/file/QNX.pm | 18 + lib/URI/file/Unix.pm | 55 + lib/URI/file/Win32.pm | 84 + lib/URI/ftp.pm | 45 + lib/URI/gopher.pm | 94 + lib/URI/http.pm | 25 + lib/URI/https.pm | 7 + lib/URI/ldap.pm | 122 + lib/URI/ldapi.pm | 30 + lib/URI/ldaps.pm | 7 + lib/URI/mailto.pm | 72 + lib/URI/mms.pm | 8 + lib/URI/news.pm | 68 + lib/URI/nntp.pm | 6 + lib/URI/pop.pm | 68 + lib/URI/rlogin.pm | 7 + lib/URI/rsync.pm | 12 + lib/URI/rtsp.pm | 8 + lib/URI/rtspu.pm | 8 + lib/URI/sip.pm | 86 + lib/URI/sips.pm | 7 + lib/URI/snews.pm | 8 + lib/URI/ssh.pm | 9 + lib/URI/telnet.pm | 7 + lib/URI/tn3270.pm | 7 + lib/URI/urn.pm | 97 + lib/URI/urn/isbn.pm | 58 + lib/URI/urn/oid.pm | 18 + lib/XML/Dumper.pm | 897 +++ lib/XML/Simple.pm | 3041 ++++++++++ lib/XML/Stream.pm | 3268 ++++++++++ lib/XML/Stream/Namespace.pm | 190 + lib/XML/Stream/Node.pm | 944 +++ lib/XML/Stream/Parser.pm | 567 ++ lib/XML/Stream/Parser/DTD.pm | 769 +++ lib/XML/Stream/Tree.pm | 682 +++ lib/XML/Stream/XPath.pm | 50 + lib/XML/Stream/XPath/Op.pm | 919 +++ lib/XML/Stream/XPath/Query.pm | 374 ++ lib/XML/Stream/XPath/Value.pm | 153 + lib/XXV/MODULES/AUTOTIMER.pm | 1359 +++++ lib/XXV/MODULES/CHANNELS.pm | 1018 ++++ lib/XXV/MODULES/CHRONICLE.pm | 249 + lib/XXV/MODULES/CONFIG.pm | 283 + lib/XXV/MODULES/EPG.pm | 1243 ++++ lib/XXV/MODULES/EVENTS.pm | 190 + lib/XXV/MODULES/GRAB.pm | 290 + lib/XXV/MODULES/HTTPD.pm | 588 ++ lib/XXV/MODULES/INTERFACE.pm | 179 + lib/XXV/MODULES/LOGREAD.pm | 221 + lib/XXV/MODULES/MEDIALIB.pm | 1328 ++++ lib/XXV/MODULES/MUSIC.pm | 1352 +++++ lib/XXV/MODULES/RECORDS.pm | 2136 +++++++ lib/XXV/MODULES/REMOTE.pm | 279 + lib/XXV/MODULES/REPORT.pm | 288 + lib/XXV/MODULES/ROBOT.pm | 180 + lib/XXV/MODULES/SHARE.pm | 280 + lib/XXV/MODULES/STATUS.pm | 771 +++ lib/XXV/MODULES/STREAM.pm | 179 + lib/XXV/MODULES/SVDRP.pm | 228 + lib/XXV/MODULES/TELNET.pm | 326 + lib/XXV/MODULES/TIMERS.pm | 1721 ++++++ lib/XXV/MODULES/USER.pm | 919 +++ lib/XXV/MODULES/VTX.pm | 1396 +++++ lib/XXV/MODULES/WAPD.pm | 354 ++ lib/XXV/OUTPUT/Ajax.pm | 231 + lib/XXV/OUTPUT/Console.pm | 741 +++ lib/XXV/OUTPUT/Dump.pm | 62 + lib/XXV/OUTPUT/HTML/PUSH.pm | 95 + lib/XXV/OUTPUT/HTML/WAIT.pm | 169 + lib/XXV/OUTPUT/Html.pm | 851 +++ lib/XXV/OUTPUT/NEWS/JABBER.pm | 296 + lib/XXV/OUTPUT/NEWS/MAIL.pm | 313 + lib/XXV/OUTPUT/NEWS/RSS.pm | 233 + lib/XXV/OUTPUT/NEWS/VDR.pm | 165 + lib/XXV/OUTPUT/Wml.pm | 431 ++ 348 files changed, 152731 insertions(+) create mode 100644 lib/Attribute/Handlers.pm create mode 100755 lib/Benchmark/Timer.pm create mode 100644 lib/Bundle/Xxv.pm create mode 100644 lib/CGI.pm create mode 100644 lib/CGI/Apache.pm create mode 100644 lib/CGI/Carp.pm create mode 100644 lib/CGI/Cookie.pm create mode 100644 lib/CGI/Fast.pm create mode 100644 lib/CGI/Pretty.pm create mode 100644 lib/CGI/Push.pm create mode 100644 lib/CGI/Switch.pm create mode 100644 lib/CGI/Util.pm create mode 100644 lib/Class/MakeMethods.pm create mode 100644 lib/Class/MakeMethods/Attribute.pm create mode 100644 lib/Class/MakeMethods/Autoload.pm create mode 100644 lib/Class/MakeMethods/Basic.pm create mode 100644 lib/Class/MakeMethods/Basic/Array.pm create mode 100644 lib/Class/MakeMethods/Basic/Global.pm create mode 100644 lib/Class/MakeMethods/Basic/Hash.pm create mode 100644 lib/Class/MakeMethods/Composite.pm create mode 100644 lib/Class/MakeMethods/Composite/Array.pm create mode 100644 lib/Class/MakeMethods/Composite/Global.pm create mode 100644 lib/Class/MakeMethods/Composite/Hash.pm create mode 100644 lib/Class/MakeMethods/Composite/Inheritable.pm create mode 100644 lib/Class/MakeMethods/Composite/Universal.pm create mode 100644 lib/Class/MakeMethods/Docs/Catalog.pod create mode 100644 lib/Class/MakeMethods/Docs/Changes.pod create mode 100644 lib/Class/MakeMethods/Docs/Examples.pod create mode 100644 lib/Class/MakeMethods/Docs/ReadMe.pod create mode 100644 lib/Class/MakeMethods/Docs/RelatedModules.pod create mode 100644 lib/Class/MakeMethods/Docs/ToDo.pod create mode 100644 lib/Class/MakeMethods/Emulator.pm create mode 100644 lib/Class/MakeMethods/Emulator/AccessorFast.pm create mode 100644 lib/Class/MakeMethods/Emulator/Inheritable.pm create mode 100644 lib/Class/MakeMethods/Emulator/MethodMaker.pm create mode 100644 lib/Class/MakeMethods/Emulator/Singleton.pm create mode 100644 lib/Class/MakeMethods/Emulator/Struct.pm create mode 100644 lib/Class/MakeMethods/Emulator/accessors.pm create mode 100644 lib/Class/MakeMethods/Emulator/mcoder.pm create mode 100644 lib/Class/MakeMethods/Evaled.pm create mode 100644 lib/Class/MakeMethods/Evaled/Hash.pm create mode 100644 lib/Class/MakeMethods/Standard.pm create mode 100644 lib/Class/MakeMethods/Standard/Array.pm create mode 100644 lib/Class/MakeMethods/Standard/Global.pm create mode 100644 lib/Class/MakeMethods/Standard/Hash.pm create mode 100644 lib/Class/MakeMethods/Standard/Inheritable.pm create mode 100644 lib/Class/MakeMethods/Standard/Universal.pm create mode 100644 lib/Class/MakeMethods/Template.pm create mode 100644 lib/Class/MakeMethods/Template/Array.pm create mode 100644 lib/Class/MakeMethods/Template/Class.pm create mode 100644 lib/Class/MakeMethods/Template/ClassInherit.pm create mode 100644 lib/Class/MakeMethods/Template/ClassName.pm create mode 100644 lib/Class/MakeMethods/Template/ClassVar.pm create mode 100644 lib/Class/MakeMethods/Template/Flyweight.pm create mode 100644 lib/Class/MakeMethods/Template/Generic.pm create mode 100644 lib/Class/MakeMethods/Template/Global.pm create mode 100644 lib/Class/MakeMethods/Template/Hash.pm create mode 100644 lib/Class/MakeMethods/Template/Inheritable.pm create mode 100644 lib/Class/MakeMethods/Template/InsideOut.pm create mode 100644 lib/Class/MakeMethods/Template/PackageVar.pm create mode 100644 lib/Class/MakeMethods/Template/Ref.pm create mode 100644 lib/Class/MakeMethods/Template/Scalar.pm create mode 100644 lib/Class/MakeMethods/Template/Static.pm create mode 100644 lib/Class/MakeMethods/Template/Struct.pm create mode 100644 lib/Class/MakeMethods/Template/StructBuiltin.pm create mode 100644 lib/Class/MakeMethods/Template/Universal.pm create mode 100644 lib/Class/MakeMethods/Utility/ArraySplicer.pm create mode 100644 lib/Class/MakeMethods/Utility/DiskCache.pm create mode 100644 lib/Class/MakeMethods/Utility/Inheritable.pm create mode 100644 lib/Class/MakeMethods/Utility/Ref.pm create mode 100644 lib/Class/MakeMethods/Utility/TextBuilder.pm create mode 100644 lib/Config/Tiny.pm create mode 100644 lib/Date/Manip.pm create mode 100644 lib/Digest/HMAC.pm create mode 100644 lib/Digest/HMAC_MD5.pm create mode 100644 lib/Digest/HMAC_SHA1.pm create mode 100644 lib/Event/File.pm create mode 100644 lib/Event/File/tail.pm create mode 100644 lib/GD/Graph/Data.pm create mode 100644 lib/GD/Graph/Error.pm create mode 100644 lib/GD/Graph/FAQ.pod create mode 100644 lib/GD/Graph/area.pm create mode 100644 lib/GD/Graph/axestype3d.pm create mode 100644 lib/GD/Graph/bars.pm create mode 100644 lib/GD/Graph/bars3d.pm create mode 100644 lib/GD/Graph/colour.pm create mode 100644 lib/GD/Graph/cylinder.pm create mode 100644 lib/GD/Graph/cylinder3d.pm create mode 100644 lib/GD/Graph/hbars.pm create mode 100644 lib/GD/Graph/lines.pm create mode 100644 lib/GD/Graph/lines3d.pm create mode 100644 lib/GD/Graph/linespoints.pm create mode 100644 lib/GD/Graph/mixed.pm create mode 100644 lib/GD/Graph/pie.pm create mode 100644 lib/GD/Graph/pie3d.pm create mode 100644 lib/GD/Graph/points.pm create mode 100644 lib/GD/Graph/utils.pm create mode 100644 lib/GD/Graph3d.pm create mode 100644 lib/HTML/TextToHTML.pm create mode 100644 lib/Locale/Maketext/Extract.pm create mode 100644 lib/Locale/Maketext/Extract/Run.pm create mode 100644 lib/Locale/Maketext/Lexicon.pm create mode 100644 lib/Locale/Maketext/Lexicon/Auto.pm create mode 100644 lib/Locale/Maketext/Lexicon/Gettext.pm create mode 100644 lib/Locale/Maketext/Lexicon/Msgcat.pm create mode 100644 lib/Locale/Maketext/Lexicon/Tie.pm create mode 100644 lib/MP3/Icecast.pm create mode 100644 lib/MP3/Info.pm create mode 100644 lib/Mail/SendEasy.pm create mode 100644 lib/Mail/SendEasy/AUTH.pm create mode 100644 lib/Mail/SendEasy/Base64.pm create mode 100644 lib/Mail/SendEasy/IOScalar.pm create mode 100644 lib/Mail/SendEasy/SMTP.pm create mode 100644 lib/MediaLibParser.pm create mode 100644 lib/MediaLibParser/DVDPalace.pm create mode 100644 lib/MediaLibParser/IMDb.pm create mode 100644 lib/Module/Reload.pm create mode 100644 lib/Net/Amazon.pm create mode 100644 lib/Net/Amazon/Attribute/Review.pm create mode 100644 lib/Net/Amazon/Attribute/ReviewSet.pm create mode 100644 lib/Net/Amazon/Property.pm create mode 100644 lib/Net/Amazon/Property/Book.pm create mode 100644 lib/Net/Amazon/Property/DVD.pm create mode 100644 lib/Net/Amazon/Property/Music.pm create mode 100644 lib/Net/Amazon/Request.pm create mode 100644 lib/Net/Amazon/Request/ASIN.pm create mode 100644 lib/Net/Amazon/Request/Artist.pm create mode 100644 lib/Net/Amazon/Request/Blended.pm create mode 100644 lib/Net/Amazon/Request/BrowseNode.pm create mode 100644 lib/Net/Amazon/Request/Exchange.pm create mode 100644 lib/Net/Amazon/Request/Keyword.pm create mode 100644 lib/Net/Amazon/Request/Manufacturer.pm create mode 100644 lib/Net/Amazon/Request/Power.pm create mode 100644 lib/Net/Amazon/Request/Seller.pm create mode 100644 lib/Net/Amazon/Request/Similar.pm create mode 100644 lib/Net/Amazon/Request/Sort.pm create mode 100644 lib/Net/Amazon/Request/TextStream.pm create mode 100644 lib/Net/Amazon/Request/UPC.pm create mode 100644 lib/Net/Amazon/Request/Wishlist.pm create mode 100644 lib/Net/Amazon/Response.pm create mode 100644 lib/Net/Amazon/Response/ASIN.pm create mode 100644 lib/Net/Amazon/Response/Artist.pm create mode 100644 lib/Net/Amazon/Response/Blended.pm create mode 100644 lib/Net/Amazon/Response/BrowseNode.pm create mode 100644 lib/Net/Amazon/Response/Exchange.pm create mode 100644 lib/Net/Amazon/Response/Keyword.pm create mode 100644 lib/Net/Amazon/Response/Manufacturer.pm create mode 100644 lib/Net/Amazon/Response/Power.pm create mode 100644 lib/Net/Amazon/Response/Seller.pm create mode 100644 lib/Net/Amazon/Response/Similar.pm create mode 100644 lib/Net/Amazon/Response/TextStream.pm create mode 100644 lib/Net/Amazon/Response/UPC.pm create mode 100644 lib/Net/Amazon/Response/Wishlist.pm create mode 100644 lib/Net/Amazon/Result/Seller.pm create mode 100644 lib/Net/Amazon/Result/Seller/Listing.pm create mode 100644 lib/Net/IP/Match/Regexp.pm create mode 100644 lib/Paths.pm create mode 100644 lib/Proc/Killfam.pm create mode 100755 lib/SOAP/Transport/HTTP/Event.pm create mode 100644 lib/Template.pm create mode 100644 lib/Template/Base.pm create mode 100644 lib/Template/Config.pm create mode 100644 lib/Template/Constants.pm create mode 100644 lib/Template/Context.pm create mode 100644 lib/Template/Directive.pm create mode 100644 lib/Template/Document.pm create mode 100644 lib/Template/Exception.pm create mode 100644 lib/Template/FAQ.pod create mode 100644 lib/Template/Filters.pm create mode 100644 lib/Template/Grammar.pm create mode 100644 lib/Template/Iterator.pm create mode 100644 lib/Template/Library/HTML.pod create mode 100644 lib/Template/Library/PostScript.pod create mode 100644 lib/Template/Library/Splash.pod create mode 100644 lib/Template/Manual.pod create mode 100644 lib/Template/Manual/Config.pod create mode 100644 lib/Template/Manual/Credits.pod create mode 100644 lib/Template/Manual/Directives.pod create mode 100644 lib/Template/Manual/Filters.pod create mode 100644 lib/Template/Manual/Internals.pod create mode 100644 lib/Template/Manual/Intro.pod create mode 100644 lib/Template/Manual/Plugins.pod create mode 100644 lib/Template/Manual/Refs.pod create mode 100644 lib/Template/Manual/Syntax.pod create mode 100644 lib/Template/Manual/VMethods.pod create mode 100644 lib/Template/Manual/Variables.pod create mode 100644 lib/Template/Manual/Views.pod create mode 100644 lib/Template/Modules.pod create mode 100644 lib/Template/Namespace/Constants.pm create mode 100644 lib/Template/Parser.pm create mode 100644 lib/Template/Plugin.pm create mode 100644 lib/Template/Plugin/Autoformat.pm create mode 100644 lib/Template/Plugin/CGI.pm create mode 100644 lib/Template/Plugin/DBI.pm create mode 100644 lib/Template/Plugin/Datafile.pm create mode 100644 lib/Template/Plugin/Date.pm create mode 100644 lib/Template/Plugin/Directory.pm create mode 100644 lib/Template/Plugin/Dumper.pm create mode 100644 lib/Template/Plugin/File.pm create mode 100644 lib/Template/Plugin/Filter.pm create mode 100644 lib/Template/Plugin/Format.pm create mode 100644 lib/Template/Plugin/GD/Constants.pm create mode 100644 lib/Template/Plugin/GD/Graph/area.pm create mode 100644 lib/Template/Plugin/GD/Graph/bars.pm create mode 100644 lib/Template/Plugin/GD/Graph/bars3d.pm create mode 100644 lib/Template/Plugin/GD/Graph/lines.pm create mode 100644 lib/Template/Plugin/GD/Graph/lines3d.pm create mode 100644 lib/Template/Plugin/GD/Graph/linespoints.pm create mode 100644 lib/Template/Plugin/GD/Graph/mixed.pm create mode 100644 lib/Template/Plugin/GD/Graph/pie.pm create mode 100644 lib/Template/Plugin/GD/Graph/pie3d.pm create mode 100644 lib/Template/Plugin/GD/Graph/points.pm create mode 100644 lib/Template/Plugin/GD/Image.pm create mode 100644 lib/Template/Plugin/GD/Polygon.pm create mode 100644 lib/Template/Plugin/GD/Text.pm create mode 100644 lib/Template/Plugin/GD/Text/Align.pm create mode 100644 lib/Template/Plugin/GD/Text/Wrap.pm create mode 100644 lib/Template/Plugin/HTML.pm create mode 100644 lib/Template/Plugin/Image.pm create mode 100644 lib/Template/Plugin/Iterator.pm create mode 100644 lib/Template/Plugin/Pod.pm create mode 100644 lib/Template/Plugin/Procedural.pm create mode 100644 lib/Template/Plugin/String.pm create mode 100644 lib/Template/Plugin/Table.pm create mode 100644 lib/Template/Plugin/URL.pm create mode 100644 lib/Template/Plugin/View.pm create mode 100644 lib/Template/Plugin/Wrap.pm create mode 100644 lib/Template/Plugin/XML/DOM.pm create mode 100644 lib/Template/Plugin/XML/RSS.pm create mode 100644 lib/Template/Plugin/XML/Simple.pm create mode 100644 lib/Template/Plugin/XML/Style.pm create mode 100644 lib/Template/Plugin/XML/XPath.pm create mode 100644 lib/Template/Plugins.pm create mode 100644 lib/Template/Provider.pm create mode 100644 lib/Template/Service.pm create mode 100644 lib/Template/Stash.pm create mode 100644 lib/Template/Stash/Context.pm create mode 100644 lib/Template/Stash/XS.pm create mode 100644 lib/Template/Test.pm create mode 100644 lib/Template/Tools/tpage.pod create mode 100644 lib/Template/Tools/ttree.pod create mode 100644 lib/Template/Tutorial.pod create mode 100644 lib/Template/Tutorial/Datafile.pod create mode 100644 lib/Template/Tutorial/Web.pod create mode 100644 lib/Template/View.pm create mode 100644 lib/Term/ReadLine/Perl.pm create mode 100644 lib/Term/ReadLine/readline.pm create mode 100644 lib/Text/ASCIITable.pm create mode 100644 lib/Text/ASCIITable/Wrap.pm create mode 100644 lib/Text/Wrap.pm create mode 100644 lib/Tools.pm create mode 100644 lib/URI.pm create mode 100644 lib/URI/Escape.pm create mode 100644 lib/URI/Heuristic.pm create mode 100644 lib/URI/QueryParam.pm create mode 100644 lib/URI/Split.pm create mode 100644 lib/URI/URL.pm create mode 100644 lib/URI/WithBase.pm create mode 100644 lib/URI/_foreign.pm create mode 100644 lib/URI/_generic.pm create mode 100644 lib/URI/_ldap.pm create mode 100644 lib/URI/_login.pm create mode 100644 lib/URI/_query.pm create mode 100644 lib/URI/_segment.pm create mode 100644 lib/URI/_server.pm create mode 100644 lib/URI/_userpass.pm create mode 100644 lib/URI/data.pm create mode 100644 lib/URI/file.pm create mode 100644 lib/URI/file/Base.pm create mode 100644 lib/URI/file/FAT.pm create mode 100644 lib/URI/file/Mac.pm create mode 100644 lib/URI/file/OS2.pm create mode 100644 lib/URI/file/QNX.pm create mode 100644 lib/URI/file/Unix.pm create mode 100644 lib/URI/file/Win32.pm create mode 100644 lib/URI/ftp.pm create mode 100644 lib/URI/gopher.pm create mode 100644 lib/URI/http.pm create mode 100644 lib/URI/https.pm create mode 100644 lib/URI/ldap.pm create mode 100644 lib/URI/ldapi.pm create mode 100644 lib/URI/ldaps.pm create mode 100644 lib/URI/mailto.pm create mode 100644 lib/URI/mms.pm create mode 100644 lib/URI/news.pm create mode 100644 lib/URI/nntp.pm create mode 100644 lib/URI/pop.pm create mode 100644 lib/URI/rlogin.pm create mode 100644 lib/URI/rsync.pm create mode 100644 lib/URI/rtsp.pm create mode 100644 lib/URI/rtspu.pm create mode 100644 lib/URI/sip.pm create mode 100644 lib/URI/sips.pm create mode 100644 lib/URI/snews.pm create mode 100644 lib/URI/ssh.pm create mode 100644 lib/URI/telnet.pm create mode 100644 lib/URI/tn3270.pm create mode 100644 lib/URI/urn.pm create mode 100644 lib/URI/urn/isbn.pm create mode 100644 lib/URI/urn/oid.pm create mode 100644 lib/XML/Dumper.pm create mode 100644 lib/XML/Simple.pm create mode 100644 lib/XML/Stream.pm create mode 100644 lib/XML/Stream/Namespace.pm create mode 100644 lib/XML/Stream/Node.pm create mode 100644 lib/XML/Stream/Parser.pm create mode 100644 lib/XML/Stream/Parser/DTD.pm create mode 100644 lib/XML/Stream/Tree.pm create mode 100644 lib/XML/Stream/XPath.pm create mode 100644 lib/XML/Stream/XPath/Op.pm create mode 100644 lib/XML/Stream/XPath/Query.pm create mode 100644 lib/XML/Stream/XPath/Value.pm create mode 100644 lib/XXV/MODULES/AUTOTIMER.pm create mode 100644 lib/XXV/MODULES/CHANNELS.pm create mode 100644 lib/XXV/MODULES/CHRONICLE.pm create mode 100644 lib/XXV/MODULES/CONFIG.pm create mode 100644 lib/XXV/MODULES/EPG.pm create mode 100644 lib/XXV/MODULES/EVENTS.pm create mode 100644 lib/XXV/MODULES/GRAB.pm create mode 100644 lib/XXV/MODULES/HTTPD.pm create mode 100644 lib/XXV/MODULES/INTERFACE.pm create mode 100644 lib/XXV/MODULES/LOGREAD.pm create mode 100644 lib/XXV/MODULES/MEDIALIB.pm create mode 100644 lib/XXV/MODULES/MUSIC.pm create mode 100644 lib/XXV/MODULES/RECORDS.pm create mode 100644 lib/XXV/MODULES/REMOTE.pm create mode 100644 lib/XXV/MODULES/REPORT.pm create mode 100644 lib/XXV/MODULES/ROBOT.pm create mode 100644 lib/XXV/MODULES/SHARE.pm create mode 100644 lib/XXV/MODULES/STATUS.pm create mode 100644 lib/XXV/MODULES/STREAM.pm create mode 100644 lib/XXV/MODULES/SVDRP.pm create mode 100644 lib/XXV/MODULES/TELNET.pm create mode 100644 lib/XXV/MODULES/TIMERS.pm create mode 100644 lib/XXV/MODULES/USER.pm create mode 100644 lib/XXV/MODULES/VTX.pm create mode 100644 lib/XXV/MODULES/WAPD.pm create mode 100644 lib/XXV/OUTPUT/Ajax.pm create mode 100644 lib/XXV/OUTPUT/Console.pm create mode 100644 lib/XXV/OUTPUT/Dump.pm create mode 100644 lib/XXV/OUTPUT/HTML/PUSH.pm create mode 100644 lib/XXV/OUTPUT/HTML/WAIT.pm create mode 100644 lib/XXV/OUTPUT/Html.pm create mode 100644 lib/XXV/OUTPUT/NEWS/JABBER.pm create mode 100644 lib/XXV/OUTPUT/NEWS/MAIL.pm create mode 100644 lib/XXV/OUTPUT/NEWS/RSS.pm create mode 100644 lib/XXV/OUTPUT/NEWS/VDR.pm create mode 100644 lib/XXV/OUTPUT/Wml.pm (limited to 'lib') diff --git a/lib/Attribute/Handlers.pm b/lib/Attribute/Handlers.pm new file mode 100644 index 0000000..a26ed18 --- /dev/null +++ b/lib/Attribute/Handlers.pm @@ -0,0 +1,845 @@ +package Attribute::Handlers; +use 5.006; +use Carp; +use warnings; +$VERSION = '0.78'; +# $DB::single=1; + +my %symcache; +sub findsym { + my ($pkg, $ref, $type) = @_; + return $symcache{$pkg,$ref} if $symcache{$pkg,$ref}; + $type ||= ref($ref); + my $found; + foreach my $sym ( values %{$pkg."::"} ) { + return $symcache{$pkg,$ref} = \$sym + if *{$sym}{$type} && *{$sym}{$type} == $ref; + } +} + +my %validtype = ( + VAR => [qw[SCALAR ARRAY HASH]], + ANY => [qw[SCALAR ARRAY HASH CODE]], + "" => [qw[SCALAR ARRAY HASH CODE]], + SCALAR => [qw[SCALAR]], + ARRAY => [qw[ARRAY]], + HASH => [qw[HASH]], + CODE => [qw[CODE]], +); +my %lastattr; +my @declarations; +my %raw; +my %phase; +my %sigil = (SCALAR=>'$', ARRAY=>'@', HASH=>'%'); +my $global_phase = 0; +my %global_phases = ( + BEGIN => 0, + CHECK => 1, + INIT => 2, + END => 3, +); +my @global_phases = qw(BEGIN CHECK INIT END); + +sub _usage_AH_ { + croak "Usage: use $_[0] autotie => {AttrName => TieClassName,...}"; +} + +my $qual_id = qr/^[_a-z]\w*(::[_a-z]\w*)*$/i; + +sub import { + my $class = shift @_; + return unless $class eq "Attribute::Handlers"; + while (@_) { + my $cmd = shift; + if ($cmd =~ /^autotie((?:ref)?)$/) { + my $tiedata = ($1 ? '$ref, ' : '') . '@$data'; + my $mapping = shift; + _usage_AH_ $class unless ref($mapping) eq 'HASH'; + while (my($attr, $tieclass) = each %$mapping) { + $tieclass =~ s/^([_a-z]\w*(::[_a-z]\w*)*)(.*)/$1/is; + my $args = $3||'()'; + _usage_AH_ $class unless $attr =~ $qual_id + && $tieclass =~ $qual_id + && eval "use base $tieclass; 1"; + if ($tieclass->isa('Exporter')) { + local $Exporter::ExportLevel = 2; + $tieclass->import(eval $args); + } + $attr =~ s/__CALLER__/caller(1)/e; + $attr = caller()."::".$attr unless $attr =~ /::/; + eval qq{ + sub $attr : ATTR(VAR) { + my (\$ref, \$data) = \@_[2,4]; + my \$was_arrayref = ref \$data eq 'ARRAY'; + \$data = [ \$data ] unless \$was_arrayref; + my \$type = ref(\$ref)||"value (".(\$ref||"").")"; + (\$type eq 'SCALAR')? tie \$\$ref,'$tieclass',$tiedata + :(\$type eq 'ARRAY') ? tie \@\$ref,'$tieclass',$tiedata + :(\$type eq 'HASH') ? tie \%\$ref,'$tieclass',$tiedata + : die "Can't autotie a \$type\n" + } 1 + } or die "Internal error: $@"; + } + } + else { + croak "Can't understand $_"; + } + } +} +sub _resolve_lastattr { + return unless $lastattr{ref}; + my $sym = findsym @lastattr{'pkg','ref'} + or die "Internal error: $lastattr{pkg} symbol went missing"; + my $name = *{$sym}{NAME}; + warn "Declaration of $name attribute in package $lastattr{pkg} may clash with future reserved word\n" + if $^W and $name !~ /[A-Z]/; + foreach ( @{$validtype{$lastattr{type}}} ) { + *{"$lastattr{pkg}::_ATTR_${_}_${name}"} = $lastattr{ref}; + } + %lastattr = (); +} + +sub AUTOLOAD { + my ($class) = $AUTOLOAD =~ m/(.*)::/g; + $AUTOLOAD =~ m/_ATTR_(.*?)_(.*)/ or + croak "Can't locate class method '$AUTOLOAD' via package '$class'"; + croak "Attribute handler '$3' doesn't handle $2 attributes"; +} + +sub DESTROY {} + +my $builtin = qr/lvalue|method|locked|unique|shared/; + +sub _gen_handler_AH_() { + return sub { + _resolve_lastattr; + my ($pkg, $ref, @attrs) = @_; + foreach (@attrs) { + my ($attr, $data) = /^([a-z_]\w*)(?:[(](.*)[)])?$/is or next; + if ($attr eq 'ATTR') { + $data ||= "ANY"; + $raw{$ref} = $data =~ s/\s*,?\s*RAWDATA\s*,?\s*//; + $phase{$ref}{BEGIN} = 1 + if $data =~ s/\s*,?\s*(BEGIN)\s*,?\s*//; + $phase{$ref}{INIT} = 1 + if $data =~ s/\s*,?\s*(INIT)\s*,?\s*//; + $phase{$ref}{END} = 1 + if $data =~ s/\s*,?\s*(END)\s*,?\s*//; + $phase{$ref}{CHECK} = 1 + if $data =~ s/\s*,?\s*(CHECK)\s*,?\s*// + || ! keys %{$phase{$ref}}; + # Added for cleanup to not pollute next call. + (%lastattr = ()), + croak "Can't have two ATTR specifiers on one subroutine" + if keys %lastattr; + croak "Bad attribute type: ATTR($data)" + unless $validtype{$data}; + %lastattr=(pkg=>$pkg,ref=>$ref,type=>$data); + } + else { + my $handler = $pkg->can($attr); + next unless $handler; + my $decl = [$pkg, $ref, $attr, $data, + $raw{$handler}, $phase{$handler}]; + foreach my $gphase (@global_phases) { + _apply_handler_AH_($decl,$gphase) + if $global_phases{$gphase} <= $global_phase; + } + if ($global_phase != 0) { + # if _gen_handler_AH_ is being called after + # CHECK it's for a lexical, so make sure + # it didn't want to run anything later + + local $Carp::CarpLevel = 2; + carp "Won't be able to apply END handler" + if $phase{$handler}{END}; + } + else { + push @declarations, $decl + } + } + $_ = undef; + } + return grep {defined && !/$builtin/} @attrs; + } +} + +*{"MODIFY_${_}_ATTRIBUTES"} = _gen_handler_AH_ foreach @{$validtype{ANY}}; +push @UNIVERSAL::ISA, 'Attribute::Handlers' + unless grep /^Attribute::Handlers$/, @UNIVERSAL::ISA; + +sub _apply_handler_AH_ { + my ($declaration, $phase) = @_; + my ($pkg, $ref, $attr, $data, $raw, $handlerphase) = @$declaration; + return unless $handlerphase->{$phase}; + # print STDERR "Handling $attr on $ref in $phase with [$data]\n"; + my $type = ref $ref; + my $handler = "_ATTR_${type}_${attr}"; + my $sym = findsym($pkg, $ref); + $sym ||= $type eq 'CODE' ? 'ANON' : 'LEXICAL'; + no warnings; + my $evaled = !$raw && eval("package $pkg; no warnings; + local \$SIG{__WARN__}=sub{die}; [$data]"); + $data = ($evaled && $data =~ /^\s*\[/) ? [$evaled] + : ($evaled) ? $evaled + : [$data]; + $pkg->$handler($sym, + (ref $sym eq 'GLOB' ? *{$sym}{ref $ref}||$ref : $ref), + $attr, + (@$data>1? $data : $data->[0]), + $phase, + ); + return 1; +} + +{ + no warnings 'void'; + CHECK { + $global_phase++; + _resolve_lastattr; + _apply_handler_AH_($_,'CHECK') foreach @declarations; + } + + INIT { + $global_phase++; + _apply_handler_AH_($_,'INIT') foreach @declarations + } +} + +END { $global_phase++; _apply_handler_AH_($_,'END') foreach @declarations } + +1; +__END__ + +=head1 NAME + +Attribute::Handlers - Simpler definition of attribute handlers + +=head1 VERSION + +This document describes version 0.78 of Attribute::Handlers, +released October 5, 2002. + +=head1 SYNOPSIS + + package MyClass; + require v5.6.0; + use Attribute::Handlers; + no warnings 'redefine'; + + + sub Good : ATTR(SCALAR) { + my ($package, $symbol, $referent, $attr, $data) = @_; + + # Invoked for any scalar variable with a :Good attribute, + # provided the variable was declared in MyClass (or + # a derived class) or typed to MyClass. + + # Do whatever to $referent here (executed in CHECK phase). + ... + } + + sub Bad : ATTR(SCALAR) { + # Invoked for any scalar variable with a :Bad attribute, + # provided the variable was declared in MyClass (or + # a derived class) or typed to MyClass. + ... + } + + sub Good : ATTR(ARRAY) { + # Invoked for any array variable with a :Good attribute, + # provided the variable was declared in MyClass (or + # a derived class) or typed to MyClass. + ... + } + + sub Good : ATTR(HASH) { + # Invoked for any hash variable with a :Good attribute, + # provided the variable was declared in MyClass (or + # a derived class) or typed to MyClass. + ... + } + + sub Ugly : ATTR(CODE) { + # Invoked for any subroutine declared in MyClass (or a + # derived class) with an :Ugly attribute. + ... + } + + sub Omni : ATTR { + # Invoked for any scalar, array, hash, or subroutine + # with an :Omni attribute, provided the variable or + # subroutine was declared in MyClass (or a derived class) + # or the variable was typed to MyClass. + # Use ref($_[2]) to determine what kind of referent it was. + ... + } + + + use Attribute::Handlers autotie => { Cycle => Tie::Cycle }; + + my $next : Cycle(['A'..'Z']); + + +=head1 DESCRIPTION + +This module, when inherited by a package, allows that package's class to +define attribute handler subroutines for specific attributes. Variables +and subroutines subsequently defined in that package, or in packages +derived from that package may be given attributes with the same names as +the attribute handler subroutines, which will then be called in one of +the compilation phases (i.e. in a C, C, C, or C +block). + +To create a handler, define it as a subroutine with the same name as +the desired attribute, and declare the subroutine itself with the +attribute C<:ATTR>. For example: + + package LoudDecl; + use Attribute::Handlers; + + sub Loud :ATTR { + my ($package, $symbol, $referent, $attr, $data, $phase) = @_; + print STDERR + ref($referent), " ", + *{$symbol}{NAME}, " ", + "($referent) ", "was just declared ", + "and ascribed the ${attr} attribute ", + "with data ($data)\n", + "in phase $phase\n"; + } + +This creates a handler for the attribute C<:Loud> in the class LoudDecl. +Thereafter, any subroutine declared with a C<:Loud> attribute in the class +LoudDecl: + + package LoudDecl; + + sub foo: Loud {...} + +causes the above handler to be invoked, and passed: + +=over + +=item [0] + +the name of the package into which it was declared; + +=item [1] + +a reference to the symbol table entry (typeglob) containing the subroutine; + +=item [2] + +a reference to the subroutine; + +=item [3] + +the name of the attribute; + +=item [4] + +any data associated with that attribute; + +=item [5] + +the name of the phase in which the handler is being invoked. + +=back + +Likewise, declaring any variables with the C<:Loud> attribute within the +package: + + package LoudDecl; + + my $foo :Loud; + my @foo :Loud; + my %foo :Loud; + +will cause the handler to be called with a similar argument list (except, +of course, that C<$_[2]> will be a reference to the variable). + +The package name argument will typically be the name of the class into +which the subroutine was declared, but it may also be the name of a derived +class (since handlers are inherited). + +If a lexical variable is given an attribute, there is no symbol table to +which it belongs, so the symbol table argument (C<$_[1]>) is set to the +string C<'LEXICAL'> in that case. Likewise, ascribing an attribute to +an anonymous subroutine results in a symbol table argument of C<'ANON'>. + +The data argument passes in the value (if any) associated with the +attribute. For example, if C<&foo> had been declared: + + sub foo :Loud("turn it up to 11, man!") {...} + +then the string C<"turn it up to 11, man!"> would be passed as the +last argument. + +Attribute::Handlers makes strenuous efforts to convert +the data argument (C<$_[4]>) to a useable form before passing it to +the handler (but see L<"Non-interpretive attribute handlers">). +For example, all of these: + + sub foo :Loud(till=>ears=>are=>bleeding) {...} + sub foo :Loud(['till','ears','are','bleeding']) {...} + sub foo :Loud(qw/till ears are bleeding/) {...} + sub foo :Loud(qw/my, ears, are, bleeding/) {...} + sub foo :Loud(till,ears,are,bleeding) {...} + +causes it to pass C<['till','ears','are','bleeding']> as the handler's +data argument. However, if the data can't be parsed as valid Perl, then +it is passed as an uninterpreted string. For example: + + sub foo :Loud(my,ears,are,bleeding) {...} + sub foo :Loud(qw/my ears are bleeding) {...} + +cause the strings C<'my,ears,are,bleeding'> and C<'qw/my ears are bleeding'> +respectively to be passed as the data argument. + +If the attribute has only a single associated scalar data value, that value is +passed as a scalar. If multiple values are associated, they are passed as an +array reference. If no value is associated with the attribute, C is +passed. + + +=head2 Typed lexicals + +Regardless of the package in which it is declared, if a lexical variable is +ascribed an attribute, the handler that is invoked is the one belonging to +the package to which it is typed. For example, the following declarations: + + package OtherClass; + + my LoudDecl $loudobj : Loud; + my LoudDecl @loudobjs : Loud; + my LoudDecl %loudobjex : Loud; + +causes the LoudDecl::Loud handler to be invoked (even if OtherClass also +defines a handler for C<:Loud> attributes). + + +=head2 Type-specific attribute handlers + +If an attribute handler is declared and the C<:ATTR> specifier is +given the name of a built-in type (C, C, C, or C), +the handler is only applied to declarations of that type. For example, +the following definition: + + package LoudDecl; + + sub RealLoud :ATTR(SCALAR) { print "Yeeeeow!" } + +creates an attribute handler that applies only to scalars: + + + package Painful; + use base LoudDecl; + + my $metal : RealLoud; # invokes &LoudDecl::RealLoud + my @metal : RealLoud; # error: unknown attribute + my %metal : RealLoud; # error: unknown attribute + sub metal : RealLoud {...} # error: unknown attribute + +You can, of course, declare separate handlers for these types as well +(but you'll need to specify C to do it quietly): + + package LoudDecl; + use Attribute::Handlers; + no warnings 'redefine'; + + sub RealLoud :ATTR(SCALAR) { print "Yeeeeow!" } + sub RealLoud :ATTR(ARRAY) { print "Urrrrrrrrrr!" } + sub RealLoud :ATTR(HASH) { print "Arrrrrgggghhhhhh!" } + sub RealLoud :ATTR(CODE) { croak "Real loud sub torpedoed" } + +You can also explicitly indicate that a single handler is meant to be +used for all types of referents like so: + + package LoudDecl; + use Attribute::Handlers; + + sub SeriousLoud :ATTR(ANY) { warn "Hearing loss imminent" } + +(I.e. C is a synonym for C<:ATTR>). + + +=head2 Non-interpretive attribute handlers + +Occasionally the strenuous efforts Attribute::Handlers makes to convert +the data argument (C<$_[4]>) to a useable form before passing it to +the handler get in the way. + +You can turn off that eagerness-to-help by declaring +an attribute handler with the keyword C. For example: + + sub Raw : ATTR(RAWDATA) {...} + sub Nekkid : ATTR(SCALAR,RAWDATA) {...} + sub Au::Naturale : ATTR(RAWDATA,ANY) {...} + +Then the handler makes absolutely no attempt to interpret the data it +receives and simply passes it as a string: + + my $power : Raw(1..100); # handlers receives "1..100" + +=head2 Phase-specific attribute handlers + +By default, attribute handlers are called at the end of the compilation +phase (in a C block). This seems to be optimal in most cases because +most things that can be defined are defined by that point but nothing has +been executed. + +However, it is possible to set up attribute handlers that are called at +other points in the program's compilation or execution, by explicitly +stating the phase (or phases) in which you wish the attribute handler to +be called. For example: + + sub Early :ATTR(SCALAR,BEGIN) {...} + sub Normal :ATTR(SCALAR,CHECK) {...} + sub Late :ATTR(SCALAR,INIT) {...} + sub Final :ATTR(SCALAR,END) {...} + sub Bookends :ATTR(SCALAR,BEGIN,END) {...} + +As the last example indicates, a handler may be set up to be (re)called in +two or more phases. The phase name is passed as the handler's final argument. + +Note that attribute handlers that are scheduled for the C phase +are handled as soon as the attribute is detected (i.e. before any +subsequently defined C blocks are executed). + + +=head2 Attributes as C interfaces + +Attributes make an excellent and intuitive interface through which to tie +variables. For example: + + use Attribute::Handlers; + use Tie::Cycle; + + sub UNIVERSAL::Cycle : ATTR(SCALAR) { + my ($package, $symbol, $referent, $attr, $data, $phase) = @_; + $data = [ $data ] unless ref $data eq 'ARRAY'; + tie $$referent, 'Tie::Cycle', $data; + } + + # and thereafter... + + package main; + + my $next : Cycle('A'..'Z'); # $next is now a tied variable + + while (<>) { + print $next; + } + +Note that, because the C attribute receives its arguments in the +C<$data> variable, if the attribute is given a list of arguments, C<$data> +will consist of a single array reference; otherwise, it will consist of the +single argument directly. Since Tie::Cycle requires its cycling values to +be passed as an array reference, this means that we need to wrap +non-array-reference arguments in an array constructor: + + $data = [ $data ] unless ref $data eq 'ARRAY'; + +Typically, however, things are the other way around: the tieable class expects +its arguments as a flattened list, so the attribute looks like: + + sub UNIVERSAL::Cycle : ATTR(SCALAR) { + my ($package, $symbol, $referent, $attr, $data, $phase) = @_; + my @data = ref $data eq 'ARRAY' ? @$data : $data; + tie $$referent, 'Tie::Whatever', @data; + } + + +This software pattern is so widely applicable that Attribute::Handlers +provides a way to automate it: specifying C<'autotie'> in the +C statement. So, the cycling example, +could also be written: + + use Attribute::Handlers autotie => { Cycle => 'Tie::Cycle' }; + + # and thereafter... + + package main; + + my $next : Cycle(['A'..'Z']); # $next is now a tied variable + + while (<>) { + print $next; + +Note that we now have to pass the cycling values as an array reference, +since the C mechanism passes C a list of arguments as a list +(as in the Tie::Whatever example), I as an array reference (as in +the original Tie::Cycle example at the start of this section). + +The argument after C<'autotie'> is a reference to a hash in which each key is +the name of an attribute to be created, and each value is the class to which +variables ascribed that attribute should be tied. + +Note that there is no longer any need to import the Tie::Cycle module -- +Attribute::Handlers takes care of that automagically. You can even pass +arguments to the module's C subroutine, by appending them to the +class name. For example: + + use Attribute::Handlers + autotie => { Dir => 'Tie::Dir qw(DIR_UNLINK)' }; + +If the attribute name is unqualified, the attribute is installed in the +current package. Otherwise it is installed in the qualifier's package: + + package Here; + + use Attribute::Handlers autotie => { + Other::Good => Tie::SecureHash, # tie attr installed in Other:: + Bad => Tie::Taxes, # tie attr installed in Here:: + UNIVERSAL::Ugly => Software::Patent # tie attr installed everywhere + }; + +Autoties are most commonly used in the module to which they actually tie, +and need to export their attributes to any module that calls them. To +facilitiate this, Attribute::Handlers recognizes a special "pseudo-class" -- +C<__CALLER__>, which may be specified as the qualifier of an attribute: + + package Tie::Me::Kangaroo:Down::Sport; + + use Attribute::Handlers autotie => { '__CALLER__::Roo' => __PACKAGE__ }; + +This causes Attribute::Handlers to define the C attribute in the package +that imports the Tie::Me::Kangaroo:Down::Sport module. + +Note that it is important to quote the __CALLER__::Roo identifier because +a bug in perl 5.8 will refuse to parse it and cause an unknown error. + +=head3 Passing the tied object to C + +Occasionally it is important to pass a reference to the object being tied +to the TIESCALAR, TIEHASH, etc. that ties it. + +The C mechanism supports this too. The following code: + + use Attribute::Handlers autotieref => { Selfish => Tie::Selfish }; + my $var : Selfish(@args); + +has the same effect as: + + tie my $var, 'Tie::Selfish', @args; + +But when C<"autotieref"> is used instead of C<"autotie">: + + use Attribute::Handlers autotieref => { Selfish => Tie::Selfish }; + my $var : Selfish(@args); + +the effect is to pass the C call an extra reference to the variable +being tied: + + tie my $var, 'Tie::Selfish', \$var, @args; + + + +=head1 EXAMPLES + +If the class shown in L were placed in the MyClass.pm +module, then the following code: + + package main; + use MyClass; + + my MyClass $slr :Good :Bad(1**1-1) :Omni(-vorous); + + package SomeOtherClass; + use base MyClass; + + sub tent { 'acle' } + + sub fn :Ugly(sister) :Omni('po',tent()) {...} + my @arr :Good :Omni(s/cie/nt/); + my %hsh :Good(q/bye) :Omni(q/bus/); + + +would cause the following handlers to be invoked: + + # my MyClass $slr :Good :Bad(1**1-1) :Omni(-vorous); + + MyClass::Good:ATTR(SCALAR)( 'MyClass', # class + 'LEXICAL', # no typeglob + \$slr, # referent + 'Good', # attr name + undef # no attr data + 'CHECK', # compiler phase + ); + + MyClass::Bad:ATTR(SCALAR)( 'MyClass', # class + 'LEXICAL', # no typeglob + \$slr, # referent + 'Bad', # attr name + 0 # eval'd attr data + 'CHECK', # compiler phase + ); + + MyClass::Omni:ATTR(SCALAR)( 'MyClass', # class + 'LEXICAL', # no typeglob + \$slr, # referent + 'Omni', # attr name + '-vorous' # eval'd attr data + 'CHECK', # compiler phase + ); + + + # sub fn :Ugly(sister) :Omni('po',tent()) {...} + + MyClass::UGLY:ATTR(CODE)( 'SomeOtherClass', # class + \*SomeOtherClass::fn, # typeglob + \&SomeOtherClass::fn, # referent + 'Ugly', # attr name + 'sister' # eval'd attr data + 'CHECK', # compiler phase + ); + + MyClass::Omni:ATTR(CODE)( 'SomeOtherClass', # class + \*SomeOtherClass::fn, # typeglob + \&SomeOtherClass::fn, # referent + 'Omni', # attr name + ['po','acle'] # eval'd attr data + 'CHECK', # compiler phase + ); + + + # my @arr :Good :Omni(s/cie/nt/); + + MyClass::Good:ATTR(ARRAY)( 'SomeOtherClass', # class + 'LEXICAL', # no typeglob + \@arr, # referent + 'Good', # attr name + undef # no attr data + 'CHECK', # compiler phase + ); + + MyClass::Omni:ATTR(ARRAY)( 'SomeOtherClass', # class + 'LEXICAL', # no typeglob + \@arr, # referent + 'Omni', # attr name + "" # eval'd attr data + 'CHECK', # compiler phase + ); + + + # my %hsh :Good(q/bye) :Omni(q/bus/); + + MyClass::Good:ATTR(HASH)( 'SomeOtherClass', # class + 'LEXICAL', # no typeglob + \%hsh, # referent + 'Good', # attr name + 'q/bye' # raw attr data + 'CHECK', # compiler phase + ); + + MyClass::Omni:ATTR(HASH)( 'SomeOtherClass', # class + 'LEXICAL', # no typeglob + \%hsh, # referent + 'Omni', # attr name + 'bus' # eval'd attr data + 'CHECK', # compiler phase + ); + + +Installing handlers into UNIVERSAL, makes them...err..universal. +For example: + + package Descriptions; + use Attribute::Handlers; + + my %name; + sub name { return $name{$_[2]}||*{$_[1]}{NAME} } + + sub UNIVERSAL::Name :ATTR { + $name{$_[2]} = $_[4]; + } + + sub UNIVERSAL::Purpose :ATTR { + print STDERR "Purpose of ", &name, " is $_[4]\n"; + } + + sub UNIVERSAL::Unit :ATTR { + print STDERR &name, " measured in $_[4]\n"; + } + +Let's you write: + + use Descriptions; + + my $capacity : Name(capacity) + : Purpose(to store max storage capacity for files) + : Unit(Gb); + + + package Other; + + sub foo : Purpose(to foo all data before barring it) { } + + # etc. + + +=head1 DIAGNOSTICS + +=over + +=item C + +An attribute handler was specified with an C<:ATTR(I)>, but the +type of referent it was defined to handle wasn't one of the five permitted: +C, C, C, C, or C. + +=item C + +A handler for attributes of the specified name I defined, but not +for the specified type of declaration. Typically encountered whe trying +to apply a C attribute handler to a subroutine, or a C +attribute handler to some other type of variable. + +=item C + +A handler for an attributes with an all-lowercase name was declared. An +attribute with an all-lowercase name might have a meaning to Perl +itself some day, even though most don't yet. Use a mixed-case attribute +name, instead. + +=item C + +You just can't, okay? +Instead, put all the specifications together with commas between them +in a single C)>. + +=item C + +You can only declare autoties for types C<"SCALAR">, C<"ARRAY">, and +C<"HASH">. They're the only things (apart from typeglobs -- which are +not declarable) that Perl can tie. + +=item C + +Something is rotten in the state of the program. An attributed +subroutine ceased to exist between the point it was declared and the point +at which its attribute handler(s) would have been called. + +=item C + +You have defined an END handler for an attribute that is being applied +to a lexical variable. Since the variable may not be available during END +this won't happen. + +=back + +=head1 AUTHOR + +Damian Conway (damian@conway.org) + +=head1 BUGS + +There are undoubtedly serious bugs lurking somewhere in code this funky :-) +Bug reports and other feedback are most welcome. + +=head1 COPYRIGHT + + Copyright (c) 2001, Damian Conway. All Rights Reserved. + This module is free software. It may be used, redistributed + and/or modified under the same terms as Perl itself. diff --git a/lib/Benchmark/Timer.pm b/lib/Benchmark/Timer.pm new file mode 100755 index 0000000..624289b --- /dev/null +++ b/lib/Benchmark/Timer.pm @@ -0,0 +1,618 @@ +# ======================================================================== +# Benchmark::Timer - Perl code benchmarking tool +# David Coppit +# +# This program contains embedded documentation in Perl POD (Plain Old +# Documentation) format. Search for the string "=head1" in this document +# to find documentation snippets, or use "perldoc" to read it; utilities +# like "pod2man" and "pod2html" can reformat as well. +# +# Copyright(c) 2004 David Coppit +# Copyright(c) 2000-2001 Andrew Ho. +# +# ======================================================================== + +=head1 NAME + +Benchmark::Timer - Benchmarking with statistical confidence + +=head1 SYNOPSIS + + # Non-statistical usage + use Benchmark::Timer; + $t = Benchmark::Timer->new(skip => 1); + + for(1 .. 1000) { + $t->start('tag'); + &long_running_operation(); + $t->stop('tag'); + } + print $t->report; + + # -------------------------------------------------------------------- + + # Statistical usage + use Benchmark::Timer; + $t = Benchmark::Timer->new(skip => 1, confidence => 97.5, error => 2); + + while($t->need_more_samples('tag')) { + $t->start('tag'); + &long_running_operation(); + $t->stop('tag'); + } + print $t->report; + +=head1 DESCRIPTION + +The Benchmark::Timer class allows you to time portions of code +conveniently, as well as benchmark code by allowing timings of repeated +trials. It is perfect for when you need more precise information about the +running time of portions of your code than the Benchmark module will give +you, but don't want to go all out and profile your code. + +The methodology is simple; create a Benchmark::Timer object, and wrap portions +of code that you want to benchmark with C and C method calls. +You can supply a tag to those methods if you plan to time multiple portions of +code. If you provide error and confidence values, you can also use +C to determine, statistically, whether you need to +collect more data. + +After you have run your code, you can obtain information about the running +time by calling the C method, or get a descriptive benchmark report +by calling C. If you run your code over multiple trials, the +average time is reported. This is wonderful for benchmarking time-critical +portions of code in a rigorous way. You can also optionally choose to skip any +number of initial trials to cut down on initial case irregularities. + +=head1 METHODS + +In all of the following methods, C<$tag> refers to the user-supplied name of +the code being timed. Unless otherwise specified, $tag defaults to the tag of +the last call to C, or "_default" if C was not previously +called with a tag. + +=over 4 + +=cut + + +# ------------------------------------------------------------------------ +# Package setup + +package Benchmark::Timer; +require 5.005; +use strict; + +use Carp; +use Time::HiRes qw( gettimeofday tv_interval ); + +use vars qw($VERSION); +$VERSION = sprintf "%d.%02d%02d", q/0.71.0/ =~ /(\d+)/g; + +use constant BEFORE => 0; +use constant ELAPSED => 1; +use constant LASTTAG => 2; +use constant TAGS => 3; +use constant SKIP => 4; +use constant MINIMUM => 5; +use constant SKIPCOUNT => 6; +use constant CONFIDENCE => 7; +use constant ERROR => 8; +use constant STAT => 9; + +# ------------------------------------------------------------------------ +# Constructor + +=item $t = Benchmark::Timer->new( [options] ); + +Constructor for the Benchmark::Timer object; returns a reference to a +timer object. Takes the following named arguments: + +=over 4 + +=item skip + +The number of trials (if any) to skip before recording timing information. + +=item minimum + +The minimum number of trials to run. + +=item error + +A percentage between 0 and 100 which indicates how much error you are willing +to tolerate in the average time measured by the benchmark. For example, a +value of 1 means that you want the reported average time to be within 1% of +the real average time. C will use this value to determine +when it is okay to stop collecting data. + +If you specify an error you must also specify a confidence. + +=item confidence + +A percentage between 0 and 100 which indicates how confident you want to be in +the error measured by the benchmark. For example, a value of 97.5 means that +you want to be 97.5% confident that the real average time is within the error +margin you have specified. C will use this value to +compute the estimated error for the collected data, so that it can determine +when it is okay to stop. + +If you specify a confidence you must also specify an error. + +=back + +=cut + +sub new { + my $class = shift; + my $self = []; + bless $self, $class; + return $self->reset(@_); +} + + +# ------------------------------------------------------------------------ +# Public methods + +=item $t->reset; + +Reset the timer object to the pristine state it started in. +Erase all memory of tags and any previously accumulated timings. +Returns a reference to the timer object. It takes the same arguments +the constructor takes. + +=cut + +sub reset { + my $self = shift; + my %args = @_; + + $self->[BEFORE] = {}; # [ gettimeofday ] storage + $self->[ELAPSED] = {}; # elapsed fractional seconds + $self->[LASTTAG] = undef; # what the last tag was + $self->[TAGS] = []; # keep list of tags in order seen + $self->[SKIP] = 0; # how many samples to skip + $self->[MINIMUM] = 1; # the minimum number of trails to run + $self->[SKIPCOUNT] = {}; # trial skip storage + delete $self->[CONFIDENCE]; # confidence factor + delete $self->[ERROR]; # allowable error + delete $self->[STAT]; # stat objects for each tag + + if(exists $args{skip}) { + croak 'argument skip must be a non-negative integer' + unless defined $args{skip} + and $args{skip} !~ /\D/ + and int $args{skip} == $args{skip}; + $self->[SKIP] = $args{skip}; + delete $args{skip}; + } + + if(exists $args{minimum}) { + croak 'argument minimum must be a non-negative integer' + unless defined $args{minimum} + and $args{minimum} !~ /\D/ + and int $args{minimum} == $args{minimum}; + croak 'argument minimum must greater than or equal to skip' + unless defined $args{minimum} + and $args{minimum} >= $self->[SKIP]; + $self->[MINIMUM] = $args{minimum}; + delete $args{minimum}; + } + + my $confidence_is_valid = + (defined $args{confidence} + and $args{confidence} =~ /^\d*\.?\d*$/ + and $args{confidence} > 0 + and $args{confidence} < 100); + + my $error_is_valid = + (defined $args{error} + and $args{error} =~ /^\d*\.?\d*$/ + and $args{error} > 0 + and $args{error} < 100); + + if ($confidence_is_valid && !$error_is_valid || + !$confidence_is_valid && $error_is_valid) + { + carp 'you must specify both confidence and error' + } + elsif ($confidence_is_valid && $error_is_valid) + { + $self->[CONFIDENCE] = $args{confidence}; + delete $args{confidence}; + + $self->[ERROR] = $args{error}; + delete $args{error}; + + # Demand load the module we need. We could just + # require people to install it... + croak 'Could not load the Statistics::PointEstimation module' + unless eval "require Statistics::PointEstimation"; + } + + if(%args) { + carp 'skipping unknown arguments'; + } + + return $self; +} + + +=item $t->start($tag); + +Record the current time so that when C is called, we can calculate an +elapsed time. + +=cut + +# In this routine we try hard to make the [ gettimeofday ] take place +# as late as possible to minimize Heisenberg problems. :) + +sub start { + my $self = shift; + my $tag = shift || $self->[LASTTAG] || '_default'; + $self->[LASTTAG] = $tag; + if(exists $self->[SKIPCOUNT]->{$tag}) { + if($self->[SKIPCOUNT]->{$tag} > 1) { + $self->[SKIPCOUNT]->{$tag}--; + } else { + $self->[SKIPCOUNT]->{$tag} = 0; + push @{$self->[BEFORE]->{$tag}}, [ gettimeofday ]; + } + } else { + push @{$self->[TAGS]}, $tag; + $self->[SKIPCOUNT]->{$tag} = $self->[SKIP] + 1; + if($self->[SKIPCOUNT]->{$tag} > 1) { + $self->[SKIPCOUNT]->{$tag}--; + } else { + $self->[SKIPCOUNT]->{$tag} = 0; + $self->[BEFORE]->{$tag} = [ [ gettimeofday ] ] + } + } +} + + +=item $t->stop($tag); + +Record timing information. If $tag is supplied, it must correspond to one +given to a previously called C call. It returns the elapsed time in +milliseconds. C croaks if the timer gets out of sync (e.g. the number +of Cs does not match the number of Cs.) + +=cut + +sub stop { + my $after = [ gettimeofday ]; # minimize overhead + my $self = shift; + my $tag = shift || $self->[LASTTAG] || '_default'; + + croak 'must call $t->start($tag) before $t->stop($tag)' + unless exists $self->[SKIPCOUNT]->{$tag}; + + return if $self->[SKIPCOUNT]->{$tag} > 0; + + my $i = exists $self->[ELAPSED]->{$tag} ? + scalar @{$self->[ELAPSED]->{$tag}} : 0; + my $before = $self->[BEFORE]->{$tag}->[$i]; + croak 'timer out of sync' unless defined $before; + + # Create a stats object if we need to + if (defined $self->[CONFIDENCE] && !defined $self->[STAT]->{$tag}) + { + $self->[STAT]->{$tag} = Statistics::PointEstimation->new; + $self->[STAT]->{$tag}->set_significance($self->[CONFIDENCE]); + } + + my $elapsed = tv_interval($before, $after); + + if($i > 0) { + push @{$self->[ELAPSED]->{$tag}}, $elapsed; + } else { + $self->[ELAPSED]->{$tag} = [ $elapsed ]; + } + + $self->[STAT]->{$tag}->add_data($elapsed) + if defined $self->[STAT]->{$tag}; + + return $elapsed; +} + + +=item $t->need_more_samples($tag); + +Compute the estimated error in the average of the data collected thus far, and +return true if that error exceeds the user-specified error. If a $tag is +supplied, it must correspond to one given to a previously called C +call. + +This routine assumes that the data are normally distributed. + +=cut + +sub need_more_samples { + my $self = shift; + my $tag = shift || $self->[LASTTAG] || '_default'; + + carp 'You must set the confidence and error in order to use need_more_samples' + unless defined $self->[CONFIDENCE]; + + # In case this function is called before any trials are run + return 1 + if !defined $self->[STAT]->{$tag} || + $self->[STAT]->{$tag}->count < $self->[MINIMUM]; + + # For debugging +# printf STDERR "Average: %.5f +/- %.5f, Samples: %d\n", +# $self->[STAT]->{$tag}->mean(), $self->[STAT]->{$tag}->delta(), +# $self->[STAT]->{$tag}->count; +# printf STDERR "Percent Error: %.5f > %.5f\n", +# $self->[STAT]->{$tag}->delta() / $self->[STAT]->{$tag}->mean() * 100, +# $self->[ERROR]; + + return (($self->[STAT]->{$tag}->delta() / $self->[STAT]->{$tag}->mean() * 100) > + $self->[ERROR]); +} + + +=item $t->report($tag); + +Returns a string containing a simple report on the collected timings for $tag. +This report contains the number of trials run, the total time taken, and, if +more than one trial was run, the average time needed to run one trial and +error information. C will complain (via a warning) if a tag is +still active. + +=cut + +sub report { + my $self = shift; + my $tag = shift || $self->[LASTTAG] || '_default'; + + unless(exists $self->[ELAPSED]->{$tag}) { + carp join ' ', 'tag', $tag, 'still running'; + return; + } + + return $self->_report($tag); +} + + +=item $t->reports; + +In a scalar context, returns a string containing a simple report on the +collected timings for all tags. The report is a concatenation of the +individual tag reports, in the original tag order. In an list context, returns +a hash keyed by tag and containing reports for each tag. The return value is +actually an array, so that the original tag order is preserved if you assign +to an array instead of a hash. C will complain (via a warning) if a +tag is still active. + + +=cut + +sub reports { + my $self = shift; + + if (wantarray) + { + my @reports; + + foreach my $tag (@{$self->[TAGS]}) { + push @reports, $tag; + push @reports, $self->report($tag); + } + + return @reports; + } + else + { + my $report = ''; + + foreach my $tag (@{$self->[TAGS]}) { + $report .= $self->report($tag); + } + + return $report; + } +} + + +sub _report { + my $self = shift; + my $tag = shift; + + unless(exists $self->[ELAPSED]->{$tag}) { + return "Tag $tag is still running or has not completed its skipped runs, skipping\n"; + } + + my $report = ''; + + my @times = @{$self->[ELAPSED]->{$tag}}; + my $n = scalar @times; + my $total = 0; $total += $_ foreach @times; + + if ($n == 1) + { + $report .= sprintf "\%d trial of \%s (\%s total)\n", + $n, $tag, timestr($total); + } + else + { + $report .= sprintf "\%d trials of \%s (\%s total), \%s/trial\n", + $n, $tag, timestr($total), timestr($total / $n); + } + + if (defined $self->[STAT]->{$tag}) + { + my $delta = 0; + $delta = $self->[STAT]->{$tag}->delta() + if defined $self->[STAT]->{$tag}->delta(); + + $report .= sprintf "Error: +/- \%.5f with \%s confidence\n", + $delta, $self->[CONFIDENCE]; + } + + return $report; +} + + +=item $t->result($tag); + +Return the time it took for $tag to elapse, or the mean time it took for $tag +to elapse once, if $tag was used to time code more than once. C will +complain (via a warning) if a tag is still active. + +=cut + +sub result { + my $self = shift; + my $tag = shift || $self->[LASTTAG] || '_default'; + unless(exists $self->[ELAPSED]->{$tag}) { + carp join ' ', 'tag', $tag, 'still running'; + return; + } + my @times = @{$self->[ELAPSED]->{$tag}}; + my $total = 0; $total += $_ foreach @times; + return $total / @times; +} + + +=item $t->results; + +Returns the timing data as a hash keyed on tags where each value is +the time it took to run that code, or the average time it took, +if that code ran more than once. In scalar context it returns a reference +to that hash. The return value is actually an array, so that the original +tag order is preserved if you assign to an array instead of a hash. + +=cut + +sub results { + my $self = shift; + my @results; + foreach my $tag (@{$self->[TAGS]}) { + push @results, $tag; + push @results, $self->result($tag); + } + return wantarray ? @results : \@results; +} + + +=item $t->data($tag), $t->data; + +These methods are useful if you want to recover the full internal timing +data to roll your own reports. + +If called with a $tag, returns the raw timing data for that $tag as +an array (or a reference to an array if called in scalar context). This is +useful for feeding to something like the Statistics::Descriptive package. + +If called with no arguments, returns the raw timing data as a hash keyed +on tags, where the values of the hash are lists of timings for that +code. In scalar context, it returns a reference to that hash. As with +C, the data is internally represented as an array so you can +recover the original tag order by assigning to an array instead of a hash. + +=cut + +sub data { + my $self = shift; + my $tag = shift; + my @results; + if($tag) { + if(exists $self->[ELAPSED]->{$tag}) { + @results = @{$self->[ELAPSED]->{$tag}}; + } else { + @results = (); + } + } else { + @results = map { ( $_ => $self->[ELAPSED]->{$_} || [] ) } + @{$self->[TAGS]}; + } + return wantarray ? @results : \@results; +} + + +# ------------------------------------------------------------------------ +# Internal utility subroutines + +# timestr($sec) takes a floating-point number of seconds and formats +# it in a sensible way, commifying large numbers of seconds, and +# converting to milliseconds if it makes sense. Since Time::HiRes has +# at most microsecond resolution, no attempt is made to convert into +# anything below that. A unit string is appended to the number. + +sub timestr { + my $sec = shift; + my $retstr; + if($sec >= 1_000) { + $retstr = commify(int $sec) . 's'; + } elsif($sec >= 1) { + $retstr = sprintf $sec == int $sec ? '%ds' : '%0.3fs', $sec; + } elsif($sec >= 0.001) { + my $ms = $sec * 1_000; + $retstr = sprintf $ms == int $ms ? '%dms' : '%0.3fms', $ms; + } elsif($sec >= 0.000001) { + $retstr = sprintf '%dus', $sec * 1_000_000; + } else { + # I'll have whatever real-time OS she's having + $retstr = $sec . 's'; + } + $retstr; +} + + +# commify($num) inserts a grouping comma according to en-US standards +# for numbers larger than 1000. For example, the integer 123456 would +# be written 123,456. Any fractional part is left untouched. + +sub commify { + my $num = shift; + return unless $num =~ /\d/; + return $num if $num < 1_000; + + my $ip = int $num; + my($fp) = ($num =~ /\.(\d+)/); + + $ip =~ s/(\d\d\d)$/,$1/; + 1 while $ip =~ s/(\d)(\d\d\d),/$1,$2,/; + + return $fp ? join '.', $ip, $fp : $ip; +} + + +# ------------------------------------------------------------------------ +# Finish up the POD. + +=back + +=head1 BUGS + +Benchmarking is an inherently futile activity, fraught with uncertainty +not dissimilar to that experienced in quantum mechanics. But things are a +little better if you apply statistics. + +=head1 SEE ALSO + +L, L, L, L + +=head1 AUTHOR + +The original code (written before April 20, 2001) was written by Andrew Ho +Eandrew@zeuscat.comE, and is copyright (c) 2000-2001 Andrew Ho. +Versions up to 0.5 are distributed under the same terms as Perl. + +Maintenance of this module is now being done by David Coppit +Edavid@coppit.orgE. + +=cut + + +# ------------------------------------------------------------------------ +# Return true for a valid Perl include + +1; + + +# ======================================================================== +__END__ diff --git a/lib/Bundle/Xxv.pm b/lib/Bundle/Xxv.pm new file mode 100644 index 0000000..411e679 --- /dev/null +++ b/lib/Bundle/Xxv.pm @@ -0,0 +1,81 @@ +package Bundle::Xxv; +use strict; +use warnings; + +$VERSION = '0.04'; + +1; + +__END__ + +=head1 NAME + +Bundle::Xxv - A bundle to install various xxv related modules + +=head1 SYNOPSIS + + mkdir -p ~/.cpan/Bundle + cp Bundle/Xxv.pm ~/.cpan/Bundle + perl -MCPAN -e 'install Bundle::Xxv' + +=head1 CONTENTS + +Test::Simple - Test package to test varios funktion +DBI - Database package for perl +DBD::mysql - Database driver to connect over DBI +Config::Tiny +Event - the great famos Event libary +MIME::Base64 - Code library to encrypt and decrypt Strings +Time::HiRes - High Resolutin timer +Locale::gettext - Localization in perl +Net::Telnet +URI +URI::file +URI::URL +Compress::Zlib - for compressed output +HTML::Tagset +HTML::Parser +HTML::Form +HTTP::Status +HTTP::Daemon +HTTP::Request +LWP::UserAgent +LWP +WWW::Mechanize - for Robot Module +Data::Random +WWW::Mechanize::FormFiller +GD - GD Image library +Digest::SHA1 +Digest::HMAC_MD5 +Digest::MD5 +Net::IP +Net::DNS +XML::Parser +XML::RSS - create an rss feed +Math::BigInt::FastCalc +Authen::SASL +XML::Stream +Net::XMPP - create an Jabber message +Proc::Killfam - killall for Perl +Proc::ProcessTable +Term::ReadLine::Gnu - Better Support for telnet interface +Template +SOAP::Lite +MP3::Icecast +MP3::Info +CGI +LWP::Simple +Net::Amazon +Net::Amazon::Request::Artist +JSON - Parse and convert to JSON (JavaScript Object Notation) + + +=head1 DESCRIPTION + +This is a bundle of xxv related modules. + +=head1 AUTHOR + +Frank Herrmann Expix at xpix dot deE + +=cut diff --git a/lib/CGI.pm b/lib/CGI.pm new file mode 100644 index 0000000..148b861 --- /dev/null +++ b/lib/CGI.pm @@ -0,0 +1,7318 @@ +package CGI; +require 5.004; +use Carp 'croak'; + +# See the bottom of this file for the POD documentation. Search for the +# string '=head'. + +# You can run this file through either pod2man or pod2html to produce pretty +# documentation in manual or html file format (these utilities are part of the +# Perl 5 distribution). + +# Copyright 1995-1998 Lincoln D. Stein. All rights reserved. +# It may be used and modified freely, but I do request that this copyright +# notice remain attached to the file. You may modify this module as you +# wish, but if you redistribute a modified version, please attach a note +# listing the modifications you have made. + +# The most recent version and complete docs are available at: +# http://stein.cshl.org/WWW/software/CGI/ + +$CGI::revision = '$Id: CGI.pm,v 1.165 2004/04/12 20:37:26 lstein Exp $'; +$CGI::VERSION=3.05; + +# HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES. +# UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING. +# $CGITempFile::TMPDIRECTORY = '/usr/tmp'; +use CGI::Util qw(rearrange make_attributes unescape escape expires ebcdic2ascii ascii2ebcdic); + +#use constant XHTML_DTD => ['-//W3C//DTD XHTML Basic 1.0//EN', +# 'http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd']; + +use constant XHTML_DTD => ['-//W3C//DTD XHTML 1.0 Transitional//EN', + 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd']; + +{ + local $^W = 0; + $TAINTED = substr("$0$^X",0,0); +} + +$MOD_PERL = 0; # no mod_perl by default +@SAVED_SYMBOLS = (); + +# >>>>> Here are some globals that you might want to adjust <<<<<< +sub initialize_globals { + # Set this to 1 to enable copious autoloader debugging messages + $AUTOLOAD_DEBUG = 0; + + # Set this to 1 to generate XTML-compatible output + $XHTML = 1; + + # Change this to the preferred DTD to print in start_html() + # or use default_dtd('text of DTD to use'); + $DEFAULT_DTD = [ '-//W3C//DTD HTML 4.01 Transitional//EN', + 'http://www.w3.org/TR/html4/loose.dtd' ] ; + + # Set this to 1 to enable NOSTICKY scripts + # or: + # 1) use CGI qw(-nosticky) + # 2) $CGI::nosticky(1) + $NOSTICKY = 0; + + # Set this to 1 to enable NPH scripts + # or: + # 1) use CGI qw(-nph) + # 2) CGI::nph(1) + # 3) print header(-nph=>1) + $NPH = 0; + + # Set this to 1 to enable debugging from @ARGV + # Set to 2 to enable debugging from STDIN + $DEBUG = 1; + + # Set this to 1 to make the temporary files created + # during file uploads safe from prying eyes + # or do... + # 1) use CGI qw(:private_tempfiles) + # 2) CGI::private_tempfiles(1); + $PRIVATE_TEMPFILES = 0; + + # Set this to 1 to cause files uploaded in multipart documents + # to be closed, instead of caching the file handle + # or: + # 1) use CGI qw(:close_upload_files) + # 2) $CGI::close_upload_files(1); + # Uploads with many files run out of file handles. + # Also, for performance, since the file is already on disk, + # it can just be renamed, instead of read and written. + $CLOSE_UPLOAD_FILES = 0; + + # Set this to a positive value to limit the size of a POSTing + # to a certain number of bytes: + $POST_MAX = -1; + + # Change this to 1 to disable uploads entirely: + $DISABLE_UPLOADS = 0; + + # Automatically determined -- don't change + $EBCDIC = 0; + + # Change this to 1 to suppress redundant HTTP headers + $HEADERS_ONCE = 0; + + # separate the name=value pairs by semicolons rather than ampersands + $USE_PARAM_SEMICOLONS = 1; + + # Do not include undefined params parsed from query string + # use CGI qw(-no_undef_params); + $NO_UNDEF_PARAMS = 0; + + # Other globals that you shouldn't worry about. + undef $Q; + $BEEN_THERE = 0; + $DTD_PUBLIC_IDENTIFIER = ""; + undef @QUERY_PARAM; + undef %EXPORT; + undef $QUERY_CHARSET; + undef %QUERY_FIELDNAMES; + + # prevent complaints by mod_perl + 1; +} + +# ------------------ START OF THE LIBRARY ------------ + +*end_form = \&endform; + +# make mod_perlhappy +initialize_globals(); + +# FIGURE OUT THE OS WE'RE RUNNING UNDER +# Some systems support the $^O variable. If not +# available then require() the Config library +unless ($OS) { + unless ($OS = $^O) { + require Config; + $OS = $Config::Config{'osname'}; + } +} +if ($OS =~ /^MSWin/i) { + $OS = 'WINDOWS'; +} elsif ($OS =~ /^VMS/i) { + $OS = 'VMS'; +} elsif ($OS =~ /^dos/i) { + $OS = 'DOS'; +} elsif ($OS =~ /^MacOS/i) { + $OS = 'MACINTOSH'; +} elsif ($OS =~ /^os2/i) { + $OS = 'OS2'; +} elsif ($OS =~ /^epoc/i) { + $OS = 'EPOC'; +} elsif ($OS =~ /^cygwin/i) { + $OS = 'CYGWIN'; +} else { + $OS = 'UNIX'; +} + +# Some OS logic. Binary mode enabled on DOS, NT and VMS +$needs_binmode = $OS=~/^(WINDOWS|DOS|OS2|MSWin|CYGWIN)/; + +# This is the default class for the CGI object to use when all else fails. +$DefaultClass = 'CGI' unless defined $CGI::DefaultClass; + +# This is where to look for autoloaded routines. +$AutoloadClass = $DefaultClass unless defined $CGI::AutoloadClass; + +# The path separator is a slash, backslash or semicolon, depending +# on the paltform. +$SL = { + UNIX => '/', OS2 => '\\', EPOC => '/', CYGWIN => '/', + WINDOWS => '\\', DOS => '\\', MACINTOSH => ':', VMS => '/' + }->{$OS}; + +# This no longer seems to be necessary +# Turn on NPH scripts by default when running under IIS server! +# $NPH++ if defined($ENV{'SERVER_SOFTWARE'}) && $ENV{'SERVER_SOFTWARE'}=~/IIS/; +$IIS++ if defined($ENV{'SERVER_SOFTWARE'}) && $ENV{'SERVER_SOFTWARE'}=~/IIS/; + +# Turn on special checking for Doug MacEachern's modperl +if (exists $ENV{MOD_PERL}) { + eval "require mod_perl"; + # mod_perl handlers may run system() on scripts using CGI.pm; + # Make sure so we don't get fooled by inherited $ENV{MOD_PERL} + if (defined $mod_perl::VERSION) { + if ($mod_perl::VERSION >= 1.99) { + $MOD_PERL = 2; + require Apache::Response; + require Apache::RequestRec; + require Apache::RequestUtil; + require APR::Pool; + } else { + $MOD_PERL = 1; + require Apache; + } + } +} + +# Turn on special checking for ActiveState's PerlEx +$PERLEX++ if defined($ENV{'GATEWAY_INTERFACE'}) && $ENV{'GATEWAY_INTERFACE'} =~ /^CGI-PerlEx/; + +# Define the CRLF sequence. I can't use a simple "\r\n" because the meaning +# of "\n" is different on different OS's (sometimes it generates CRLF, sometimes LF +# and sometimes CR). The most popular VMS web server +# doesn't accept CRLF -- instead it wants a LR. EBCDIC machines don't +# use ASCII, so \015\012 means something different. I find this all +# really annoying. +$EBCDIC = "\t" ne "\011"; +if ($OS eq 'VMS') { + $CRLF = "\n"; +} elsif ($EBCDIC) { + $CRLF= "\r\n"; +} else { + $CRLF = "\015\012"; +} + +if ($needs_binmode) { + $CGI::DefaultClass->binmode(\*main::STDOUT); + $CGI::DefaultClass->binmode(\*main::STDIN); + $CGI::DefaultClass->binmode(\*main::STDERR); +} + +%EXPORT_TAGS = ( + ':html2'=>['h1'..'h6',qw/p br hr ol ul li dl dt dd menu code var strong em + tt u i b blockquote pre img a address cite samp dfn html head + base body Link nextid title meta kbd start_html end_html + input Select option comment charset escapeHTML/], + ':html3'=>[qw/div table caption th td TR Tr sup Sub strike applet Param + embed basefont style span layer ilayer font frameset frame script small big Area Map/], + ':html4'=>[qw/abbr acronym bdo col colgroup del fieldset iframe + ins label legend noframes noscript object optgroup Q + thead tbody tfoot/], + ':netscape'=>[qw/blink fontsize center/], + ':form'=>[qw/textfield textarea filefield password_field hidden checkbox checkbox_group + submit reset defaults radio_group popup_menu button autoEscape + scrolling_list image_button start_form end_form startform endform + start_multipart_form end_multipart_form isindex tmpFileName uploadInfo URL_ENCODED MULTIPART/], + ':cgi'=>[qw/param upload path_info path_translated url self_url script_name cookie Dump + raw_cookie request_method query_string Accept user_agent remote_host content_type + remote_addr referer server_name server_software server_port server_protocol virtual_port + virtual_host remote_ident auth_type http append + save_parameters restore_parameters param_fetch + remote_user user_name header redirect import_names put + Delete Delete_all url_param cgi_error/], + ':ssl' => [qw/https/], + ':cgi-lib' => [qw/ReadParse PrintHeader HtmlTop HtmlBot SplitParam Vars/], + ':html' => [qw/:html2 :html3 :html4 :netscape/], + ':standard' => [qw/:html2 :html3 :html4 :form :cgi/], + ':push' => [qw/multipart_init multipart_start multipart_end multipart_final/], + ':all' => [qw/:html2 :html3 :netscape :form :cgi :internal :html4/] + ); + +# to import symbols into caller +sub import { + my $self = shift; + + # This causes modules to clash. + undef %EXPORT_OK; + undef %EXPORT; + + $self->_setup_symbols(@_); + my ($callpack, $callfile, $callline) = caller; + + # To allow overriding, search through the packages + # Till we find one in which the correct subroutine is defined. + my @packages = ($self,@{"$self\:\:ISA"}); + foreach $sym (keys %EXPORT) { + my $pck; + my $def = ${"$self\:\:AutoloadClass"} || $DefaultClass; + foreach $pck (@packages) { + if (defined(&{"$pck\:\:$sym"})) { + $def = $pck; + last; + } + } + *{"${callpack}::$sym"} = \&{"$def\:\:$sym"}; + } +} + +sub compile { + my $pack = shift; + $pack->_setup_symbols('-compile',@_); +} + +sub expand_tags { + my($tag) = @_; + return ("start_$1","end_$1") if $tag=~/^(?:\*|start_|end_)(.+)/; + my(@r); + return ($tag) unless $EXPORT_TAGS{$tag}; + foreach (@{$EXPORT_TAGS{$tag}}) { + push(@r,&expand_tags($_)); + } + return @r; +} + +#### Method: new +# The new routine. This will check the current environment +# for an existing query string, and initialize itself, if so. +#### +sub new { + my($class,@initializer) = @_; + my $self = {}; + + bless $self,ref $class || $class || $DefaultClass; + if (ref($initializer[0]) + && (UNIVERSAL::isa($initializer[0],'Apache') + || + UNIVERSAL::isa($initializer[0],'Apache::RequestRec') + )) { + $self->r(shift @initializer); + } + if (ref($initializer[0]) + && (UNIVERSAL::isa($initializer[0],'CODE'))) { + $self->upload_hook(shift @initializer, shift @initializer); + } + if ($MOD_PERL) { + $self->r(Apache->request) unless $self->r; + my $r = $self->r; + if ($MOD_PERL == 1) { + $r->register_cleanup(\&CGI::_reset_globals); + } + else { + # XXX: once we have the new API + # will do a real PerlOptions -SetupEnv check + $r->subprocess_env unless exists $ENV{REQUEST_METHOD}; + $r->pool->cleanup_register(\&CGI::_reset_globals); + } + undef $NPH; + } + $self->_reset_globals if $PERLEX; + $self->init(@initializer); + return $self; +} + +# We provide a DESTROY method so that we can ensure that +# temporary files are closed (via Fh->DESTROY) before they +# are unlinked (via CGITempFile->DESTROY) because it is not +# possible to unlink an open file on Win32. We explicitly +# call DESTROY on each, rather than just undefing them and +# letting Perl DESTROY them by garbage collection, in case the +# user is still holding any reference to them as well. +sub DESTROY { + my $self = shift; + foreach my $href (values %{$self->{'.tmpfiles'}}) { + $href->{hndl}->DESTROY if defined $href->{hndl}; + $href->{name}->DESTROY if defined $href->{name}; + } +} + +sub r { + my $self = shift; + my $r = $self->{'.r'}; + $self->{'.r'} = shift if @_; + $r; +} + +sub upload_hook { + my ($self,$hook,$data) = self_or_default(@_); + $self->{'.upload_hook'} = $hook; + $self->{'.upload_data'} = $data; +} + +#### Method: param +# Returns the value(s)of a named parameter. +# If invoked in a list context, returns the +# entire list. Otherwise returns the first +# member of the list. +# If name is not provided, return a list of all +# the known parameters names available. +# If more than one argument is provided, the +# second and subsequent arguments are used to +# set the value of the parameter. +#### +sub param { + my($self,@p) = self_or_default(@_); + return $self->all_parameters unless @p; + my($name,$value,@other); + + # For compatibility between old calling style and use_named_parameters() style, + # we have to special case for a single parameter present. + if (@p > 1) { + ($name,$value,@other) = rearrange([NAME,[DEFAULT,VALUE,VALUES]],@p); + my(@values); + + if (substr($p[0],0,1) eq '-') { + @values = defined($value) ? (ref($value) && ref($value) eq 'ARRAY' ? @{$value} : $value) : (); + } else { + foreach ($value,@other) { + push(@values,$_) if defined($_); + } + } + # If values is provided, then we set it. + if (@values) { + $self->add_parameter($name); + $self->{$name}=[@values]; + } + } else { + $name = $p[0]; + } + + return unless defined($name) && $self->{$name}; + return wantarray ? @{$self->{$name}} : $self->{$name}->[0]; +} + +sub self_or_default { + return @_ if defined($_[0]) && (!ref($_[0])) &&($_[0] eq 'CGI'); + unless (defined($_[0]) && + (ref($_[0]) eq 'CGI' || UNIVERSAL::isa($_[0],'CGI')) # slightly optimized for common case + ) { + $Q = $CGI::DefaultClass->new unless defined($Q); + unshift(@_,$Q); + } + return wantarray ? @_ : $Q; +} + +sub self_or_CGI { + local $^W=0; # prevent a warning + if (defined($_[0]) && + (substr(ref($_[0]),0,3) eq 'CGI' + || UNIVERSAL::isa($_[0],'CGI'))) { + return @_; + } else { + return ($DefaultClass,@_); + } +} + +######################################## +# THESE METHODS ARE MORE OR LESS PRIVATE +# GO TO THE __DATA__ SECTION TO SEE MORE +# PUBLIC METHODS +######################################## + +# Initialize the query object from the environment. +# If a parameter list is found, this object will be set +# to an associative array in which parameter names are keys +# and the values are stored as lists +# If a keyword list is found, this method creates a bogus +# parameter list with the single parameter 'keywords'. + +sub init { + my $self = shift; + my($query_string,$meth,$content_length,$fh,@lines) = ('','','',''); + + my $initializer = shift; # for backward compatibility + local($/) = "\n"; + + # set autoescaping on by default + $self->{'escape'} = 1; + + # if we get called more than once, we want to initialize + # ourselves from the original query (which may be gone + # if it was read from STDIN originally.) + if (defined(@QUERY_PARAM) && !defined($initializer)) { + foreach (@QUERY_PARAM) { + $self->param('-name'=>$_,'-value'=>$QUERY_PARAM{$_}); + } + $self->charset($QUERY_CHARSET); + $self->{'.fieldnames'} = {%QUERY_FIELDNAMES}; + return; + } + + $meth=$ENV{'REQUEST_METHOD'} if defined($ENV{'REQUEST_METHOD'}); + $content_length = defined($ENV{'CONTENT_LENGTH'}) ? $ENV{'CONTENT_LENGTH'} : 0; + + $fh = to_filehandle($initializer) if $initializer; + + # set charset to the safe ISO-8859-1 + $self->charset('ISO-8859-1'); + + METHOD: { + + # avoid unreasonably large postings + if (($POST_MAX > 0) && ($content_length > $POST_MAX)) { + # quietly read and discard the post + my $buffer; + my $max = $content_length; + while ($max > 0 && + (my $bytes = $MOD_PERL + ? $self->r->read($buffer,$max < 10000 ? $max : 10000) + : read(STDIN,$buffer,$max < 10000 ? $max : 10000) + )) { + $self->cgi_error("413 Request entity too large"); + last METHOD; + } + } + + # Process multipart postings, but only if the initializer is + # not defined. + if ($meth eq 'POST' + && defined($ENV{'CONTENT_TYPE'}) + && $ENV{'CONTENT_TYPE'}=~m|^multipart/form-data| + && !defined($initializer) + ) { + my($boundary) = $ENV{'CONTENT_TYPE'} =~ /boundary=\"?([^\";,]+)\"?/; + $self->read_multipart($boundary,$content_length); + last METHOD; + } + + # If initializer is defined, then read parameters + # from it. + if (defined($initializer)) { + if (UNIVERSAL::isa($initializer,'CGI')) { + $query_string = $initializer->query_string; + last METHOD; + } + if (ref($initializer) && ref($initializer) eq 'HASH') { + foreach (keys %$initializer) { + $self->param('-name'=>$_,'-value'=>$initializer->{$_}); + } + last METHOD; + } + + if (defined($fh) && ($fh ne '')) { + while (<$fh>) { + chomp; + last if /^=/; + push(@lines,$_); + } + # massage back into standard format + if ("@lines" =~ /=/) { + $query_string=join("&",@lines); + } else { + $query_string=join("+",@lines); + } + last METHOD; + } + + if (defined($fh) && ($fh ne '')) { + while (<$fh>) { + chomp; + last if /^=/; + push(@lines,$_); + } + # massage back into standard format + if ("@lines" =~ /=/) { + $query_string=join("&",@lines); + } else { + $query_string=join("+",@lines); + } + last METHOD; + } + + # last chance -- treat it as a string + $initializer = $$initializer if ref($initializer) eq 'SCALAR'; + $query_string = $initializer; + + last METHOD; + } + + # If method is GET or HEAD, fetch the query from + # the environment. + if ($meth=~/^(GET|HEAD)$/) { + if ($MOD_PERL) { + $query_string = $self->r->args; + } else { + $query_string = $ENV{'QUERY_STRING'} if defined $ENV{'QUERY_STRING'}; + $query_string ||= $ENV{'REDIRECT_QUERY_STRING'} if defined $ENV{'REDIRECT_QUERY_STRING'}; + } + last METHOD; + } + + if ($meth eq 'POST') { + $self->read_from_client(\$query_string,$content_length,0) + if $content_length > 0; + # Some people want to have their cake and eat it too! + # Uncomment this line to have the contents of the query string + # APPENDED to the POST data. + # $query_string .= (length($query_string) ? '&' : '') . $ENV{'QUERY_STRING'} if defined $ENV{'QUERY_STRING'}; + last METHOD; + } + + # If $meth is not of GET, POST or HEAD, assume we're being debugged offline. + # Check the command line and then the standard input for data. + # We use the shellwords package in order to behave the way that + # UN*X programmers expect. + if ($DEBUG) + { + my $cmdline_ret = read_from_cmdline(); + $query_string = $cmdline_ret->{'query_string'}; + if (defined($cmdline_ret->{'subpath'})) + { + $self->path_info($cmdline_ret->{'subpath'}); + } + } + } + +# YL: Begin Change for XML handler 10/19/2001 + if ($meth eq 'POST' + && defined($ENV{'CONTENT_TYPE'}) + && $ENV{'CONTENT_TYPE'} !~ m|^application/x-www-form-urlencoded| + && $ENV{'CONTENT_TYPE'} !~ m|^multipart/form-data| ) { + my($param) = 'POSTDATA' ; + $self->add_parameter($param) ; + push (@{$self->{$param}},$query_string); + undef $query_string ; + } +# YL: End Change for XML handler 10/19/2001 + + # We now have the query string in hand. We do slightly + # different things for keyword lists and parameter lists. + if (defined $query_string && length $query_string) { + if ($query_string =~ /[&=;]/) { + $self->parse_params($query_string); + } else { + $self->add_parameter('keywords'); + $self->{'keywords'} = [$self->parse_keywordlist($query_string)]; + } + } + + # Special case. Erase everything if there is a field named + # .defaults. + if ($self->param('.defaults')) { + $self->delete_all(); + } + + # Associative array containing our defined fieldnames + $self->{'.fieldnames'} = {}; + foreach ($self->param('.cgifields')) { + $self->{'.fieldnames'}->{$_}++; + } + + # Clear out our default submission button flag if present + $self->delete('.submit'); + $self->delete('.cgifields'); + + $self->save_request unless defined $initializer; +} + +# FUNCTIONS TO OVERRIDE: +# Turn a string into a filehandle +sub to_filehandle { + my $thingy = shift; + return undef unless $thingy; + return $thingy if UNIVERSAL::isa($thingy,'GLOB'); + return $thingy if UNIVERSAL::isa($thingy,'FileHandle'); + if (!ref($thingy)) { + my $caller = 1; + while (my $package = caller($caller++)) { + my($tmp) = $thingy=~/[\':]/ ? $thingy : "$package\:\:$thingy"; + return $tmp if defined(fileno($tmp)); + } + } + return undef; +} + +# send output to the browser +sub put { + my($self,@p) = self_or_default(@_); + $self->print(@p); +} + +# print to standard output (for overriding in mod_perl) +sub print { + shift; + CORE::print(@_); +} + +# get/set last cgi_error +sub cgi_error { + my ($self,$err) = self_or_default(@_); + $self->{'.cgi_error'} = $err if defined $err; + return $self->{'.cgi_error'}; +} + +sub save_request { + my($self) = @_; + # We're going to play with the package globals now so that if we get called + # again, we initialize ourselves in exactly the same way. This allows + # us to have several of these objects. + @QUERY_PARAM = $self->param; # save list of parameters + foreach (@QUERY_PARAM) { + next unless defined $_; + $QUERY_PARAM{$_}=$self->{$_}; + } + $QUERY_CHARSET = $self->charset; + %QUERY_FIELDNAMES = %{$self->{'.fieldnames'}}; +} + +sub parse_params { + my($self,$tosplit) = @_; + my(@pairs) = split(/[&;]/,$tosplit); + my($param,$value); + foreach (@pairs) { + ($param,$value) = split('=',$_,2); + next unless defined $param; + next if $NO_UNDEF_PARAMS and not defined $value; + $value = '' unless defined $value; + $param = unescape($param); + $value = unescape($value); + $self->add_parameter($param); + push (@{$self->{$param}},$value); + } +} + +sub add_parameter { + my($self,$param)=@_; + return unless defined $param; + push (@{$self->{'.parameters'}},$param) + unless defined($self->{$param}); +} + +sub all_parameters { + my $self = shift; + return () unless defined($self) && $self->{'.parameters'}; + return () unless @{$self->{'.parameters'}}; + return @{$self->{'.parameters'}}; +} + +# put a filehandle into binary mode (DOS) +sub binmode { + return unless defined($_[1]) && defined fileno($_[1]); + CORE::binmode($_[1]); +} + +sub _make_tag_func { + my ($self,$tagname) = @_; + my $func = qq( + sub $tagname { + my (\$q,\$a,\@rest) = self_or_default(\@_); + my(\$attr) = ''; + if (ref(\$a) && ref(\$a) eq 'HASH') { + my(\@attr) = make_attributes(\$a,\$q->{'escape'}); + \$attr = " \@attr" if \@attr; + } else { + unshift \@rest,\$a if defined \$a; + } + ); + if ($tagname=~/start_(\w+)/i) { + $func .= qq! return "<\L$1\E\$attr>";} !; + } elsif ($tagname=~/end_(\w+)/i) { + $func .= qq! return "<\L/$1\E>"; } !; + } else { + $func .= qq# + return \$XHTML ? "\L<$tagname\E\$attr />" : "\L<$tagname\E\$attr>" unless \@rest; + my(\$tag,\$untag) = ("\L<$tagname\E\$attr>","\L\E"); + my \@result = map { "\$tag\$_\$untag" } + (ref(\$rest[0]) eq 'ARRAY') ? \@{\$rest[0]} : "\@rest"; + return "\@result"; + }#; + } +return $func; +} + +sub AUTOLOAD { + print STDERR "CGI::AUTOLOAD for $AUTOLOAD\n" if $CGI::AUTOLOAD_DEBUG; + my $func = &_compile; + goto &$func; +} + +sub _compile { + my($func) = $AUTOLOAD; + my($pack,$func_name); + { + local($1,$2); # this fixes an obscure variable suicide problem. + $func=~/(.+)::([^:]+)$/; + ($pack,$func_name) = ($1,$2); + $pack=~s/::SUPER$//; # fix another obscure problem + $pack = ${"$pack\:\:AutoloadClass"} || $CGI::DefaultClass + unless defined(${"$pack\:\:AUTOLOADED_ROUTINES"}); + + my($sub) = \%{"$pack\:\:SUBS"}; + unless (%$sub) { + my($auto) = \${"$pack\:\:AUTOLOADED_ROUTINES"}; + eval "package $pack; $$auto"; + croak("$AUTOLOAD: $@") if $@; + $$auto = ''; # Free the unneeded storage (but don't undef it!!!) + } + my($code) = $sub->{$func_name}; + + $code = "sub $AUTOLOAD { }" if (!$code and $func_name eq 'DESTROY'); + if (!$code) { + (my $base = $func_name) =~ s/^(start_|end_)//i; + if ($EXPORT{':any'} || + $EXPORT{'-any'} || + $EXPORT{$base} || + (%EXPORT_OK || grep(++$EXPORT_OK{$_},&expand_tags(':html'))) + && $EXPORT_OK{$base}) { + $code = $CGI::DefaultClass->_make_tag_func($func_name); + } + } + croak("Undefined subroutine $AUTOLOAD\n") unless $code; + eval "package $pack; $code"; + if ($@) { + $@ =~ s/ at .*\n//; + croak("$AUTOLOAD: $@"); + } + } + CORE::delete($sub->{$func_name}); #free storage + return "$pack\:\:$func_name"; +} + +sub _selected { + my $self = shift; + my $value = shift; + return '' unless $value; + return $XHTML ? qq( selected="selected") : qq( selected); +} + +sub _checked { + my $self = shift; + my $value = shift; + return '' unless $value; + return $XHTML ? qq( checked="checked") : qq( checked); +} + +sub _reset_globals { initialize_globals(); } + +sub _setup_symbols { + my $self = shift; + my $compile = 0; + + # to avoid reexporting unwanted variables + undef %EXPORT; + + foreach (@_) { + $HEADERS_ONCE++, next if /^[:-]unique_headers$/; + $NPH++, next if /^[:-]nph$/; + $NOSTICKY++, next if /^[:-]nosticky$/; + $DEBUG=0, next if /^[:-]no_?[Dd]ebug$/; + $DEBUG=2, next if /^[:-][Dd]ebug$/; + $USE_PARAM_SEMICOLONS++, next if /^[:-]newstyle_urls$/; + $XHTML++, next if /^[:-]xhtml$/; + $XHTML=0, next if /^[:-]no_?xhtml$/; + $USE_PARAM_SEMICOLONS=0, next if /^[:-]oldstyle_urls$/; + $PRIVATE_TEMPFILES++, next if /^[:-]private_tempfiles$/; + $CLOSE_UPLOAD_FILES++, next if /^[:-]close_upload_files$/; + $EXPORT{$_}++, next if /^[:-]any$/; + $compile++, next if /^[:-]compile$/; + $NO_UNDEF_PARAMS++, next if /^[:-]no_undef_params$/; + + # This is probably extremely evil code -- to be deleted some day. + if (/^[-]autoload$/) { + my($pkg) = caller(1); + *{"${pkg}::AUTOLOAD"} = sub { + my($routine) = $AUTOLOAD; + $routine =~ s/^.*::/CGI::/; + &$routine; + }; + next; + } + + foreach (&expand_tags($_)) { + tr/a-zA-Z0-9_//cd; # don't allow weird function names + $EXPORT{$_}++; + } + } + _compile_all(keys %EXPORT) if $compile; + @SAVED_SYMBOLS = @_; +} + +sub charset { + my ($self,$charset) = self_or_default(@_); + $self->{'.charset'} = $charset if defined $charset; + $self->{'.charset'}; +} + +############################################################################### +################# THESE FUNCTIONS ARE AUTOLOADED ON DEMAND #################### +############################################################################### +$AUTOLOADED_ROUTINES = ''; # get rid of -w warning +$AUTOLOADED_ROUTINES=<<'END_OF_AUTOLOAD'; + +%SUBS = ( + +'URL_ENCODED'=> <<'END_OF_FUNC', +sub URL_ENCODED { 'application/x-www-form-urlencoded'; } +END_OF_FUNC + +'MULTIPART' => <<'END_OF_FUNC', +sub MULTIPART { 'multipart/form-data'; } +END_OF_FUNC + +'SERVER_PUSH' => <<'END_OF_FUNC', +sub SERVER_PUSH { 'multipart/x-mixed-replace;boundary="' . shift() . '"'; } +END_OF_FUNC + +'new_MultipartBuffer' => <<'END_OF_FUNC', +# Create a new multipart buffer +sub new_MultipartBuffer { + my($self,$boundary,$length) = @_; + return MultipartBuffer->new($self,$boundary,$length); +} +END_OF_FUNC + +'read_from_client' => <<'END_OF_FUNC', +# Read data from a file handle +sub read_from_client { + my($self, $buff, $len, $offset) = @_; + local $^W=0; # prevent a warning + return $MOD_PERL + ? $self->r->read($$buff, $len, $offset) + : read(\*STDIN, $$buff, $len, $offset); +} +END_OF_FUNC + +'delete' => <<'END_OF_FUNC', +#### Method: delete +# Deletes the named parameter entirely. +#### +sub delete { + my($self,@p) = self_or_default(@_); + my(@names) = rearrange([NAME],@p); + my @to_delete = ref($names[0]) eq 'ARRAY' ? @$names[0] : @names; + my %to_delete; + foreach my $name (@to_delete) + { + CORE::delete $self->{$name}; + CORE::delete $self->{'.fieldnames'}->{$name}; + $to_delete{$name}++; + } + @{$self->{'.parameters'}}=grep { !exists($to_delete{$_}) } $self->param(); + return; +} +END_OF_FUNC + +#### Method: import_names +# Import all parameters into the given namespace. +# Assumes namespace 'Q' if not specified +#### +'import_names' => <<'END_OF_FUNC', +sub import_names { + my($self,$namespace,$delete) = self_or_default(@_); + $namespace = 'Q' unless defined($namespace); + die "Can't import names into \"main\"\n" if \%{"${namespace}::"} == \%::; + if ($delete || $MOD_PERL || exists $ENV{'FCGI_ROLE'}) { + # can anyone find an easier way to do this? + foreach (keys %{"${namespace}::"}) { + local *symbol = "${namespace}::${_}"; + undef $symbol; + undef @symbol; + undef %symbol; + } + } + my($param,@value,$var); + foreach $param ($self->param) { + # protect against silly names + ($var = $param)=~tr/a-zA-Z0-9_/_/c; + $var =~ s/^(?=\d)/_/; + local *symbol = "${namespace}::$var"; + @value = $self->param($param); + @symbol = @value; + $symbol = $value[0]; + } +} +END_OF_FUNC + +#### Method: keywords +# Keywords acts a bit differently. Calling it in a list context +# returns the list of keywords. +# Calling it in a scalar context gives you the size of the list. +#### +'keywords' => <<'END_OF_FUNC', +sub keywords { + my($self,@values) = self_or_default(@_); + # If values is provided, then we set it. + $self->{'keywords'}=[@values] if @values; + my(@result) = defined($self->{'keywords'}) ? @{$self->{'keywords'}} : (); + @result; +} +END_OF_FUNC + +# These are some tie() interfaces for compatibility +# with Steve Brenner's cgi-lib.pl routines +'Vars' => <<'END_OF_FUNC', +sub Vars { + my $q = shift; + my %in; + tie(%in,CGI,$q); + return %in if wantarray; + return \%in; +} +END_OF_FUNC + +# These are some tie() interfaces for compatibility +# with Steve Brenner's cgi-lib.pl routines +'ReadParse' => <<'END_OF_FUNC', +sub ReadParse { + local(*in); + if (@_) { + *in = $_[0]; + } else { + my $pkg = caller(); + *in=*{"${pkg}::in"}; + } + tie(%in,CGI); + return scalar(keys %in); +} +END_OF_FUNC + +'PrintHeader' => <<'END_OF_FUNC', +sub PrintHeader { + my($self) = self_or_default(@_); + return $self->header(); +} +END_OF_FUNC + +'HtmlTop' => <<'END_OF_FUNC', +sub HtmlTop { + my($self,@p) = self_or_default(@_); + return $self->start_html(@p); +} +END_OF_FUNC + +'HtmlBot' => <<'END_OF_FUNC', +sub HtmlBot { + my($self,@p) = self_or_default(@_); + return $self->end_html(@p); +} +END_OF_FUNC + +'SplitParam' => <<'END_OF_FUNC', +sub SplitParam { + my ($param) = @_; + my (@params) = split ("\0", $param); + return (wantarray ? @params : $params[0]); +} +END_OF_FUNC + +'MethGet' => <<'END_OF_FUNC', +sub MethGet { + return request_method() eq 'GET'; +} +END_OF_FUNC + +'MethPost' => <<'END_OF_FUNC', +sub MethPost { + return request_method() eq 'POST'; +} +END_OF_FUNC + +'TIEHASH' => <<'END_OF_FUNC', +sub TIEHASH { + my $class = shift; + my $arg = $_[0]; + if (ref($arg) && UNIVERSAL::isa($arg,'CGI')) { + return $arg; + } + return $Q ||= $class->new(@_); +} +END_OF_FUNC + +'STORE' => <<'END_OF_FUNC', +sub STORE { + my $self = shift; + my $tag = shift; + my $vals = shift; + my @vals = index($vals,"\0")!=-1 ? split("\0",$vals) : $vals; + $self->param(-name=>$tag,-value=>\@vals); +} +END_OF_FUNC + +'FETCH' => <<'END_OF_FUNC', +sub FETCH { + return $_[0] if $_[1] eq 'CGI'; + return undef unless defined $_[0]->param($_[1]); + return join("\0",$_[0]->param($_[1])); +} +END_OF_FUNC + +'FIRSTKEY' => <<'END_OF_FUNC', +sub FIRSTKEY { + $_[0]->{'.iterator'}=0; + $_[0]->{'.parameters'}->[$_[0]->{'.iterator'}++]; +} +END_OF_FUNC + +'NEXTKEY' => <<'END_OF_FUNC', +sub NEXTKEY { + $_[0]->{'.parameters'}->[$_[0]->{'.iterator'}++]; +} +END_OF_FUNC + +'EXISTS' => <<'END_OF_FUNC', +sub EXISTS { + exists $_[0]->{$_[1]}; +} +END_OF_FUNC + +'DELETE' => <<'END_OF_FUNC', +sub DELETE { + $_[0]->delete($_[1]); +} +END_OF_FUNC + +'CLEAR' => <<'END_OF_FUNC', +sub CLEAR { + %{$_[0]}=(); +} +#### +END_OF_FUNC + +#### +# Append a new value to an existing query +#### +'append' => <<'EOF', +sub append { + my($self,@p) = @_; + my($name,$value) = rearrange([NAME,[VALUE,VALUES]],@p); + my(@values) = defined($value) ? (ref($value) ? @{$value} : $value) : (); + if (@values) { + $self->add_parameter($name); + push(@{$self->{$name}},@values); + } + return $self->param($name); +} +EOF + +#### Method: delete_all +# Delete all parameters +#### +'delete_all' => <<'EOF', +sub delete_all { + my($self) = self_or_default(@_); + my @param = $self->param(); + $self->delete(@param); +} +EOF + +'Delete' => <<'EOF', +sub Delete { + my($self,@p) = self_or_default(@_); + $self->delete(@p); +} +EOF + +'Delete_all' => <<'EOF', +sub Delete_all { + my($self,@p) = self_or_default(@_); + $self->delete_all(@p); +} +EOF + +#### Method: autoescape +# If you want to turn off the autoescaping features, +# call this method with undef as the argument +'autoEscape' => <<'END_OF_FUNC', +sub autoEscape { + my($self,$escape) = self_or_default(@_); + my $d = $self->{'escape'}; + $self->{'escape'} = $escape; + $d; +} +END_OF_FUNC + + +#### Method: version +# Return the current version +#### +'version' => <<'END_OF_FUNC', +sub version { + return $VERSION; +} +END_OF_FUNC + +#### Method: url_param +# Return a parameter in the QUERY_STRING, regardless of +# whether this was a POST or a GET +#### +'url_param' => <<'END_OF_FUNC', +sub url_param { + my ($self,@p) = self_or_default(@_); + my $name = shift(@p); + return undef unless exists($ENV{QUERY_STRING}); + unless (exists($self->{'.url_param'})) { + $self->{'.url_param'}={}; # empty hash + if ($ENV{QUERY_STRING} =~ /=/) { + my(@pairs) = split(/[&;]/,$ENV{QUERY_STRING}); + my($param,$value); + foreach (@pairs) { + ($param,$value) = split('=',$_,2); + $param = unescape($param); + $value = unescape($value); + push(@{$self->{'.url_param'}->{$param}},$value); + } + } else { + $self->{'.url_param'}->{'keywords'} = [$self->parse_keywordlist($ENV{QUERY_STRING})]; + } + } + return keys %{$self->{'.url_param'}} unless defined($name); + return () unless $self->{'.url_param'}->{$name}; + return wantarray ? @{$self->{'.url_param'}->{$name}} + : $self->{'.url_param'}->{$name}->[0]; +} +END_OF_FUNC + +#### Method: Dump +# Returns a string in which all the known parameter/value +# pairs are represented as nested lists, mainly for the purposes +# of debugging. +#### +'Dump' => <<'END_OF_FUNC', +sub Dump { + my($self) = self_or_default(@_); + my($param,$value,@result); + return '
    ' unless $self->param; + push(@result,"
      "); + foreach $param ($self->param) { + my($name)=$self->escapeHTML($param); + push(@result,"
    • $param
    • "); + push(@result,"
        "); + foreach $value ($self->param($param)) { + $value = $self->escapeHTML($value); + $value =~ s/\n/
        \n/g; + push(@result,"
      • $value
      • "); + } + push(@result,"
      "); + } + push(@result,"
    "); + return join("\n",@result); +} +END_OF_FUNC + +#### Method as_string +# +# synonym for "dump" +#### +'as_string' => <<'END_OF_FUNC', +sub as_string { + &Dump(@_); +} +END_OF_FUNC + +#### Method: save +# Write values out to a filehandle in such a way that they can +# be reinitialized by the filehandle form of the new() method +#### +'save' => <<'END_OF_FUNC', +sub save { + my($self,$filehandle) = self_or_default(@_); + $filehandle = to_filehandle($filehandle); + my($param); + local($,) = ''; # set print field separator back to a sane value + local($\) = ''; # set output line separator to a sane value + foreach $param ($self->param) { + my($escaped_param) = escape($param); + my($value); + foreach $value ($self->param($param)) { + print $filehandle "$escaped_param=",escape("$value"),"\n"; + } + } + foreach (keys %{$self->{'.fieldnames'}}) { + print $filehandle ".cgifields=",escape("$_"),"\n"; + } + print $filehandle "=\n"; # end of record +} +END_OF_FUNC + + +#### Method: save_parameters +# An alias for save() that is a better name for exportation. +# Only intended to be used with the function (non-OO) interface. +#### +'save_parameters' => <<'END_OF_FUNC', +sub save_parameters { + my $fh = shift; + return save(to_filehandle($fh)); +} +END_OF_FUNC + +#### Method: restore_parameters +# A way to restore CGI parameters from an initializer. +# Only intended to be used with the function (non-OO) interface. +#### +'restore_parameters' => <<'END_OF_FUNC', +sub restore_parameters { + $Q = $CGI::DefaultClass->new(@_); +} +END_OF_FUNC + +#### Method: multipart_init +# Return a Content-Type: style header for server-push +# This has to be NPH on most web servers, and it is advisable to set $| = 1 +# +# Many thanks to Ed Jordan for this +# contribution, updated by Andrew Benham (adsb@bigfoot.com) +#### +'multipart_init' => <<'END_OF_FUNC', +sub multipart_init { + my($self,@p) = self_or_default(@_); + my($boundary,@other) = rearrange([BOUNDARY],@p); + $boundary = $boundary || '------- =_aaaaaaaaaa0'; + $self->{'separator'} = "$CRLF--$boundary$CRLF"; + $self->{'final_separator'} = "$CRLF--$boundary--$CRLF"; + $type = SERVER_PUSH($boundary); + return $self->header( + -nph => 0, + -type => $type, + (map { split "=", $_, 2 } @other), + ) . "WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY." . $self->multipart_end; +} +END_OF_FUNC + + +#### Method: multipart_start +# Return a Content-Type: style header for server-push, start of section +# +# Many thanks to Ed Jordan for this +# contribution, updated by Andrew Benham (adsb@bigfoot.com) +#### +'multipart_start' => <<'END_OF_FUNC', +sub multipart_start { + my(@header); + my($self,@p) = self_or_default(@_); + my($type,@other) = rearrange([TYPE],@p); + $type = $type || 'text/html'; + push(@header,"Content-Type: $type"); + + # rearrange() was designed for the HTML portion, so we + # need to fix it up a little. + foreach (@other) { + # Don't use \s because of perl bug 21951 + next unless my($header,$value) = /([^ \r\n\t=]+)=\"?(.+?)\"?$/; + ($_ = $header) =~ s/^(\w)(.*)/$1 . lc ($2) . ': '.$self->unescapeHTML($value)/e; + } + push(@header,@other); + my $header = join($CRLF,@header)."${CRLF}${CRLF}"; + return $header; +} +END_OF_FUNC + + +#### Method: multipart_end +# Return a MIME boundary separator for server-push, end of section +# +# Many thanks to Ed Jordan for this +# contribution +#### +'multipart_end' => <<'END_OF_FUNC', +sub multipart_end { + my($self,@p) = self_or_default(@_); + return $self->{'separator'}; +} +END_OF_FUNC + + +#### Method: multipart_final +# Return a MIME boundary separator for server-push, end of all sections +# +# Contributed by Andrew Benham (adsb@bigfoot.com) +#### +'multipart_final' => <<'END_OF_FUNC', +sub multipart_final { + my($self,@p) = self_or_default(@_); + return $self->{'final_separator'} . "WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY." . $CRLF; +} +END_OF_FUNC + + +#### Method: header +# Return a Content-Type: style header +# +#### +'header' => <<'END_OF_FUNC', +sub header { + my($self,@p) = self_or_default(@_); + my(@header); + + return "" if $self->{'.header_printed'}++ and $HEADERS_ONCE; + + my($type,$status,$cookie,$target,$expires,$nph,$charset,$attachment,$p3p,@other) = + rearrange([['TYPE','CONTENT_TYPE','CONTENT-TYPE'], + 'STATUS',['COOKIE','COOKIES'],'TARGET', + 'EXPIRES','NPH','CHARSET', + 'ATTACHMENT','P3P'],@p); + + $nph ||= $NPH; + if (defined $charset) { + $self->charset($charset); + } else { + $charset = $self->charset; + } + + # rearrange() was designed for the HTML portion, so we + # need to fix it up a little. + foreach (@other) { + # Don't use \s because of perl bug 21951 + next unless my($header,$value) = /([^ \r\n\t=]+)=\"?(.+?)\"?$/; + ($_ = $header) =~ s/^(\w)(.*)/"\u$1\L$2" . ': '.$self->unescapeHTML($value)/e; + } + + $type ||= 'text/html' unless defined($type); + $type .= "; charset=$charset" if $type ne '' and $type =~ m!^text/! and $type !~ /\bcharset\b/ and $charset ne ''; + + # Maybe future compatibility. Maybe not. + my $protocol = $ENV{SERVER_PROTOCOL} || 'HTTP/1.0'; + push(@header,$protocol . ' ' . ($status || '200 OK')) if $nph; + push(@header,"Server: " . &server_software()) if $nph; + + push(@header,"Status: $status") if $status; + push(@header,"Window-Target: $target") if $target; + if ($p3p) { + $p3p = join ' ',@$p3p if ref($p3p) eq 'ARRAY'; + push(@header,qq(P3P: policyref="/w3c/p3p.xml", CP="$p3p")); + } + # push all the cookies -- there may be several + if ($cookie) { + my(@cookie) = ref($cookie) && ref($cookie) eq 'ARRAY' ? @{$cookie} : $cookie; + foreach (@cookie) { + my $cs = UNIVERSAL::isa($_,'CGI::Cookie') ? $_->as_string : $_; + push(@header,"Set-Cookie: $cs") if $cs ne ''; + } + } + # if the user indicates an expiration time, then we need + # both an Expires and a Date header (so that the browser is + # uses OUR clock) + push(@header,"Expires: " . expires($expires,'http')) + if $expires; + push(@header,"Date: " . expires(0,'http')) if $expires || $cookie || $nph; + push(@header,"Pragma: no-cache") if $self->cache(); + push(@header,"Content-Disposition: attachment; filename=\"$attachment\"") if $attachment; + push(@header,map {ucfirst $_} @other); + push(@header,"Content-Type: $type") if $type ne ''; + my $header = join($CRLF,@header)."${CRLF}${CRLF}"; + if ($MOD_PERL and not $nph) { + $self->r->send_cgi_header($header); + return ''; + } + return $header; +} +END_OF_FUNC + + +#### Method: cache +# Control whether header() will produce the no-cache +# Pragma directive. +#### +'cache' => <<'END_OF_FUNC', +sub cache { + my($self,$new_value) = self_or_default(@_); + $new_value = '' unless $new_value; + if ($new_value ne '') { + $self->{'cache'} = $new_value; + } + return $self->{'cache'}; +} +END_OF_FUNC + + +#### Method: redirect +# Return a Location: style header +# +#### +'redirect' => <<'END_OF_FUNC', +sub redirect { + my($self,@p) = self_or_default(@_); + my($url,$target,$status,$cookie,$nph,@other) = + rearrange([[LOCATION,URI,URL],TARGET,STATUS,['COOKIE','COOKIES'],NPH],@p); + $status = '302 Moved' unless defined $status; + $url ||= $self->self_url; + my(@o); + foreach (@other) { tr/\"//d; push(@o,split("=",$_,2)); } + unshift(@o, + '-Status' => $status, + '-Location'=> $url, + '-nph' => $nph); + unshift(@o,'-Target'=>$target) if $target; + unshift(@o,'-Type'=>''); + my @unescaped; + unshift(@unescaped,'-Cookie'=>$cookie) if $cookie; + return $self->header((map {$self->unescapeHTML($_)} @o),@unescaped); +} +END_OF_FUNC + + +#### Method: start_html +# Canned HTML header +# +# Parameters: +# $title -> (optional) The title for this HTML document (-title) +# $author -> (optional) e-mail address of the author (-author) +# $base -> (optional) if set to true, will enter the BASE address of this document +# for resolving relative references (-base) +# $xbase -> (optional) alternative base at some remote location (-xbase) +# $target -> (optional) target window to load all links into (-target) +# $script -> (option) Javascript code (-script) +# $no_script -> (option) Javascript +END + ; + my($other) = @other ? " @other" : ''; + push(@result,""); + return join("\n",@result); +} +END_OF_FUNC + +### Method: _style +# internal method for generating a CSS style section +#### +'_style' => <<'END_OF_FUNC', +sub _style { + my ($self,$style) = @_; + my (@result); + my $type = 'text/css'; + + my $cdata_start = $XHTML ? "\n\n" : " -->\n"; + + my @s = ref($style) eq 'ARRAY' ? @$style : $style; + + for my $s (@s) { + if (ref($s)) { + my($src,$code,$verbatim,$stype,$foo,@other) = + rearrange([qw(SRC CODE VERBATIM TYPE FOO)], + ('-foo'=>'bar', + ref($s) eq 'ARRAY' ? @$s : %$s)); + $type = $stype if $stype; + my $other = @other ? join ' ',@other : ''; + + if (ref($src) eq "ARRAY") # Check to see if the $src variable is an array reference + { # If it is, push a LINK tag for each one + foreach $src (@$src) + { + push(@result,$XHTML ? qq() + : qq()) if $src; + } + } + else + { # Otherwise, push the single -src, if it exists. + push(@result,$XHTML ? qq() + : qq() + ) if $src; + } + if ($verbatim) { + my @v = ref($verbatim) eq 'ARRAY' ? @$verbatim : $verbatim; + push(@result, "") foreach @v; + } + my @c = ref($code) eq 'ARRAY' ? @$code : $code if $code; + push(@result,style({'type'=>$type},"$cdata_start\n$_\n$cdata_end")) foreach @c; + + } else { + my $src = $s; + push(@result,$XHTML ? qq() + : qq()); + } + } + @result; +} +END_OF_FUNC + +'_script' => <<'END_OF_FUNC', +sub _script { + my ($self,$script) = @_; + my (@result); + + my (@scripts) = ref($script) eq 'ARRAY' ? @$script : ($script); + foreach $script (@scripts) { + my($src,$code,$language); + if (ref($script)) { # script is a hash + ($src,$code,$language, $type) = + rearrange([SRC,CODE,LANGUAGE,TYPE], + '-foo'=>'bar', # a trick to allow the '-' to be omitted + ref($script) eq 'ARRAY' ? @$script : %$script); + # User may not have specified language + $language ||= 'JavaScript'; + unless (defined $type) { + $type = lc $language; + # strip '1.2' from 'javascript1.2' + $type =~ s/^(\D+).*$/text\/$1/; + } + } else { + ($src,$code,$language, $type) = ('',$script,'JavaScript', 'text/javascript'); + } + + my $comment = '//'; # javascript by default + $comment = '#' if $type=~/perl|tcl/i; + $comment = "'" if $type=~/vbscript/i; + + my ($cdata_start,$cdata_end); + if ($XHTML) { + $cdata_start = "$comment"; + } else { + $cdata_start = "\n\n"; + } + my(@satts); + push(@satts,'src'=>$src) if $src; + push(@satts,'language'=>$language) unless defined $type; + push(@satts,'type'=>$type); + $code = "$cdata_start$code$cdata_end" if defined $code; + push(@result,script({@satts},$code || '')); + } + @result; +} +END_OF_FUNC + +#### Method: end_html +# End an HTML document. +# Trivial method for completeness. Just returns "" +#### +'end_html' => <<'END_OF_FUNC', +sub end_html { + return ""; +} +END_OF_FUNC + + +################################ +# METHODS USED IN BUILDING FORMS +################################ + +#### Method: isindex +# Just prints out the isindex tag. +# Parameters: +# $action -> optional URL of script to run +# Returns: +# A string containing a tag +'isindex' => <<'END_OF_FUNC', +sub isindex { + my($self,@p) = self_or_default(@_); + my($action,@other) = rearrange([ACTION],@p); + $action = qq/ action="$action"/ if $action; + my($other) = @other ? " @other" : ''; + return $XHTML ? "" : ""; +} +END_OF_FUNC + + +#### Method: startform +# Start a form +# Parameters: +# $method -> optional submission method to use (GET or POST) +# $action -> optional URL of script to run +# $enctype ->encoding to use (URL_ENCODED or MULTIPART) +'startform' => <<'END_OF_FUNC', +sub startform { + my($self,@p) = self_or_default(@_); + + my($method,$action,$enctype,@other) = + rearrange([METHOD,ACTION,ENCTYPE],@p); + + $method = $self->escapeHTML(lc($method) || 'post'); + $enctype = $self->escapeHTML($enctype || &URL_ENCODED); + if (defined $action) { + $action = $self->escapeHTML($action); + } + else { + $action = $self->escapeHTML($self->url(-absolute=>1,-path=>1)); + if (exists $ENV{QUERY_STRING} && length($ENV{QUERY_STRING})>0) { + $action .= "?".$self->escapeHTML($ENV{QUERY_STRING},1); + } + } + $action = qq(action="$action"); + my($other) = @other ? " @other" : ''; + $self->{'.parametersToAdd'}={}; + return qq/
    \n/; +} +END_OF_FUNC + + +#### Method: start_form +# synonym for startform +'start_form' => <<'END_OF_FUNC', +sub start_form { + &startform; +} +END_OF_FUNC + +'end_multipart_form' => <<'END_OF_FUNC', +sub end_multipart_form { + &endform; +} +END_OF_FUNC + +#### Method: start_multipart_form +# synonym for startform +'start_multipart_form' => <<'END_OF_FUNC', +sub start_multipart_form { + my($self,@p) = self_or_default(@_); + if (defined($param[0]) && substr($param[0],0,1) eq '-') { + my(%p) = @p; + $p{'-enctype'}=&MULTIPART; + return $self->startform(%p); + } else { + my($method,$action,@other) = + rearrange([METHOD,ACTION],@p); + return $self->startform($method,$action,&MULTIPART,@other); + } +} +END_OF_FUNC + + +#### Method: endform +# End a form +'endform' => <<'END_OF_FUNC', +sub endform { + my($self,@p) = self_or_default(@_); + if ( $NOSTICKY ) { + return wantarray ? ("
    ") : "\n"; + } else { + return wantarray ? ("
    ",$self->get_fields,"
    ","") : + "
    ".$self->get_fields ."
    \n"; + } +} +END_OF_FUNC + + +'_textfield' => <<'END_OF_FUNC', +sub _textfield { + my($self,$tag,@p) = self_or_default(@_); + my($name,$default,$size,$maxlength,$override,@other) = + rearrange([NAME,[DEFAULT,VALUE,VALUES],SIZE,MAXLENGTH,[OVERRIDE,FORCE]],@p); + + my $current = $override ? $default : + (defined($self->param($name)) ? $self->param($name) : $default); + + $current = defined($current) ? $self->escapeHTML($current,1) : ''; + $name = defined($name) ? $self->escapeHTML($name) : ''; + my($s) = defined($size) ? qq/ size="$size"/ : ''; + my($m) = defined($maxlength) ? qq/ maxlength="$maxlength"/ : ''; + my($other) = @other ? " @other" : ''; + # this entered at cristy's request to fix problems with file upload fields + # and WebTV -- not sure it won't break stuff + my($value) = $current ne '' ? qq(value="$current") : ''; + return $XHTML ? qq() + : qq(); +} +END_OF_FUNC + +#### Method: textfield +# Parameters: +# $name -> Name of the text field +# $default -> Optional default value of the field if not +# already defined. +# $size -> Optional width of field in characaters. +# $maxlength -> Optional maximum number of characters. +# Returns: +# A string containing a field +# +'textfield' => <<'END_OF_FUNC', +sub textfield { + my($self,@p) = self_or_default(@_); + $self->_textfield('text',@p); +} +END_OF_FUNC + + +#### Method: filefield +# Parameters: +# $name -> Name of the file upload field +# $size -> Optional width of field in characaters. +# $maxlength -> Optional maximum number of characters. +# Returns: +# A string containing a field +# +'filefield' => <<'END_OF_FUNC', +sub filefield { + my($self,@p) = self_or_default(@_); + $self->_textfield('file',@p); +} +END_OF_FUNC + + +#### Method: password +# Create a "secret password" entry field +# Parameters: +# $name -> Name of the field +# $default -> Optional default value of the field if not +# already defined. +# $size -> Optional width of field in characters. +# $maxlength -> Optional maximum characters that can be entered. +# Returns: +# A string containing a field +# +'password_field' => <<'END_OF_FUNC', +sub password_field { + my ($self,@p) = self_or_default(@_); + $self->_textfield('password',@p); +} +END_OF_FUNC + +#### Method: textarea +# Parameters: +# $name -> Name of the text field +# $default -> Optional default value of the field if not +# already defined. +# $rows -> Optional number of rows in text area +# $columns -> Optional number of columns in text area +# Returns: +# A string containing a tag +# +'textarea' => <<'END_OF_FUNC', +sub textarea { + my($self,@p) = self_or_default(@_); + + my($name,$default,$rows,$cols,$override,@other) = + rearrange([NAME,[DEFAULT,VALUE],ROWS,[COLS,COLUMNS],[OVERRIDE,FORCE]],@p); + + my($current)= $override ? $default : + (defined($self->param($name)) ? $self->param($name) : $default); + + $name = defined($name) ? $self->escapeHTML($name) : ''; + $current = defined($current) ? $self->escapeHTML($current) : ''; + my($r) = $rows ? qq/ rows="$rows"/ : ''; + my($c) = $cols ? qq/ cols="$cols"/ : ''; + my($other) = @other ? " @other" : ''; + return qq{}; +} +END_OF_FUNC + + +#### Method: button +# Create a javascript button. +# Parameters: +# $name -> (optional) Name for the button. (-name) +# $value -> (optional) Value of the button when selected (and visible name) (-value) +# $onclick -> (optional) Text of the JavaScript to run when the button is +# clicked. +# Returns: +# A string containing a tag +#### +'button' => <<'END_OF_FUNC', +sub button { + my($self,@p) = self_or_default(@_); + + my($label,$value,$script,@other) = rearrange([NAME,[VALUE,LABEL], + [ONCLICK,SCRIPT]],@p); + + $label=$self->escapeHTML($label); + $value=$self->escapeHTML($value,1); + $script=$self->escapeHTML($script); + + my($name) = ''; + $name = qq/ name="$label"/ if $label; + $value = $value || $label; + my($val) = ''; + $val = qq/ value="$value"/ if $value; + $script = qq/ onclick="$script"/ if $script; + my($other) = @other ? " @other" : ''; + return $XHTML ? qq() + : qq(); +} +END_OF_FUNC + + +#### Method: submit +# Create a "submit query" button. +# Parameters: +# $name -> (optional) Name for the button. +# $value -> (optional) Value of the button when selected (also doubles as label). +# $label -> (optional) Label printed on the button(also doubles as the value). +# Returns: +# A string containing a tag +#### +'submit' => <<'END_OF_FUNC', +sub submit { + my($self,@p) = self_or_default(@_); + + my($label,$value,@other) = rearrange([NAME,[VALUE,LABEL]],@p); + + $label=$self->escapeHTML($label); + $value=$self->escapeHTML($value,1); + + my $name = $NOSTICKY ? '' : ' name=".submit"'; + $name = qq/ name="$label"/ if defined($label); + $value = defined($value) ? $value : $label; + my $val = ''; + $val = qq/ value="$value"/ if defined($value); + my($other) = @other ? " @other" : ''; + return $XHTML ? qq() + : qq(); +} +END_OF_FUNC + + +#### Method: reset +# Create a "reset" button. +# Parameters: +# $name -> (optional) Name for the button. +# Returns: +# A string containing a tag +#### +'reset' => <<'END_OF_FUNC', +sub reset { + my($self,@p) = self_or_default(@_); + my($label,$value,@other) = rearrange(['NAME',['VALUE','LABEL']],@p); + $label=$self->escapeHTML($label); + $value=$self->escapeHTML($value,1); + my ($name) = ' name=".reset"'; + $name = qq/ name="$label"/ if defined($label); + $value = defined($value) ? $value : $label; + my($val) = ''; + $val = qq/ value="$value"/ if defined($value); + my($other) = @other ? " @other" : ''; + return $XHTML ? qq() + : qq(); +} +END_OF_FUNC + + +#### Method: defaults +# Create a "defaults" button. +# Parameters: +# $name -> (optional) Name for the button. +# Returns: +# A string containing a tag +# +# Note: this button has a special meaning to the initialization script, +# and tells it to ERASE the current query string so that your defaults +# are used again! +#### +'defaults' => <<'END_OF_FUNC', +sub defaults { + my($self,@p) = self_or_default(@_); + + my($label,@other) = rearrange([[NAME,VALUE]],@p); + + $label=$self->escapeHTML($label,1); + $label = $label || "Defaults"; + my($value) = qq/ value="$label"/; + my($other) = @other ? " @other" : ''; + return $XHTML ? qq() + : qq//; +} +END_OF_FUNC + + +#### Method: comment +# Create an HTML +# Parameters: a string +'comment' => <<'END_OF_FUNC', +sub comment { + my($self,@p) = self_or_CGI(@_); + return ""; +} +END_OF_FUNC + +#### Method: checkbox +# Create a checkbox that is not logically linked to any others. +# The field value is "on" when the button is checked. +# Parameters: +# $name -> Name of the checkbox +# $checked -> (optional) turned on by default if true +# $value -> (optional) value of the checkbox, 'on' by default +# $label -> (optional) a user-readable label printed next to the box. +# Otherwise the checkbox name is used. +# Returns: +# A string containing a field +#### +'checkbox' => <<'END_OF_FUNC', +sub checkbox { + my($self,@p) = self_or_default(@_); + + my($name,$checked,$value,$label,$override,@other) = + rearrange([NAME,[CHECKED,SELECTED,ON],VALUE,LABEL,[OVERRIDE,FORCE]],@p); + + $value = defined $value ? $value : 'on'; + + if (!$override && ($self->{'.fieldnames'}->{$name} || + defined $self->param($name))) { + $checked = grep($_ eq $value,$self->param($name)) ? $self->_checked(1) : ''; + } else { + $checked = $self->_checked($checked); + } + my($the_label) = defined $label ? $label : $name; + $name = $self->escapeHTML($name); + $value = $self->escapeHTML($value,1); + $the_label = $self->escapeHTML($the_label); + my($other) = @other ? " @other" : ''; + $self->register_parameter($name); + return $XHTML ? qq{$the_label} + : qq{$the_label}; +} +END_OF_FUNC + + +#### Method: checkbox_group +# Create a list of logically-linked checkboxes. +# Parameters: +# $name -> Common name for all the check boxes +# $values -> A pointer to a regular array containing the +# values for each checkbox in the group. +# $defaults -> (optional) +# 1. If a pointer to a regular array of checkbox values, +# then this will be used to decide which +# checkboxes to turn on by default. +# 2. If a scalar, will be assumed to hold the +# value of a single checkbox in the group to turn on. +# $linebreak -> (optional) Set to true to place linebreaks +# between the buttons. +# $labels -> (optional) +# A pointer to an associative array of labels to print next to each checkbox +# in the form $label{'value'}="Long explanatory label". +# Otherwise the provided values are used as the labels. +# Returns: +# An ARRAY containing a series of fields +#### +'checkbox_group' => <<'END_OF_FUNC', +sub checkbox_group { + my($self,@p) = self_or_default(@_); + + my($name,$values,$defaults,$linebreak,$labels,$attributes,$rows,$columns, + $rowheaders,$colheaders,$override,$nolabels,@other) = + rearrange([NAME,[VALUES,VALUE],[DEFAULTS,DEFAULT], + LINEBREAK,LABELS,ATTRIBUTES,ROWS,[COLUMNS,COLS], + ROWHEADERS,COLHEADERS, + [OVERRIDE,FORCE],NOLABELS],@p); + + my($checked,$break,$result,$label); + + my(%checked) = $self->previous_or_default($name,$defaults,$override); + + if ($linebreak) { + $break = $XHTML ? "
    " : "
    "; + } + else { + $break = ''; + } + $name=$self->escapeHTML($name); + + # Create the elements + my(@elements,@values); + + @values = $self->_set_values_and_labels($values,\$labels,$name); + + my($other) = @other ? " @other" : ''; + foreach (@values) { + $checked = $self->_checked($checked{$_}); + $label = ''; + unless (defined($nolabels) && $nolabels) { + $label = $_; + $label = $labels->{$_} if defined($labels) && defined($labels->{$_}); + $label = $self->escapeHTML($label); + } + my $attribs = $self->_set_attributes($_, $attributes); + $_ = $self->escapeHTML($_,1); + push(@elements,$XHTML ? qq(${label}${break}) + : qq/${label}${break}/); + } + $self->register_parameter($name); + return wantarray ? @elements : join(' ',@elements) + unless defined($columns) || defined($rows); + $rows = 1 if $rows && $rows < 1; + $cols = 1 if $cols && $cols < 1; + return _tableize($rows,$columns,$rowheaders,$colheaders,@elements); +} +END_OF_FUNC + +# Escape HTML -- used internally +'escapeHTML' => <<'END_OF_FUNC', +sub escapeHTML { + # hack to work around earlier hacks + push @_,$_[0] if @_==1 && $_[0] eq 'CGI'; + my ($self,$toencode,$newlinestoo) = CGI::self_or_default(@_); + return undef unless defined($toencode); + return $toencode if ref($self) && !$self->{'escape'}; + $toencode =~ s{&}{&}gso; + $toencode =~ s{<}{<}gso; + $toencode =~ s{>}{>}gso; + if ($DTD_PUBLIC_IDENTIFIER =~ /[^X]HTML 3\.2/i) { + # $quot; was accidentally omitted from the HTML 3.2 DTD -- see + # / + # . + $toencode =~ s{"}{"}gso; + } + else { + $toencode =~ s{"}{"}gso; + } + my $latin = uc $self->{'.charset'} eq 'ISO-8859-1' || + uc $self->{'.charset'} eq 'WINDOWS-1252'; + if ($latin) { # bug in some browsers + $toencode =~ s{'}{'}gso; + $toencode =~ s{\x8b}{‹}gso; + $toencode =~ s{\x9b}{›}gso; + if (defined $newlinestoo && $newlinestoo) { + $toencode =~ s{\012}{ }gso; + $toencode =~ s{\015}{ }gso; + } + } + return $toencode; +} +END_OF_FUNC + +# unescape HTML -- used internally +'unescapeHTML' => <<'END_OF_FUNC', +sub unescapeHTML { + # hack to work around earlier hacks + push @_,$_[0] if @_==1 && $_[0] eq 'CGI'; + my ($self,$string) = CGI::self_or_default(@_); + return undef unless defined($string); + my $latin = defined $self->{'.charset'} ? $self->{'.charset'} =~ /^(ISO-8859-1|WINDOWS-1252)$/i + : 1; + # thanks to Randal Schwartz for the correct solution to this one + $string=~ s[&(.*?);]{ + local $_ = $1; + /^amp$/i ? "&" : + /^quot$/i ? '"' : + /^gt$/i ? ">" : + /^lt$/i ? "<" : + /^#(\d+)$/ && $latin ? chr($1) : + /^#x([0-9a-f]+)$/i && $latin ? chr(hex($1)) : + $_ + }gex; + return $string; +} +END_OF_FUNC + +# Internal procedure - don't use +'_tableize' => <<'END_OF_FUNC', +sub _tableize { + my($rows,$columns,$rowheaders,$colheaders,@elements) = @_; + $rowheaders = [] unless defined $rowheaders; + $colheaders = [] unless defined $colheaders; + my($result); + + if (defined($columns)) { + $rows = int(0.99 + @elements/$columns) unless defined($rows); + } + if (defined($rows)) { + $columns = int(0.99 + @elements/$rows) unless defined($columns); + } + + # rearrange into a pretty table + $result = ""; + my($row,$column); + unshift(@$colheaders,'') if @$colheaders && @$rowheaders; + $result .= "" if @{$colheaders}; + foreach (@{$colheaders}) { + $result .= ""; + } + for ($row=0;$row<$rows;$row++) { + $result .= ""; + $result .= "" if @$rowheaders; + for ($column=0;$column<$columns;$column++) { + $result .= "" + if defined($elements[$column*$rows + $row]); + } + $result .= ""; + } + $result .= "
    $_
    $rowheaders->[$row]" . $elements[$column*$rows + $row] . "
    "; + return $result; +} +END_OF_FUNC + + +#### Method: radio_group +# Create a list of logically-linked radio buttons. +# Parameters: +# $name -> Common name for all the buttons. +# $values -> A pointer to a regular array containing the +# values for each button in the group. +# $default -> (optional) Value of the button to turn on by default. Pass '-' +# to turn _nothing_ on. +# $linebreak -> (optional) Set to true to place linebreaks +# between the buttons. +# $labels -> (optional) +# A pointer to an associative array of labels to print next to each checkbox +# in the form $label{'value'}="Long explanatory label". +# Otherwise the provided values are used as the labels. +# Returns: +# An ARRAY containing a series of fields +#### +'radio_group' => <<'END_OF_FUNC', +sub radio_group { + my($self,@p) = self_or_default(@_); + + my($name,$values,$default,$linebreak,$labels,$attributes, + $rows,$columns,$rowheaders,$colheaders,$override,$nolabels,@other) = + rearrange([NAME,[VALUES,VALUE],DEFAULT,LINEBREAK,LABELS,ATTRIBUTES, + ROWS,[COLUMNS,COLS], + ROWHEADERS,COLHEADERS, + [OVERRIDE,FORCE],NOLABELS],@p); + my($result,$checked); + + if (!$override && defined($self->param($name))) { + $checked = $self->param($name); + } else { + $checked = $default; + } + my(@elements,@values); + @values = $self->_set_values_and_labels($values,\$labels,$name); + + # If no check array is specified, check the first by default + $checked = $values[0] unless defined($checked) && $checked ne ''; + $name=$self->escapeHTML($name); + + my($other) = @other ? " @other" : ''; + foreach (@values) { + my($checkit) = $checked eq $_ ? qq/ checked="checked"/ : ''; + my($break); + if ($linebreak) { + $break = $XHTML ? "
    " : "
    "; + } + else { + $break = ''; + } + my($label)=''; + unless (defined($nolabels) && $nolabels) { + $label = $_; + $label = $labels->{$_} if defined($labels) && defined($labels->{$_}); + $label = $self->escapeHTML($label,1); + } + my $attribs = $self->_set_attributes($_, $attributes); + $_=$self->escapeHTML($_); + push(@elements,$XHTML ? qq(${label}${break}) + : qq/${label}${break}/); + } + $self->register_parameter($name); + return wantarray ? @elements : join(' ',@elements) + unless defined($columns) || defined($rows); + return _tableize($rows,$columns,$rowheaders,$colheaders,@elements); +} +END_OF_FUNC + + +#### Method: popup_menu +# Create a popup menu. +# Parameters: +# $name -> Name for all the menu +# $values -> A pointer to a regular array containing the +# text of each menu item. +# $default -> (optional) Default item to display +# $labels -> (optional) +# A pointer to an associative array of labels to print next to each checkbox +# in the form $label{'value'}="Long explanatory label". +# Otherwise the provided values are used as the labels. +# Returns: +# A string containing the definition of a popup menu. +#### +'popup_menu' => <<'END_OF_FUNC', +sub popup_menu { + my($self,@p) = self_or_default(@_); + + my($name,$values,$default,$labels,$attributes,$override,@other) = + rearrange([NAME,[VALUES,VALUE],[DEFAULT,DEFAULTS],LABELS, + ATTRIBUTES,[OVERRIDE,FORCE]],@p); + my($result,$selected); + + if (!$override && defined($self->param($name))) { + $selected = $self->param($name); + } else { + $selected = $default; + } + $name=$self->escapeHTML($name); + my($other) = @other ? " @other" : ''; + + my(@values); + @values = $self->_set_values_and_labels($values,\$labels,$name); + + $result = qq/"; + return $result; +} +END_OF_FUNC + + +#### Method: optgroup +# Create a optgroup. +# Parameters: +# $name -> Label for the group +# $values -> A pointer to a regular array containing the +# values for each option line in the group. +# $labels -> (optional) +# A pointer to an associative array of labels to print next to each item +# in the form $label{'value'}="Long explanatory label". +# Otherwise the provided values are used as the labels. +# $labeled -> (optional) +# A true value indicates the value should be used as the label attribute +# in the option elements. +# The label attribute specifies the option label presented to the user. +# This defaults to the content of the \n/; + foreach (@values) { + if (/_set_attributes($_, $attributes); + my($label) = $_; + $label = $labels->{$_} if defined($labels) && defined($labels->{$_}); + $label=$self->escapeHTML($label); + my($value)=$self->escapeHTML($_,1); + $result .= $labeled ? $novals ? "$label\n" + : "$label\n" + : $novals ? "$label\n" + : "$label\n"; + } + } + $result .= ""; + return $result; +} +END_OF_FUNC + + +#### Method: scrolling_list +# Create a scrolling list. +# Parameters: +# $name -> name for the list +# $values -> A pointer to a regular array containing the +# values for each option line in the list. +# $defaults -> (optional) +# 1. If a pointer to a regular array of options, +# then this will be used to decide which +# lines to turn on by default. +# 2. Otherwise holds the value of the single line to turn on. +# $size -> (optional) Size of the list. +# $multiple -> (optional) If set, allow multiple selections. +# $labels -> (optional) +# A pointer to an associative array of labels to print next to each checkbox +# in the form $label{'value'}="Long explanatory label". +# Otherwise the provided values are used as the labels. +# Returns: +# A string containing the definition of a scrolling list. +#### +'scrolling_list' => <<'END_OF_FUNC', +sub scrolling_list { + my($self,@p) = self_or_default(@_); + my($name,$values,$defaults,$size,$multiple,$labels,$attributes,$override,@other) + = rearrange([NAME,[VALUES,VALUE],[DEFAULTS,DEFAULT], + SIZE,MULTIPLE,LABELS,ATTRIBUTES,[OVERRIDE,FORCE]],@p); + + my($result,@values); + @values = $self->_set_values_and_labels($values,\$labels,$name); + + $size = $size || scalar(@values); + + my(%selected) = $self->previous_or_default($name,$defaults,$override); + my($is_multiple) = $multiple ? qq/ multiple="multiple"/ : ''; + my($has_size) = $size ? qq/ size="$size"/: ''; + my($other) = @other ? " @other" : ''; + + $name=$self->escapeHTML($name); + $result = qq/"; + $self->register_parameter($name); + return $result; +} +END_OF_FUNC + + +#### Method: hidden +# Parameters: +# $name -> Name of the hidden field +# @default -> (optional) Initial values of field (may be an array) +# or +# $default->[initial values of field] +# Returns: +# A string containing a +#### +'hidden' => <<'END_OF_FUNC', +sub hidden { + my($self,@p) = self_or_default(@_); + + # this is the one place where we departed from our standard + # calling scheme, so we have to special-case (darn) + my(@result,@value); + my($name,$default,$override,@other) = + rearrange([NAME,[DEFAULT,VALUE,VALUES],[OVERRIDE,FORCE]],@p); + + my $do_override = 0; + if ( ref($p[0]) || substr($p[0],0,1) eq '-') { + @value = ref($default) ? @{$default} : $default; + $do_override = $override; + } else { + foreach ($default,$override,@other) { + push(@value,$_) if defined($_); + } + } + + # use previous values if override is not set + my @prev = $self->param($name); + @value = @prev if !$do_override && @prev; + + $name=$self->escapeHTML($name); + foreach (@value) { + $_ = defined($_) ? $self->escapeHTML($_,1) : ''; + push @result,$XHTML ? qq() + : qq(); + } + return wantarray ? @result : join('',@result); +} +END_OF_FUNC + + +#### Method: image_button +# Parameters: +# $name -> Name of the button +# $src -> URL of the image source +# $align -> Alignment style (TOP, BOTTOM or MIDDLE) +# Returns: +# A string containing a +#### +'image_button' => <<'END_OF_FUNC', +sub image_button { + my($self,@p) = self_or_default(@_); + + my($name,$src,$alignment,@other) = + rearrange([NAME,SRC,ALIGN],@p); + + my($align) = $alignment ? " align=\U\"$alignment\"" : ''; + my($other) = @other ? " @other" : ''; + $name=$self->escapeHTML($name); + return $XHTML ? qq() + : qq//; +} +END_OF_FUNC + + +#### Method: self_url +# Returns a URL containing the current script and all its +# param/value pairs arranged as a query. You can use this +# to create a link that, when selected, will reinvoke the +# script with all its state information preserved. +#### +'self_url' => <<'END_OF_FUNC', +sub self_url { + my($self,@p) = self_or_default(@_); + return $self->url('-path_info'=>1,'-query'=>1,'-full'=>1,@p); +} +END_OF_FUNC + + +# This is provided as a synonym to self_url() for people unfortunate +# enough to have incorporated it into their programs already! +'state' => <<'END_OF_FUNC', +sub state { + &self_url; +} +END_OF_FUNC + + +#### Method: url +# Like self_url, but doesn't return the query string part of +# the URL. +#### +'url' => <<'END_OF_FUNC', +sub url { + my($self,@p) = self_or_default(@_); + my ($relative,$absolute,$full,$path_info,$query,$base) = + rearrange(['RELATIVE','ABSOLUTE','FULL',['PATH','PATH_INFO'],['QUERY','QUERY_STRING'],'BASE'],@p); + my $url; + $full++ if $base || !($relative || $absolute); + + my $path = $self->path_info; + my $script_name = $self->script_name; + + # for compatibility with Apache's MultiViews + if (exists($ENV{REQUEST_URI})) { + my $index; + $script_name = unescape($ENV{REQUEST_URI}); + $script_name =~ s/\?.+$//s; # strip query string + # and path + if (exists($ENV{PATH_INFO})) { + my $encoded_path = unescape($ENV{PATH_INFO}); + $script_name =~ s/\Q$encoded_path\E$//i; + } + } + + if ($full) { + my $protocol = $self->protocol(); + $url = "$protocol://"; + my $vh = http('x_forwarded_host') || http('host'); + if ($vh) { + $url .= $vh; + } else { + $url .= server_name(); + my $port = $self->server_port; + $url .= ":" . $port + unless (lc($protocol) eq 'http' && $port == 80) + || (lc($protocol) eq 'https' && $port == 443); + } + return $url if $base; + $url .= $script_name; + } elsif ($relative) { + ($url) = $script_name =~ m!([^/]+)$!; + } elsif ($absolute) { + $url = $script_name; + } + + $url .= $path if $path_info and defined $path; + $url .= "?" . $self->query_string if $query and $self->query_string; + $url = '' unless defined $url; + $url =~ s/([^a-zA-Z0-9_.%;&?\/\\:+=~-])/sprintf("%%%02X",ord($1))/eg; + return $url; +} + +END_OF_FUNC + +#### Method: cookie +# Set or read a cookie from the specified name. +# Cookie can then be passed to header(). +# Usual rules apply to the stickiness of -value. +# Parameters: +# -name -> name for this cookie (optional) +# -value -> value of this cookie (scalar, array or hash) +# -path -> paths for which this cookie is valid (optional) +# -domain -> internet domain in which this cookie is valid (optional) +# -secure -> if true, cookie only passed through secure channel (optional) +# -expires -> expiry date in format Wdy, DD-Mon-YYYY HH:MM:SS GMT (optional) +#### +'cookie' => <<'END_OF_FUNC', +sub cookie { + my($self,@p) = self_or_default(@_); + my($name,$value,$path,$domain,$secure,$expires) = + rearrange([NAME,[VALUE,VALUES],PATH,DOMAIN,SECURE,EXPIRES],@p); + + require CGI::Cookie; + + # if no value is supplied, then we retrieve the + # value of the cookie, if any. For efficiency, we cache the parsed + # cookies in our state variables. + unless ( defined($value) ) { + $self->{'.cookies'} = CGI::Cookie->fetch + unless $self->{'.cookies'}; + + # If no name is supplied, then retrieve the names of all our cookies. + return () unless $self->{'.cookies'}; + return keys %{$self->{'.cookies'}} unless $name; + return () unless $self->{'.cookies'}->{$name}; + return $self->{'.cookies'}->{$name}->value if defined($name) && $name ne ''; + } + + # If we get here, we're creating a new cookie + return undef unless defined($name) && $name ne ''; # this is an error + + my @param; + push(@param,'-name'=>$name); + push(@param,'-value'=>$value); + push(@param,'-domain'=>$domain) if $domain; + push(@param,'-path'=>$path) if $path; + push(@param,'-expires'=>$expires) if $expires; + push(@param,'-secure'=>$secure) if $secure; + + return new CGI::Cookie(@param); +} +END_OF_FUNC + +'parse_keywordlist' => <<'END_OF_FUNC', +sub parse_keywordlist { + my($self,$tosplit) = @_; + $tosplit = unescape($tosplit); # unescape the keywords + $tosplit=~tr/+/ /; # pluses to spaces + my(@keywords) = split(/\s+/,$tosplit); + return @keywords; +} +END_OF_FUNC + +'param_fetch' => <<'END_OF_FUNC', +sub param_fetch { + my($self,@p) = self_or_default(@_); + my($name) = rearrange([NAME],@p); + unless (exists($self->{$name})) { + $self->add_parameter($name); + $self->{$name} = []; + } + + return $self->{$name}; +} +END_OF_FUNC + +############################################### +# OTHER INFORMATION PROVIDED BY THE ENVIRONMENT +############################################### + +#### Method: path_info +# Return the extra virtual path information provided +# after the URL (if any) +#### +'path_info' => <<'END_OF_FUNC', +sub path_info { + my ($self,$info) = self_or_default(@_); + if (defined($info)) { + $info = "/$info" if $info ne '' && substr($info,0,1) ne '/'; + $self->{'.path_info'} = $info; + } elsif (! defined($self->{'.path_info'}) ) { + $self->{'.path_info'} = defined($ENV{'PATH_INFO'}) ? + $ENV{'PATH_INFO'} : ''; + + # hack to fix broken path info in IIS + $self->{'.path_info'} =~ s/^\Q$ENV{'SCRIPT_NAME'}\E// if $IIS; + + } + return $self->{'.path_info'}; +} +END_OF_FUNC + + +#### Method: request_method +# Returns 'POST', 'GET', 'PUT' or 'HEAD' +#### +'request_method' => <<'END_OF_FUNC', +sub request_method { + return $ENV{'REQUEST_METHOD'}; +} +END_OF_FUNC + +#### Method: content_type +# Returns the content_type string +#### +'content_type' => <<'END_OF_FUNC', +sub content_type { + return $ENV{'CONTENT_TYPE'}; +} +END_OF_FUNC + +#### Method: path_translated +# Return the physical path information provided +# by the URL (if any) +#### +'path_translated' => <<'END_OF_FUNC', +sub path_translated { + return $ENV{'PATH_TRANSLATED'}; +} +END_OF_FUNC + + +#### Method: query_string +# Synthesize a query string from our current +# parameters +#### +'query_string' => <<'END_OF_FUNC', +sub query_string { + my($self) = self_or_default(@_); + my($param,$value,@pairs); + foreach $param ($self->param) { + my($eparam) = escape($param); + foreach $value ($self->param($param)) { + $value = escape($value); + next unless defined $value; + push(@pairs,"$eparam=$value"); + } + } + foreach (keys %{$self->{'.fieldnames'}}) { + push(@pairs,".cgifields=".escape("$_")); + } + return join($USE_PARAM_SEMICOLONS ? ';' : '&',@pairs); +} +END_OF_FUNC + + +#### Method: accept +# Without parameters, returns an array of the +# MIME types the browser accepts. +# With a single parameter equal to a MIME +# type, will return undef if the browser won't +# accept it, 1 if the browser accepts it but +# doesn't give a preference, or a floating point +# value between 0.0 and 1.0 if the browser +# declares a quantitative score for it. +# This handles MIME type globs correctly. +#### +'Accept' => <<'END_OF_FUNC', +sub Accept { + my($self,$search) = self_or_CGI(@_); + my(%prefs,$type,$pref,$pat); + + my(@accept) = split(',',$self->http('accept')); + + foreach (@accept) { + ($pref) = /q=(\d\.\d+|\d+)/; + ($type) = m#(\S+/[^;]+)#; + next unless $type; + $prefs{$type}=$pref || 1; + } + + return keys %prefs unless $search; + + # if a search type is provided, we may need to + # perform a pattern matching operation. + # The MIME types use a glob mechanism, which + # is easily translated into a perl pattern match + + # First return the preference for directly supported + # types: + return $prefs{$search} if $prefs{$search}; + + # Didn't get it, so try pattern matching. + foreach (keys %prefs) { + next unless /\*/; # not a pattern match + ($pat = $_) =~ s/([^\w*])/\\$1/g; # escape meta characters + $pat =~ s/\*/.*/g; # turn it into a pattern + return $prefs{$_} if $search=~/$pat/; + } +} +END_OF_FUNC + + +#### Method: user_agent +# If called with no parameters, returns the user agent. +# If called with one parameter, does a pattern match (case +# insensitive) on the user agent. +#### +'user_agent' => <<'END_OF_FUNC', +sub user_agent { + my($self,$match)=self_or_CGI(@_); + return $self->http('user_agent') unless $match; + return $self->http('user_agent') =~ /$match/i; +} +END_OF_FUNC + + +#### Method: raw_cookie +# Returns the magic cookies for the session. +# The cookies are not parsed or altered in any way, i.e. +# cookies are returned exactly as given in the HTTP +# headers. If a cookie name is given, only that cookie's +# value is returned, otherwise the entire raw cookie +# is returned. +#### +'raw_cookie' => <<'END_OF_FUNC', +sub raw_cookie { + my($self,$key) = self_or_CGI(@_); + + require CGI::Cookie; + + if (defined($key)) { + $self->{'.raw_cookies'} = CGI::Cookie->raw_fetch + unless $self->{'.raw_cookies'}; + + return () unless $self->{'.raw_cookies'}; + return () unless $self->{'.raw_cookies'}->{$key}; + return $self->{'.raw_cookies'}->{$key}; + } + return $self->http('cookie') || $ENV{'COOKIE'} || ''; +} +END_OF_FUNC + +#### Method: virtual_host +# Return the name of the virtual_host, which +# is not always the same as the server +###### +'virtual_host' => <<'END_OF_FUNC', +sub virtual_host { + my $vh = http('x_forwarded_host') || http('host') || server_name(); + $vh =~ s/:\d+$//; # get rid of port number + return $vh; +} +END_OF_FUNC + +#### Method: remote_host +# Return the name of the remote host, or its IP +# address if unavailable. If this variable isn't +# defined, it returns "localhost" for debugging +# purposes. +#### +'remote_host' => <<'END_OF_FUNC', +sub remote_host { + return $ENV{'REMOTE_HOST'} || $ENV{'REMOTE_ADDR'} + || 'localhost'; +} +END_OF_FUNC + + +#### Method: remote_addr +# Return the IP addr of the remote host. +#### +'remote_addr' => <<'END_OF_FUNC', +sub remote_addr { + return $ENV{'REMOTE_ADDR'} || '127.0.0.1'; +} +END_OF_FUNC + + +#### Method: script_name +# Return the partial URL to this script for +# self-referencing scripts. Also see +# self_url(), which returns a URL with all state information +# preserved. +#### +'script_name' => <<'END_OF_FUNC', +sub script_name { + return $ENV{'SCRIPT_NAME'} if defined($ENV{'SCRIPT_NAME'}); + # These are for debugging + return "/$0" unless $0=~/^\//; + return $0; +} +END_OF_FUNC + + +#### Method: referer +# Return the HTTP_REFERER: useful for generating +# a GO BACK button. +#### +'referer' => <<'END_OF_FUNC', +sub referer { + my($self) = self_or_CGI(@_); + return $self->http('referer'); +} +END_OF_FUNC + + +#### Method: server_name +# Return the name of the server +#### +'server_name' => <<'END_OF_FUNC', +sub server_name { + return $ENV{'SERVER_NAME'} || 'localhost'; +} +END_OF_FUNC + +#### Method: server_software +# Return the name of the server software +#### +'server_software' => <<'END_OF_FUNC', +sub server_software { + return $ENV{'SERVER_SOFTWARE'} || 'cmdline'; +} +END_OF_FUNC + +#### Method: virtual_port +# Return the server port, taking virtual hosts into account +#### +'virtual_port' => <<'END_OF_FUNC', +sub virtual_port { + my($self) = self_or_default(@_); + my $vh = $self->http('x_forwarded_host') || $self->http('host'); + if ($vh) { + return ($vh =~ /:(\d+)$/)[0] || '80'; + } else { + return $self->server_port(); + } +} +END_OF_FUNC + +#### Method: server_port +# Return the tcp/ip port the server is running on +#### +'server_port' => <<'END_OF_FUNC', +sub server_port { + return $ENV{'SERVER_PORT'} || 80; # for debugging +} +END_OF_FUNC + +#### Method: server_protocol +# Return the protocol (usually HTTP/1.0) +#### +'server_protocol' => <<'END_OF_FUNC', +sub server_protocol { + return $ENV{'SERVER_PROTOCOL'} || 'HTTP/1.0'; # for debugging +} +END_OF_FUNC + +#### Method: http +# Return the value of an HTTP variable, or +# the list of variables if none provided +#### +'http' => <<'END_OF_FUNC', +sub http { + my ($self,$parameter) = self_or_CGI(@_); + return $ENV{$parameter} if $parameter=~/^HTTP/; + $parameter =~ tr/-/_/; + return $ENV{"HTTP_\U$parameter\E"} if $parameter; + my(@p); + foreach (keys %ENV) { + push(@p,$_) if /^HTTP/; + } + return @p; +} +END_OF_FUNC + +#### Method: https +# Return the value of HTTPS +#### +'https' => <<'END_OF_FUNC', +sub https { + local($^W)=0; + my ($self,$parameter) = self_or_CGI(@_); + return $ENV{HTTPS} unless $parameter; + return $ENV{$parameter} if $parameter=~/^HTTPS/; + $parameter =~ tr/-/_/; + return $ENV{"HTTPS_\U$parameter\E"} if $parameter; + my(@p); + foreach (keys %ENV) { + push(@p,$_) if /^HTTPS/; + } + return @p; +} +END_OF_FUNC + +#### Method: protocol +# Return the protocol (http or https currently) +#### +'protocol' => <<'END_OF_FUNC', +sub protocol { + local($^W)=0; + my $self = shift; + return 'https' if uc($self->https()) eq 'ON'; + return 'https' if $self->server_port == 443; + my $prot = $self->server_protocol; + my($protocol,$version) = split('/',$prot); + return "\L$protocol\E"; +} +END_OF_FUNC + +#### Method: remote_ident +# Return the identity of the remote user +# (but only if his host is running identd) +#### +'remote_ident' => <<'END_OF_FUNC', +sub remote_ident { + return $ENV{'REMOTE_IDENT'}; +} +END_OF_FUNC + + +#### Method: auth_type +# Return the type of use verification/authorization in use, if any. +#### +'auth_type' => <<'END_OF_FUNC', +sub auth_type { + return $ENV{'AUTH_TYPE'}; +} +END_OF_FUNC + + +#### Method: remote_user +# Return the authorization name used for user +# verification. +#### +'remote_user' => <<'END_OF_FUNC', +sub remote_user { + return $ENV{'REMOTE_USER'}; +} +END_OF_FUNC + + +#### Method: user_name +# Try to return the remote user's name by hook or by +# crook +#### +'user_name' => <<'END_OF_FUNC', +sub user_name { + my ($self) = self_or_CGI(@_); + return $self->http('from') || $ENV{'REMOTE_IDENT'} || $ENV{'REMOTE_USER'}; +} +END_OF_FUNC + +#### Method: nosticky +# Set or return the NOSTICKY global flag +#### +'nosticky' => <<'END_OF_FUNC', +sub nosticky { + my ($self,$param) = self_or_CGI(@_); + $CGI::NOSTICKY = $param if defined($param); + return $CGI::NOSTICKY; +} +END_OF_FUNC + +#### Method: nph +# Set or return the NPH global flag +#### +'nph' => <<'END_OF_FUNC', +sub nph { + my ($self,$param) = self_or_CGI(@_); + $CGI::NPH = $param if defined($param); + return $CGI::NPH; +} +END_OF_FUNC + +#### Method: private_tempfiles +# Set or return the private_tempfiles global flag +#### +'private_tempfiles' => <<'END_OF_FUNC', +sub private_tempfiles { + my ($self,$param) = self_or_CGI(@_); + $CGI::PRIVATE_TEMPFILES = $param if defined($param); + return $CGI::PRIVATE_TEMPFILES; +} +END_OF_FUNC +#### Method: close_upload_files +# Set or return the close_upload_files global flag +#### +'close_upload_files' => <<'END_OF_FUNC', +sub close_upload_files { + my ($self,$param) = self_or_CGI(@_); + $CGI::CLOSE_UPLOAD_FILES = $param if defined($param); + return $CGI::CLOSE_UPLOAD_FILES; +} +END_OF_FUNC + + +#### Method: default_dtd +# Set or return the default_dtd global +#### +'default_dtd' => <<'END_OF_FUNC', +sub default_dtd { + my ($self,$param,$param2) = self_or_CGI(@_); + if (defined $param2 && defined $param) { + $CGI::DEFAULT_DTD = [ $param, $param2 ]; + } elsif (defined $param) { + $CGI::DEFAULT_DTD = $param; + } + return $CGI::DEFAULT_DTD; +} +END_OF_FUNC + +# -------------- really private subroutines ----------------- +'previous_or_default' => <<'END_OF_FUNC', +sub previous_or_default { + my($self,$name,$defaults,$override) = @_; + my(%selected); + + if (!$override && ($self->{'.fieldnames'}->{$name} || + defined($self->param($name)) ) ) { + grep($selected{$_}++,$self->param($name)); + } elsif (defined($defaults) && ref($defaults) && + (ref($defaults) eq 'ARRAY')) { + grep($selected{$_}++,@{$defaults}); + } else { + $selected{$defaults}++ if defined($defaults); + } + + return %selected; +} +END_OF_FUNC + +'register_parameter' => <<'END_OF_FUNC', +sub register_parameter { + my($self,$param) = @_; + $self->{'.parametersToAdd'}->{$param}++; +} +END_OF_FUNC + +'get_fields' => <<'END_OF_FUNC', +sub get_fields { + my($self) = @_; + return $self->CGI::hidden('-name'=>'.cgifields', + '-values'=>[keys %{$self->{'.parametersToAdd'}}], + '-override'=>1); +} +END_OF_FUNC + +'read_from_cmdline' => <<'END_OF_FUNC', +sub read_from_cmdline { + my($input,@words); + my($query_string); + my($subpath); + if ($DEBUG && @ARGV) { + @words = @ARGV; + } elsif ($DEBUG > 1) { + require "shellwords.pl"; + print STDERR "(offline mode: enter name=value pairs on standard input; press ^D or ^Z when done)\n"; + chomp(@lines = ); # remove newlines + $input = join(" ",@lines); + @words = &shellwords($input); + } + foreach (@words) { + s/\\=/%3D/g; + s/\\&/%26/g; + } + + if ("@words"=~/=/) { + $query_string = join('&',@words); + } else { + $query_string = join('+',@words); + } + if ($query_string =~ /^(.*?)\?(.*)$/) + { + $query_string = $2; + $subpath = $1; + } + return { 'query_string' => $query_string, 'subpath' => $subpath }; +} +END_OF_FUNC + +##### +# subroutine: read_multipart +# +# Read multipart data and store it into our parameters. +# An interesting feature is that if any of the parts is a file, we +# create a temporary file and open up a filehandle on it so that the +# caller can read from it if necessary. +##### +'read_multipart' => <<'END_OF_FUNC', +sub read_multipart { + my($self,$boundary,$length) = @_; + my($buffer) = $self->new_MultipartBuffer($boundary,$length); + return unless $buffer; + my(%header,$body); + my $filenumber = 0; + while (!$buffer->eof) { + %header = $buffer->readHeader; + + unless (%header) { + $self->cgi_error("400 Bad request (malformed multipart POST)"); + return; + } + + my($param)= $header{'Content-Disposition'}=~/ name="([^;]*)"/; + $param .= $TAINTED; + + # Bug: Netscape doesn't escape quotation marks in file names!!! + my($filename) = $header{'Content-Disposition'}=~/ filename="([^;]*)"/; + # Test for Opera's multiple upload feature + my($multipart) = ( defined( $header{'Content-Type'} ) && + $header{'Content-Type'} =~ /multipart\/mixed/ ) ? + 1 : 0; + + # add this parameter to our list + $self->add_parameter($param); + + # If no filename specified, then just read the data and assign it + # to our parameter list. + if ( ( !defined($filename) || $filename eq '' ) && !$multipart ) { + my($value) = $buffer->readBody; + $value .= $TAINTED; + push(@{$self->{$param}},$value); + next; + } + + my ($tmpfile,$tmp,$filehandle); + UPLOADS: { + # If we get here, then we are dealing with a potentially large + # uploaded form. Save the data to a temporary file, then open + # the file for reading. + + # skip the file if uploads disabled + if ($DISABLE_UPLOADS) { + while (defined($data = $buffer->read)) { } + last UPLOADS; + } + + # set the filename to some recognizable value + if ( ( !defined($filename) || $filename eq '' ) && $multipart ) { + $filename = "multipart/mixed"; + } + + # choose a relatively unpredictable tmpfile sequence number + my $seqno = unpack("%16C*",join('',localtime,values %ENV)); + for (my $cnt=10;$cnt>0;$cnt--) { + next unless $tmpfile = new CGITempFile($seqno); + $tmp = $tmpfile->as_string; + last if defined($filehandle = Fh->new($filename,$tmp,$PRIVATE_TEMPFILES)); + $seqno += int rand(100); + } + die "CGI open of tmpfile: $!\n" unless defined $filehandle; + $CGI::DefaultClass->binmode($filehandle) if $CGI::needs_binmode + && defined fileno($filehandle); + + # if this is an multipart/mixed attachment, save the header + # together with the body for later parsing with an external + # MIME parser module + if ( $multipart ) { + foreach ( keys %header ) { + print $filehandle "$_: $header{$_}${CRLF}"; + } + print $filehandle "${CRLF}"; + } + + my ($data); + local($\) = ''; + my $totalbytes; + while (defined($data = $buffer->read)) { + if (defined $self->{'.upload_hook'}) + { + $totalbytes += length($data); + &{$self->{'.upload_hook'}}($filename ,$data, $totalbytes, $self->{'.upload_data'}); + } + print $filehandle $data; + } + + # back up to beginning of file + seek($filehandle,0,0); + + ## Close the filehandle if requested this allows a multipart MIME + ## upload to contain many files, and we won't die due to too many + ## open file handles. The user can access the files using the hash + ## below. + close $filehandle if $CLOSE_UPLOAD_FILES; + $CGI::DefaultClass->binmode($filehandle) if $CGI::needs_binmode; + + # Save some information about the uploaded file where we can get + # at it later. + $self->{'.tmpfiles'}->{fileno($filehandle)}= { + hndl => $filehandle, + name => $tmpfile, + info => {%header}, + }; + push(@{$self->{$param}},$filehandle); + } + } +} +END_OF_FUNC + +'upload' =><<'END_OF_FUNC', +sub upload { + my($self,$param_name) = self_or_default(@_); + my @param = grep(ref && fileno($_), $self->param($param_name)); + return unless @param; + return wantarray ? @param : $param[0]; +} +END_OF_FUNC + +'tmpFileName' => <<'END_OF_FUNC', +sub tmpFileName { + my($self,$filename) = self_or_default(@_); + return $self->{'.tmpfiles'}->{fileno($filename)}->{name} ? + $self->{'.tmpfiles'}->{fileno($filename)}->{name}->as_string + : ''; +} +END_OF_FUNC + +'uploadInfo' => <<'END_OF_FUNC', +sub uploadInfo { + my($self,$filename) = self_or_default(@_); + return $self->{'.tmpfiles'}->{fileno($filename)}->{info}; +} +END_OF_FUNC + +# internal routine, don't use +'_set_values_and_labels' => <<'END_OF_FUNC', +sub _set_values_and_labels { + my $self = shift; + my ($v,$l,$n) = @_; + $$l = $v if ref($v) eq 'HASH' && !ref($$l); + return $self->param($n) if !defined($v); + return $v if !ref($v); + return ref($v) eq 'HASH' ? keys %$v : @$v; +} +END_OF_FUNC + +# internal routine, don't use +'_set_attributes' => <<'END_OF_FUNC', +sub _set_attributes { + my $self = shift; + my($element, $attributes) = @_; + return '' unless defined($attributes->{$element}); + $attribs = ' '; + foreach my $attrib (keys %{$attributes->{$element}}) { + (my $clean_attrib = $attrib) =~ s/^-//; + $attribs .= "@{[lc($clean_attrib)]}=\"$attributes->{$element}{$attrib}\" "; + } + $attribs =~ s/ $//; + return $attribs; +} +END_OF_FUNC + +'_compile_all' => <<'END_OF_FUNC', +sub _compile_all { + foreach (@_) { + next if defined(&$_); + $AUTOLOAD = "CGI::$_"; + _compile(); + } +} +END_OF_FUNC + +); +END_OF_AUTOLOAD +; + +######################################################### +# Globals and stubs for other packages that we use. +######################################################### + +################### Fh -- lightweight filehandle ############### +package Fh; +use overload + '""' => \&asString, + 'cmp' => \&compare, + 'fallback'=>1; + +$FH='fh00000'; + +*Fh::AUTOLOAD = \&CGI::AUTOLOAD; + +$AUTOLOADED_ROUTINES = ''; # prevent -w error +$AUTOLOADED_ROUTINES=<<'END_OF_AUTOLOAD'; +%SUBS = ( +'asString' => <<'END_OF_FUNC', +sub asString { + my $self = shift; + # get rid of package name + (my $i = $$self) =~ s/^\*(\w+::fh\d{5})+//; + $i =~ s/%(..)/ chr(hex($1)) /eg; + return $i.$CGI::TAINTED; +# BEGIN DEAD CODE +# This was an extremely clever patch that allowed "use strict refs". +# Unfortunately it relied on another bug that caused leaky file descriptors. +# The underlying bug has been fixed, so this no longer works. However +# "strict refs" still works for some reason. +# my $self = shift; +# return ${*{$self}{SCALAR}}; +# END DEAD CODE +} +END_OF_FUNC + +'compare' => <<'END_OF_FUNC', +sub compare { + my $self = shift; + my $value = shift; + return "$self" cmp $value; +} +END_OF_FUNC + +'new' => <<'END_OF_FUNC', +sub new { + my($pack,$name,$file,$delete) = @_; + _setup_symbols(@SAVED_SYMBOLS) if @SAVED_SYMBOLS; + require Fcntl unless defined &Fcntl::O_RDWR; + (my $safename = $name) =~ s/([':%])/ sprintf '%%%02X', ord $1 /eg; + my $fv = ++$FH . $safename; + my $ref = \*{"Fh::$fv"}; + $file =~ m!^([a-zA-Z0-9_ \'\":/.\$\\-]+)$! || return; + my $safe = $1; + sysopen($ref,$safe,Fcntl::O_RDWR()|Fcntl::O_CREAT()|Fcntl::O_EXCL(),0600) || return; + unlink($safe) if $delete; + CORE::delete $Fh::{$fv}; + return bless $ref,$pack; +} +END_OF_FUNC + +'DESTROY' => <<'END_OF_FUNC', +sub DESTROY { + my $self = shift; + close $self; +} +END_OF_FUNC + +); +END_OF_AUTOLOAD + +######################## MultipartBuffer #################### +package MultipartBuffer; + +use constant DEBUG => 0; + +# how many bytes to read at a time. We use +# a 4K buffer by default. +$INITIAL_FILLUNIT = 1024 * 4; +$TIMEOUT = 240*60; # 4 hour timeout for big files +$SPIN_LOOP_MAX = 2000; # bug fix for some Netscape servers +$CRLF=$CGI::CRLF; + +#reuse the autoload function +*MultipartBuffer::AUTOLOAD = \&CGI::AUTOLOAD; + +# avoid autoloader warnings +sub DESTROY {} + +############################################################################### +################# THESE FUNCTIONS ARE AUTOLOADED ON DEMAND #################### +############################################################################### +$AUTOLOADED_ROUTINES = ''; # prevent -w error +$AUTOLOADED_ROUTINES=<<'END_OF_AUTOLOAD'; +%SUBS = ( + +'new' => <<'END_OF_FUNC', +sub new { + my($package,$interface,$boundary,$length) = @_; + $FILLUNIT = $INITIAL_FILLUNIT; + $CGI::DefaultClass->binmode($IN); # if $CGI::needs_binmode; # just do it always + + # If the user types garbage into the file upload field, + # then Netscape passes NOTHING to the server (not good). + # We may hang on this read in that case. So we implement + # a read timeout. If nothing is ready to read + # by then, we return. + + # Netscape seems to be a little bit unreliable + # about providing boundary strings. + my $boundary_read = 0; + if ($boundary) { + + # Under the MIME spec, the boundary consists of the + # characters "--" PLUS the Boundary string + + # BUG: IE 3.01 on the Macintosh uses just the boundary -- not + # the two extra hyphens. We do a special case here on the user-agent!!!! + $boundary = "--$boundary" unless CGI::user_agent('MSIE\s+3\.0[12];\s*Mac|DreamPassport'); + + } else { # otherwise we find it ourselves + my($old); + ($old,$/) = ($/,$CRLF); # read a CRLF-delimited line + $boundary = ; # BUG: This won't work correctly under mod_perl + $length -= length($boundary); + chomp($boundary); # remove the CRLF + $/ = $old; # restore old line separator + $boundary_read++; + } + + my $self = {LENGTH=>$length, + BOUNDARY=>$boundary, + INTERFACE=>$interface, + BUFFER=>'', + }; + + $FILLUNIT = length($boundary) + if length($boundary) > $FILLUNIT; + + my $retval = bless $self,ref $package || $package; + + # Read the preamble and the topmost (boundary) line plus the CRLF. + unless ($boundary_read) { + while ($self->read(0)) { } + } + die "Malformed multipart POST: data truncated\n" if $self->eof; + + return $retval; +} +END_OF_FUNC + +'readHeader' => <<'END_OF_FUNC', +sub readHeader { + my($self) = @_; + my($end); + my($ok) = 0; + my($bad) = 0; + + local($CRLF) = "\015\012" if $CGI::OS eq 'VMS' || $CGI::EBCDIC; + + do { + $self->fillBuffer($FILLUNIT); + $ok++ if ($end = index($self->{BUFFER},"${CRLF}${CRLF}")) >= 0; + $ok++ if $self->{BUFFER} eq ''; + $bad++ if !$ok && $self->{LENGTH} <= 0; + # this was a bad idea + # $FILLUNIT *= 2 if length($self->{BUFFER}) >= $FILLUNIT; + } until $ok || $bad; + return () if $bad; + + #EBCDIC NOTE: translate header into EBCDIC, but watch out for continuation lines! + + my($header) = substr($self->{BUFFER},0,$end+2); + substr($self->{BUFFER},0,$end+4) = ''; + my %return; + + if ($CGI::EBCDIC) { + warn "untranslated header=$header\n" if DEBUG; + $header = CGI::Util::ascii2ebcdic($header); + warn "translated header=$header\n" if DEBUG; + } + + # See RFC 2045 Appendix A and RFC 822 sections 3.4.8 + # (Folding Long Header Fields), 3.4.3 (Comments) + # and 3.4.5 (Quoted-Strings). + + my $token = '[-\w!\#$%&\'*+.^_\`|{}~]'; + $header=~s/$CRLF\s+/ /og; # merge continuation lines + + while ($header=~/($token+):\s+([^$CRLF]*)/mgox) { + my ($field_name,$field_value) = ($1,$2); + $field_name =~ s/\b(\w)/uc($1)/eg; #canonicalize + $return{$field_name}=$field_value; + } + return %return; +} +END_OF_FUNC + +# This reads and returns the body as a single scalar value. +'readBody' => <<'END_OF_FUNC', +sub readBody { + my($self) = @_; + my($data); + my($returnval)=''; + + #EBCDIC NOTE: want to translate returnval into EBCDIC HERE + + while (defined($data = $self->read)) { + $returnval .= $data; + } + + if ($CGI::EBCDIC) { + warn "untranslated body=$returnval\n" if DEBUG; + $returnval = CGI::Util::ascii2ebcdic($returnval); + warn "translated body=$returnval\n" if DEBUG; + } + return $returnval; +} +END_OF_FUNC + +# This will read $bytes or until the boundary is hit, whichever happens +# first. After the boundary is hit, we return undef. The next read will +# skip over the boundary and begin reading again; +'read' => <<'END_OF_FUNC', +sub read { + my($self,$bytes) = @_; + + # default number of bytes to read + $bytes = $bytes || $FILLUNIT; + + # Fill up our internal buffer in such a way that the boundary + # is never split between reads. + $self->fillBuffer($bytes); + + my $boundary_start = $CGI::EBCDIC ? CGI::Util::ebcdic2ascii($self->{BOUNDARY}) : $self->{BOUNDARY}; + my $boundary_end = $CGI::EBCDIC ? CGI::Util::ebcdic2ascii($self->{BOUNDARY}.'--') : $self->{BOUNDARY}.'--'; + + # Find the boundary in the buffer (it may not be there). + my $start = index($self->{BUFFER},$boundary_start); + + warn "boundary=$self->{BOUNDARY} length=$self->{LENGTH} start=$start\n" if DEBUG; + # protect against malformed multipart POST operations + die "Malformed multipart POST\n" unless ($start >= 0) || ($self->{LENGTH} > 0); + + + #EBCDIC NOTE: want to translate boundary search into ASCII here. + + # If the boundary begins the data, then skip past it + # and return undef. + if ($start == 0) { + + # clear us out completely if we've hit the last boundary. + if (index($self->{BUFFER},$boundary_end)==0) { + $self->{BUFFER}=''; + $self->{LENGTH}=0; + return undef; + } + + # just remove the boundary. + substr($self->{BUFFER},0,length($boundary_start))=''; + $self->{BUFFER} =~ s/^\012\015?//; + return undef; + } + + my $bytesToReturn; + if ($start > 0) { # read up to the boundary + $bytesToReturn = $start-2 > $bytes ? $bytes : $start; + } else { # read the requested number of bytes + # leave enough bytes in the buffer to allow us to read + # the boundary. Thanks to Kevin Hendrick for finding + # this one. + $bytesToReturn = $bytes - (length($boundary_start)+1); + } + + my $returnval=substr($self->{BUFFER},0,$bytesToReturn); + substr($self->{BUFFER},0,$bytesToReturn)=''; + + # If we hit the boundary, remove the CRLF from the end. + return ($bytesToReturn==$start) + ? substr($returnval,0,-2) : $returnval; +} +END_OF_FUNC + + +# This fills up our internal buffer in such a way that the +# boundary is never split between reads +'fillBuffer' => <<'END_OF_FUNC', +sub fillBuffer { + my($self,$bytes) = @_; + return unless $self->{LENGTH}; + + my($boundaryLength) = length($self->{BOUNDARY}); + my($bufferLength) = length($self->{BUFFER}); + my($bytesToRead) = $bytes - $bufferLength + $boundaryLength + 2; + $bytesToRead = $self->{LENGTH} if $self->{LENGTH} < $bytesToRead; + + # Try to read some data. We may hang here if the browser is screwed up. + my $bytesRead = $self->{INTERFACE}->read_from_client(\$self->{BUFFER}, + $bytesToRead, + $bufferLength); + warn "bytesToRead=$bytesToRead, bufferLength=$bufferLength, buffer=$self->{BUFFER}\n" if DEBUG; + $self->{BUFFER} = '' unless defined $self->{BUFFER}; + + # An apparent bug in the Apache server causes the read() + # to return zero bytes repeatedly without blocking if the + # remote user aborts during a file transfer. I don't know how + # they manage this, but the workaround is to abort if we get + # more than SPIN_LOOP_MAX consecutive zero reads. + if ($bytesRead == 0) { + die "CGI.pm: Server closed socket during multipart read (client aborted?).\n" + if ($self->{ZERO_LOOP_COUNTER}++ >= $SPIN_LOOP_MAX); + } else { + $self->{ZERO_LOOP_COUNTER}=0; + } + + $self->{LENGTH} -= $bytesRead; +} +END_OF_FUNC + + +# Return true when we've finished reading +'eof' => <<'END_OF_FUNC' +sub eof { + my($self) = @_; + return 1 if (length($self->{BUFFER}) == 0) + && ($self->{LENGTH} <= 0); + undef; +} +END_OF_FUNC + +); +END_OF_AUTOLOAD + +#################################################################################### +################################## TEMPORARY FILES ################################# +#################################################################################### +package CGITempFile; + +sub find_tempdir { + undef $TMPDIRECTORY; + $SL = $CGI::SL; + $MAC = $CGI::OS eq 'MACINTOSH'; + my ($vol) = $MAC ? MacPerl::Volumes() =~ /:(.*)/ : ""; + unless ($TMPDIRECTORY) { + @TEMP=("${SL}usr${SL}tmp","${SL}var${SL}tmp", + "C:${SL}temp","${SL}tmp","${SL}temp", + "${vol}${SL}Temporary Items", + "${SL}WWW_ROOT", "${SL}SYS\$SCRATCH", + "C:${SL}system${SL}temp"); + unshift(@TEMP,$ENV{'TMPDIR'}) if defined $ENV{'TMPDIR'}; + + # this feature was supposed to provide per-user tmpfiles, but + # it is problematic. + # unshift(@TEMP,(getpwuid($<))[7].'/tmp') if $CGI::OS eq 'UNIX'; + # Rob: getpwuid() is unfortunately UNIX specific. On brain dead OS'es this + # : can generate a 'getpwuid() not implemented' exception, even though + # : it's never called. Found under DOS/Win with the DJGPP perl port. + # : Refer to getpwuid() only at run-time if we're fortunate and have UNIX. + # unshift(@TEMP,(eval {(getpwuid($>))[7]}).'/tmp') if $CGI::OS eq 'UNIX' and $> != 0; + + foreach (@TEMP) { + do {$TMPDIRECTORY = $_; last} if -d $_ && -w _; + } + } + $TMPDIRECTORY = $MAC ? "" : "." unless $TMPDIRECTORY; +} + +find_tempdir(); + +$MAXTRIES = 5000; + +# cute feature, but overload implementation broke it +# %OVERLOAD = ('""'=>'as_string'); +*CGITempFile::AUTOLOAD = \&CGI::AUTOLOAD; + +sub DESTROY { + my($self) = @_; + $$self =~ m!^([a-zA-Z0-9_ \'\":/.\$\\-]+)$! || return; + my $safe = $1; # untaint operation + unlink $safe; # get rid of the file +} + +############################################################################### +################# THESE FUNCTIONS ARE AUTOLOADED ON DEMAND #################### +############################################################################### +$AUTOLOADED_ROUTINES = ''; # prevent -w error +$AUTOLOADED_ROUTINES=<<'END_OF_AUTOLOAD'; +%SUBS = ( + +'new' => <<'END_OF_FUNC', +sub new { + my($package,$sequence) = @_; + my $filename; + find_tempdir() unless -w $TMPDIRECTORY; + for (my $i = 0; $i < $MAXTRIES; $i++) { + last if ! -f ($filename = sprintf("${TMPDIRECTORY}${SL}CGItemp%d",$sequence++)); + } + # check that it is a more-or-less valid filename + return unless $filename =~ m!^([a-zA-Z0-9_ \'\":/.\$\\-]+)$!; + # this used to untaint, now it doesn't + # $filename = $1; + return bless \$filename; +} +END_OF_FUNC + +'as_string' => <<'END_OF_FUNC' +sub as_string { + my($self) = @_; + return $$self; +} +END_OF_FUNC + +); +END_OF_AUTOLOAD + +package CGI; + +# We get a whole bunch of warnings about "possibly uninitialized variables" +# when running with the -w switch. Touch them all once to get rid of the +# warnings. This is ugly and I hate it. +if ($^W) { + $CGI::CGI = ''; + $CGI::CGI=<'words', + -values=>['eenie','meenie','minie','moe'], + -defaults=>['eenie','minie']), p, + "What's your favorite color? ", + popup_menu(-name=>'color', + -values=>['red','green','blue','chartreuse']),p, + submit, + end_form, + hr; + + if (param()) { + print "Your name is",em(param('name')),p, + "The keywords are: ",em(join(", ",param('words'))),p, + "Your favorite color is ",em(param('color')), + hr; + } + +=head1 ABSTRACT + +This perl library uses perl5 objects to make it easy to create Web +fill-out forms and parse their contents. This package defines CGI +objects, entities that contain the values of the current query string +and other state variables. Using a CGI object's methods, you can +examine keywords and parameters passed to your script, and create +forms whose initial values are taken from the current query (thereby +preserving state information). The module provides shortcut functions +that produce boilerplate HTML, reducing typing and coding errors. It +also provides functionality for some of the more advanced features of +CGI scripting, including support for file uploads, cookies, cascading +style sheets, server push, and frames. + +CGI.pm also provides a simple function-oriented programming style for +those who don't need its object-oriented features. + +The current version of CGI.pm is available at + + http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html + ftp://ftp-genome.wi.mit.edu/pub/software/WWW/ + +=head1 DESCRIPTION + +=head2 PROGRAMMING STYLE + +There are two styles of programming with CGI.pm, an object-oriented +style and a function-oriented style. In the object-oriented style you +create one or more CGI objects and then use object methods to create +the various elements of the page. Each CGI object starts out with the +list of named parameters that were passed to your CGI script by the +server. You can modify the objects, save them to a file or database +and recreate them. Because each object corresponds to the "state" of +the CGI script, and because each object's parameter list is +independent of the others, this allows you to save the state of the +script and restore it later. + +For example, using the object oriented style, here is how you create +a simple "Hello World" HTML page: + + #!/usr/local/bin/perl -w + use CGI; # load CGI routines + $q = new CGI; # create new CGI object + print $q->header, # create the HTTP header + $q->start_html('hello world'), # start the HTML + $q->h1('hello world'), # level 1 header + $q->end_html; # end the HTML + +In the function-oriented style, there is one default CGI object that +you rarely deal with directly. Instead you just call functions to +retrieve CGI parameters, create HTML tags, manage cookies, and so +on. This provides you with a cleaner programming interface, but +limits you to using one CGI object at a time. The following example +prints the same page, but uses the function-oriented interface. +The main differences are that we now need to import a set of functions +into our name space (usually the "standard" functions), and we don't +need to create the CGI object. + + #!/usr/local/bin/perl + use CGI qw/:standard/; # load standard CGI routines + print header, # create the HTTP header + start_html('hello world'), # start the HTML + h1('hello world'), # level 1 header + end_html; # end the HTML + +The examples in this document mainly use the object-oriented style. +See HOW TO IMPORT FUNCTIONS for important information on +function-oriented programming in CGI.pm + +=head2 CALLING CGI.PM ROUTINES + +Most CGI.pm routines accept several arguments, sometimes as many as 20 +optional ones! To simplify this interface, all routines use a named +argument calling style that looks like this: + + print $q->header(-type=>'image/gif',-expires=>'+3d'); + +Each argument name is preceded by a dash. Neither case nor order +matters in the argument list. -type, -Type, and -TYPE are all +acceptable. In fact, only the first argument needs to begin with a +dash. If a dash is present in the first argument, CGI.pm assumes +dashes for the subsequent ones. + +Several routines are commonly called with just one argument. In the +case of these routines you can provide the single argument without an +argument name. header() happens to be one of these routines. In this +case, the single argument is the document type. + + print $q->header('text/html'); + +Other such routines are documented below. + +Sometimes named arguments expect a scalar, sometimes a reference to an +array, and sometimes a reference to a hash. Often, you can pass any +type of argument and the routine will do whatever is most appropriate. +For example, the param() routine is used to set a CGI parameter to a +single or a multi-valued value. The two cases are shown below: + + $q->param(-name=>'veggie',-value=>'tomato'); + $q->param(-name=>'veggie',-value=>['tomato','tomahto','potato','potahto']); + +A large number of routines in CGI.pm actually aren't specifically +defined in the module, but are generated automatically as needed. +These are the "HTML shortcuts," routines that generate HTML tags for +use in dynamically-generated pages. HTML tags have both attributes +(the attribute="value" pairs within the tag itself) and contents (the +part between the opening and closing pairs.) To distinguish between +attributes and contents, CGI.pm uses the convention of passing HTML +attributes as a hash reference as the first argument, and the +contents, if any, as any subsequent arguments. It works out like +this: + + Code Generated HTML + ---- -------------- + h1()

    + h1('some','contents');

    some contents

    + h1({-align=>left});

    + h1({-align=>left},'contents');

    contents

    + +HTML tags are described in more detail later. + +Many newcomers to CGI.pm are puzzled by the difference between the +calling conventions for the HTML shortcuts, which require curly braces +around the HTML tag attributes, and the calling conventions for other +routines, which manage to generate attributes without the curly +brackets. Don't be confused. As a convenience the curly braces are +optional in all but the HTML shortcuts. If you like, you can use +curly braces when calling any routine that takes named arguments. For +example: + + print $q->header( {-type=>'image/gif',-expires=>'+3d'} ); + +If you use the B<-w> switch, you will be warned that some CGI.pm argument +names conflict with built-in Perl functions. The most frequent of +these is the -values argument, used to create multi-valued menus, +radio button clusters and the like. To get around this warning, you +have several choices: + +=over 4 + +=item 1. + +Use another name for the argument, if one is available. +For example, -value is an alias for -values. + +=item 2. + +Change the capitalization, e.g. -Values + +=item 3. + +Put quotes around the argument name, e.g. '-values' + +=back + +Many routines will do something useful with a named argument that it +doesn't recognize. For example, you can produce non-standard HTTP +header fields by providing them as named arguments: + + print $q->header(-type => 'text/html', + -cost => 'Three smackers', + -annoyance_level => 'high', + -complaints_to => 'bit bucket'); + +This will produce the following nonstandard HTTP header: + + HTTP/1.0 200 OK + Cost: Three smackers + Annoyance-level: high + Complaints-to: bit bucket + Content-type: text/html + +Notice the way that underscores are translated automatically into +hyphens. HTML-generating routines perform a different type of +translation. + +This feature allows you to keep up with the rapidly changing HTTP and +HTML "standards". + +=head2 CREATING A NEW QUERY OBJECT (OBJECT-ORIENTED STYLE): + + $query = new CGI; + +This will parse the input (from both POST and GET methods) and store +it into a perl5 object called $query. + +=head2 CREATING A NEW QUERY OBJECT FROM AN INPUT FILE + + $query = new CGI(INPUTFILE); + +If you provide a file handle to the new() method, it will read +parameters from the file (or STDIN, or whatever). The file can be in +any of the forms describing below under debugging (i.e. a series of +newline delimited TAG=VALUE pairs will work). Conveniently, this type +of file is created by the save() method (see below). Multiple records +can be saved and restored. + +Perl purists will be pleased to know that this syntax accepts +references to file handles, or even references to filehandle globs, +which is the "official" way to pass a filehandle: + + $query = new CGI(\*STDIN); + +You can also initialize the CGI object with a FileHandle or IO::File +object. + +If you are using the function-oriented interface and want to +initialize CGI state from a file handle, the way to do this is with +B. This will (re)initialize the +default CGI object from the indicated file handle. + + open (IN,"test.in") || die; + restore_parameters(IN); + close IN; + +You can also initialize the query object from an associative array +reference: + + $query = new CGI( {'dinosaur'=>'barney', + 'song'=>'I love you', + 'friends'=>[qw/Jessica George Nancy/]} + ); + +or from a properly formatted, URL-escaped query string: + + $query = new CGI('dinosaur=barney&color=purple'); + +or from a previously existing CGI object (currently this clones the +parameter list, but none of the other object-specific fields, such as +autoescaping): + + $old_query = new CGI; + $new_query = new CGI($old_query); + +To create an empty query, initialize it from an empty string or hash: + + $empty_query = new CGI(""); + + -or- + + $empty_query = new CGI({}); + +=head2 FETCHING A LIST OF KEYWORDS FROM THE QUERY: + + @keywords = $query->keywords + +If the script was invoked as the result of an search, the +parsed keywords can be obtained as an array using the keywords() method. + +=head2 FETCHING THE NAMES OF ALL THE PARAMETERS PASSED TO YOUR SCRIPT: + + @names = $query->param + +If the script was invoked with a parameter list +(e.g. "name1=value1&name2=value2&name3=value3"), the param() method +will return the parameter names as a list. If the script was invoked +as an script and contains a string without ampersands +(e.g. "value1+value2+value3") , there will be a single parameter named +"keywords" containing the "+"-delimited keywords. + +NOTE: As of version 1.5, the array of parameter names returned will +be in the same order as they were submitted by the browser. +Usually this order is the same as the order in which the +parameters are defined in the form (however, this isn't part +of the spec, and so isn't guaranteed). + +=head2 FETCHING THE VALUE OR VALUES OF A SINGLE NAMED PARAMETER: + + @values = $query->param('foo'); + + -or- + + $value = $query->param('foo'); + +Pass the param() method a single argument to fetch the value of the +named parameter. If the parameter is multivalued (e.g. from multiple +selections in a scrolling list), you can ask to receive an array. Otherwise +the method will return a single value. + +If a value is not given in the query string, as in the queries +"name1=&name2=" or "name1&name2", it will be returned as an empty +string. This feature is new in 2.63. + + +If the parameter does not exist at all, then param() will return undef +in a scalar context, and the empty list in a list context. + + +=head2 SETTING THE VALUE(S) OF A NAMED PARAMETER: + + $query->param('foo','an','array','of','values'); + +This sets the value for the named parameter 'foo' to an array of +values. This is one way to change the value of a field AFTER +the script has been invoked once before. (Another way is with +the -override parameter accepted by all methods that generate +form elements.) + +param() also recognizes a named parameter style of calling described +in more detail later: + + $query->param(-name=>'foo',-values=>['an','array','of','values']); + + -or- + + $query->param(-name=>'foo',-value=>'the value'); + +=head2 APPENDING ADDITIONAL VALUES TO A NAMED PARAMETER: + + $query->append(-name=>'foo',-values=>['yet','more','values']); + +This adds a value or list of values to the named parameter. The +values are appended to the end of the parameter if it already exists. +Otherwise the parameter is created. Note that this method only +recognizes the named argument calling syntax. + +=head2 IMPORTING ALL PARAMETERS INTO A NAMESPACE: + + $query->import_names('R'); + +This creates a series of variables in the 'R' namespace. For example, +$R::foo, @R:foo. For keyword lists, a variable @R::keywords will appear. +If no namespace is given, this method will assume 'Q'. +WARNING: don't import anything into 'main'; this is a major security +risk!!!! + +NOTE 1: Variable names are transformed as necessary into legal Perl +variable names. All non-legal characters are transformed into +underscores. If you need to keep the original names, you should use +the param() method instead to access CGI variables by name. + +NOTE 2: In older versions, this method was called B. As of version 2.20, +this name has been removed completely to avoid conflict with the built-in +Perl module B operator. + +=head2 DELETING A PARAMETER COMPLETELY: + + $query->delete('foo','bar','baz'); + +This completely clears a list of parameters. It sometimes useful for +resetting parameters that you don't want passed down between script +invocations. + +If you are using the function call interface, use "Delete()" instead +to avoid conflicts with Perl's built-in delete operator. + +=head2 DELETING ALL PARAMETERS: + + $query->delete_all(); + +This clears the CGI object completely. It might be useful to ensure +that all the defaults are taken when you create a fill-out form. + +Use Delete_all() instead if you are using the function call interface. + +=head2 DIRECT ACCESS TO THE PARAMETER LIST: + + $q->param_fetch('address')->[1] = '1313 Mockingbird Lane'; + unshift @{$q->param_fetch(-name=>'address')},'George Munster'; + +If you need access to the parameter list in a way that isn't covered +by the methods above, you can obtain a direct reference to it by +calling the B method with the name of the . This +will return an array reference to the named parameters, which you then +can manipulate in any way you like. + +You can also use a named argument style using the B<-name> argument. + +=head2 FETCHING THE PARAMETER LIST AS A HASH: + + $params = $q->Vars; + print $params->{'address'}; + @foo = split("\0",$params->{'foo'}); + %params = $q->Vars; + + use CGI ':cgi-lib'; + $params = Vars; + +Many people want to fetch the entire parameter list as a hash in which +the keys are the names of the CGI parameters, and the values are the +parameters' values. The Vars() method does this. Called in a scalar +context, it returns the parameter list as a tied hash reference. +Changing a key changes the value of the parameter in the underlying +CGI parameter list. Called in a list context, it returns the +parameter list as an ordinary hash. This allows you to read the +contents of the parameter list, but not to change it. + +When using this, the thing you must watch out for are multivalued CGI +parameters. Because a hash cannot distinguish between scalar and +list context, multivalued parameters will be returned as a packed +string, separated by the "\0" (null) character. You must split this +packed string in order to get at the individual values. This is the +convention introduced long ago by Steve Brenner in his cgi-lib.pl +module for Perl version 4. + +If you wish to use Vars() as a function, import the I<:cgi-lib> set of +function calls (also see the section on CGI-LIB compatibility). + +=head2 SAVING THE STATE OF THE SCRIPT TO A FILE: + + $query->save(FILEHANDLE) + +This will write the current state of the form to the provided +filehandle. You can read it back in by providing a filehandle +to the new() method. Note that the filehandle can be a file, a pipe, +or whatever! + +The format of the saved file is: + + NAME1=VALUE1 + NAME1=VALUE1' + NAME2=VALUE2 + NAME3=VALUE3 + = + +Both name and value are URL escaped. Multi-valued CGI parameters are +represented as repeated names. A session record is delimited by a +single = symbol. You can write out multiple records and read them +back in with several calls to B. You can do this across several +sessions by opening the file in append mode, allowing you to create +primitive guest books, or to keep a history of users' queries. Here's +a short example of creating multiple session records: + + use CGI; + + open (OUT,">>test.out") || die; + $records = 5; + foreach (0..$records) { + my $q = new CGI; + $q->param(-name=>'counter',-value=>$_); + $q->save(OUT); + } + close OUT; + + # reopen for reading + open (IN,"test.out") || die; + while (!eof(IN)) { + my $q = new CGI(IN); + print $q->param('counter'),"\n"; + } + +The file format used for save/restore is identical to that used by the +Whitehead Genome Center's data exchange format "Boulderio", and can be +manipulated and even databased using Boulderio utilities. See + + http://stein.cshl.org/boulder/ + +for further details. + +If you wish to use this method from the function-oriented (non-OO) +interface, the exported name for this method is B. + +=head2 RETRIEVING CGI ERRORS + +Errors can occur while processing user input, particularly when +processing uploaded files. When these errors occur, CGI will stop +processing and return an empty parameter list. You can test for +the existence and nature of errors using the I function. +The error messages are formatted as HTTP status codes. You can either +incorporate the error text into an HTML page, or use it as the value +of the HTTP status: + + my $error = $q->cgi_error; + if ($error) { + print $q->header(-status=>$error), + $q->start_html('Problems'), + $q->h2('Request not processed'), + $q->strong($error); + exit 0; + } + +When using the function-oriented interface (see the next section), +errors may only occur the first time you call I. Be ready +for this! + +=head2 USING THE FUNCTION-ORIENTED INTERFACE + +To use the function-oriented interface, you must specify which CGI.pm +routines or sets of routines to import into your script's namespace. +There is a small overhead associated with this importation, but it +isn't much. + + use CGI ; + +The listed methods will be imported into the current package; you can +call them directly without creating a CGI object first. This example +shows how to import the B and B +methods, and then use them directly: + + use CGI 'param','header'; + print header('text/plain'); + $zipcode = param('zipcode'); + +More frequently, you'll import common sets of functions by referring +to the groups by name. All function sets are preceded with a ":" +character as in ":html3" (for tags defined in the HTML 3 standard). + +Here is a list of the function sets you can import: + +=over 4 + +=item B<:cgi> + +Import all CGI-handling methods, such as B, B +and the like. + +=item B<:form> + +Import all fill-out form generating methods, such as B. + +=item B<:html2> + +Import all methods that generate HTML 2.0 standard elements. + +=item B<:html3> + +Import all methods that generate HTML 3.0 elements (such as +, and ). + +=item B<:html4> + +Import all methods that generate HTML 4 elements (such as +, and ). + +=item B<:netscape> + +Import all methods that generate Netscape-specific HTML extensions. + +=item B<:html> + +Import all HTML-generating shortcuts (i.e. 'html2' + 'html3' + +'netscape')... + +=item B<:standard> + +Import "standard" features, 'html2', 'html3', 'html4', 'form' and 'cgi'. + +=item B<:all> + +Import all the available methods. For the full list, see the CGI.pm +code, where the variable %EXPORT_TAGS is defined. + +=back + +If you import a function name that is not part of CGI.pm, the module +will treat it as a new HTML tag and generate the appropriate +subroutine. You can then use it like any other HTML tag. This is to +provide for the rapidly-evolving HTML "standard." For example, say +Microsoft comes out with a new tag called (which causes the +user's desktop to be flooded with a rotating gradient fill until his +machine reboots). You don't need to wait for a new version of CGI.pm +to start using it immediately: + + use CGI qw/:standard :html3 gradient/; + print gradient({-start=>'red',-end=>'blue'}); + +Note that in the interests of execution speed CGI.pm does B use +the standard L syntax for specifying load symbols. This may +change in the future. + +If you import any of the state-maintaining CGI or form-generating +methods, a default CGI object will be created and initialized +automatically the first time you use any of the methods that require +one to be present. This includes B, B, +B and the like. (If you need direct access to the CGI +object, you can find it in the global variable B<$CGI::Q>). By +importing CGI.pm methods, you can create visually elegant scripts: + + use CGI qw/:standard/; + print + header, + start_html('Simple Script'), + h1('Simple Script'), + start_form, + "What's your name? ",textfield('name'),p, + "What's the combination?", + checkbox_group(-name=>'words', + -values=>['eenie','meenie','minie','moe'], + -defaults=>['eenie','moe']),p, + "What's your favorite color?", + popup_menu(-name=>'color', + -values=>['red','green','blue','chartreuse']),p, + submit, + end_form, + hr,"\n"; + + if (param) { + print + "Your name is ",em(param('name')),p, + "The keywords are: ",em(join(", ",param('words'))),p, + "Your favorite color is ",em(param('color')),".\n"; + } + print end_html; + +=head2 PRAGMAS + +In addition to the function sets, there are a number of pragmas that +you can import. Pragmas, which are always preceded by a hyphen, +change the way that CGI.pm functions in various ways. Pragmas, +function sets, and individual functions can all be imported in the +same use() line. For example, the following use statement imports the +standard set of functions and enables debugging mode (pragma +-debug): + + use CGI qw/:standard -debug/; + +The current list of pragmas is as follows: + +=over 4 + +=item -any + +When you I, then any method that the query object +doesn't recognize will be interpreted as a new HTML tag. This allows +you to support the next I Netscape or Microsoft HTML +extension. This lets you go wild with new and unsupported tags: + + use CGI qw(-any); + $q=new CGI; + print $q->gradient({speed=>'fast',start=>'red',end=>'blue'}); + +Since using any causes any mistyped method name +to be interpreted as an HTML tag, use it with care or not at +all. + +=item -compile + +This causes the indicated autoloaded methods to be compiled up front, +rather than deferred to later. This is useful for scripts that run +for an extended period of time under FastCGI or mod_perl, and for +those destined to be crunched by Malcom Beattie's Perl compiler. Use +it in conjunction with the methods or method families you plan to use. + + use CGI qw(-compile :standard :html3); + +or even + + use CGI qw(-compile :all); + +Note that using the -compile pragma in this way will always have +the effect of importing the compiled functions into the current +namespace. If you want to compile without importing use the +compile() method instead: + + use CGI(); + CGI->compile(); + +This is particularly useful in a mod_perl environment, in which you +might want to precompile all CGI routines in a startup script, and +then import the functions individually in each mod_perl script. + +=item -nosticky + +This makes CGI.pm not generating the hidden fields .submit +and .cgifields. It is very useful if you don't want to +have the hidden fields appear in the querystring in a GET method. +For example, a search script generated this way will have +a very nice url with search parameters for bookmarking. + +=item -no_undef_params + +This keeps CGI.pm from including undef params in the parameter list. + +=item -no_xhtml + +By default, CGI.pm versions 2.69 and higher emit XHTML +(http://www.w3.org/TR/xhtml1/). The -no_xhtml pragma disables this +feature. Thanks to Michalis Kabrianis for this +feature. + +If start_html()'s -dtd parameter specifies an HTML 2.0 or 3.2 DTD, +XHTML will automatically be disabled without needing to use this +pragma. + +=item -nph + +This makes CGI.pm produce a header appropriate for an NPH (no +parsed header) script. You may need to do other things as well +to tell the server that the script is NPH. See the discussion +of NPH scripts below. + +=item -newstyle_urls + +Separate the name=value pairs in CGI parameter query strings with +semicolons rather than ampersands. For example: + + ?name=fred;age=24;favorite_color=3 + +Semicolon-delimited query strings are always accepted, but will not be +emitted by self_url() and query_string() unless the -newstyle_urls +pragma is specified. + +This became the default in version 2.64. + +=item -oldstyle_urls + +Separate the name=value pairs in CGI parameter query strings with +ampersands rather than semicolons. This is no longer the default. + +=item -autoload + +This overrides the autoloader so that any function in your program +that is not recognized is referred to CGI.pm for possible evaluation. +This allows you to use all the CGI.pm functions without adding them to +your symbol table, which is of concern for mod_perl users who are +worried about memory consumption. I when +I<-autoload> is in effect, you cannot use "poetry mode" +(functions without the parenthesis). Use I rather +than I
    , or add something like I +to the top of your script. + +=item -no_debug + +This turns off the command-line processing features. If you want to +run a CGI.pm script from the command line to produce HTML, and you +don't want it to read CGI parameters from the command line or STDIN, +then use this pragma: + + use CGI qw(-no_debug :standard); + +=item -debug + +This turns on full debugging. In addition to reading CGI arguments +from the command-line processing, CGI.pm will pause and try to read +arguments from STDIN, producing the message "(offline mode: enter +name=value pairs on standard input)" features. + +See the section on debugging for more details. + +=item -private_tempfiles + +CGI.pm can process uploaded file. Ordinarily it spools the uploaded +file to a temporary directory, then deletes the file when done. +However, this opens the risk of eavesdropping as described in the file +upload section. Another CGI script author could peek at this data +during the upload, even if it is confidential information. On Unix +systems, the -private_tempfiles pragma will cause the temporary file +to be unlinked as soon as it is opened and before any data is written +into it, reducing, but not eliminating the risk of eavesdropping +(there is still a potential race condition). To make life harder for +the attacker, the program chooses tempfile names by calculating a 32 +bit checksum of the incoming HTTP headers. + +To ensure that the temporary file cannot be read by other CGI scripts, +use suEXEC or a CGI wrapper program to run your script. The temporary +file is created with mode 0600 (neither world nor group readable). + +The temporary directory is selected using the following algorithm: + + 1. if the current user (e.g. "nobody") has a directory named + "tmp" in its home directory, use that (Unix systems only). + + 2. if the environment variable TMPDIR exists, use the location + indicated. + + 3. Otherwise try the locations /usr/tmp, /var/tmp, C:\temp, + /tmp, /temp, ::Temporary Items, and \WWW_ROOT. + +Each of these locations is checked that it is a directory and is +writable. If not, the algorithm tries the next choice. + +=back + +=head2 SPECIAL FORMS FOR IMPORTING HTML-TAG FUNCTIONS + +Many of the methods generate HTML tags. As described below, tag +functions automatically generate both the opening and closing tags. +For example: + + print h1('Level 1 Header'); + +produces + +

    Level 1 Header

    + +There will be some times when you want to produce the start and end +tags yourself. In this case, you can use the form start_I +and end_I, as in: + + print start_h1,'Level 1 Header',end_h1; + +With a few exceptions (described below), start_I and +end_I functions are not generated automatically when you +I. However, you can specify the tags you want to generate +I functions for by putting an asterisk in front of their +name, or, alternatively, requesting either "start_I" or +"end_I" in the import list. + +Example: + + use CGI qw/:standard *table start_ul/; + +In this example, the following functions are generated in addition to +the standard ones: + +=over 4 + +=item 1. start_table() (generates a
    tag) + +=item 2. end_table() (generates a
    tag) + +=item 3. start_ul() (generates a
      tag) + +=item 4. end_ul() (generates a
    tag) + +=back + +=head1 GENERATING DYNAMIC DOCUMENTS + +Most of CGI.pm's functions deal with creating documents on the fly. +Generally you will produce the HTTP header first, followed by the +document itself. CGI.pm provides functions for generating HTTP +headers of various types as well as for generating HTML. For creating +GIF images, see the GD.pm module. + +Each of these functions produces a fragment of HTML or HTTP which you +can print out directly so that it displays in the browser window, +append to a string, or save to a file for later use. + +=head2 CREATING A STANDARD HTTP HEADER: + +Normally the first thing you will do in any CGI script is print out an +HTTP header. This tells the browser what type of document to expect, +and gives other optional information, such as the language, expiration +date, and whether to cache the document. The header can also be +manipulated for special purposes, such as server push and pay per view +pages. + + print $query->header; + + -or- + + print $query->header('image/gif'); + + -or- + + print $query->header('text/html','204 No response'); + + -or- + + print $query->header(-type=>'image/gif', + -nph=>1, + -status=>'402 Payment required', + -expires=>'+3d', + -cookie=>$cookie, + -charset=>'utf-7', + -attachment=>'foo.gif', + -Cost=>'$2.00'); + +header() returns the Content-type: header. You can provide your own +MIME type if you choose, otherwise it defaults to text/html. An +optional second parameter specifies the status code and a human-readable +message. For example, you can specify 204, "No response" to create a +script that tells the browser to do nothing at all. + +The last example shows the named argument style for passing arguments +to the CGI methods using named parameters. Recognized parameters are +B<-type>, B<-status>, B<-expires>, and B<-cookie>. Any other named +parameters will be stripped of their initial hyphens and turned into +header fields, allowing you to specify any HTTP header you desire. +Internal underscores will be turned into hyphens: + + print $query->header(-Content_length=>3002); + +Most browsers will not cache the output from CGI scripts. Every time +the browser reloads the page, the script is invoked anew. You can +change this behavior with the B<-expires> parameter. When you specify +an absolute or relative expiration interval with this parameter, some +browsers and proxy servers will cache the script's output until the +indicated expiration date. The following forms are all valid for the +-expires field: + + +30s 30 seconds from now + +10m ten minutes from now + +1h one hour from now + -1d yesterday (i.e. "ASAP!") + now immediately + +3M in three months + +10y in ten years time + Thursday, 25-Apr-1999 00:40:33 GMT at the indicated time & date + +The B<-cookie> parameter generates a header that tells the browser to provide +a "magic cookie" during all subsequent transactions with your script. +Netscape cookies have a special format that includes interesting attributes +such as expiration time. Use the cookie() method to create and retrieve +session cookies. + +The B<-nph> parameter, if set to a true value, will issue the correct +headers to work with a NPH (no-parse-header) script. This is important +to use with certain servers that expect all their scripts to be NPH. + +The B<-charset> parameter can be used to control the character set +sent to the browser. If not provided, defaults to ISO-8859-1. As a +side effect, this sets the charset() method as well. + +The B<-attachment> parameter can be used to turn the page into an +attachment. Instead of displaying the page, some browsers will prompt +the user to save it to disk. The value of the argument is the +suggested name for the saved file. In order for this to work, you may +have to set the B<-type> to "application/octet-stream". + +The B<-p3p> parameter will add a P3P tag to the outgoing header. The +parameter can be an arrayref or a space-delimited string of P3P tags. +For example: + + print header(-p3p=>[qw(CAO DSP LAW CURa)]); + print header(-p3p=>'CAO DSP LAW CURa'); + +In either case, the outgoing header will be formatted as: + + P3P: policyref="/w3c/p3p.xml" cp="CAO DSP LAW CURa" + +=head2 GENERATING A REDIRECTION HEADER + + print $query->redirect('http://somewhere.else/in/movie/land'); + +Sometimes you don't want to produce a document yourself, but simply +redirect the browser elsewhere, perhaps choosing a URL based on the +time of day or the identity of the user. + +The redirect() function redirects the browser to a different URL. If +you use redirection like this, you should B print out a header as +well. + +You should always use full URLs (including the http: or ftp: part) in +redirection requests. Relative URLs will not work correctly. + +You can also use named arguments: + + print $query->redirect(-uri=>'http://somewhere.else/in/movie/land', + -nph=>1, + -status=>301); + +The B<-nph> parameter, if set to a true value, will issue the correct +headers to work with a NPH (no-parse-header) script. This is important +to use with certain servers, such as Microsoft IIS, which +expect all their scripts to be NPH. + +The B<-status> parameter will set the status of the redirect. HTTP +defines three different possible redirection status codes: + + 301 Moved Permanently + 302 Found + 303 See Other + +The default if not specified is 302, which means "moved temporarily." +You may change the status to another status code if you wish. Be +advised that changing the status to anything other than 301, 302 or +303 will probably break redirection. + +=head2 CREATING THE HTML DOCUMENT HEADER + + print $query->start_html(-title=>'Secrets of the Pyramids', + -author=>'fred@capricorn.org', + -base=>'true', + -target=>'_blank', + -meta=>{'keywords'=>'pharaoh secret mummy', + 'copyright'=>'copyright 1996 King Tut'}, + -style=>{'src'=>'/styles/style1.css'}, + -BGCOLOR=>'blue'); + +After creating the HTTP header, most CGI scripts will start writing +out an HTML document. The start_html() routine creates the top of the +page, along with a lot of optional information that controls the +page's appearance and behavior. + +This method returns a canned HTML header and the opening tag. +All parameters are optional. In the named parameter form, recognized +parameters are -title, -author, -base, -xbase, -dtd, -lang and -target +(see below for the explanation). Any additional parameters you +provide, such as the Netscape unofficial BGCOLOR attribute, are added +to the tag. Additional parameters must be proceeded by a +hyphen. + +The argument B<-xbase> allows you to provide an HREF for the tag +different from the current location, as in + + -xbase=>"http://home.mcom.com/" + +All relative links will be interpreted relative to this tag. + +The argument B<-target> allows you to provide a default target frame +for all the links and fill-out forms on the page. B +See the Netscape documentation on frames for details of how to +manipulate this. + + -target=>"answer_window" + +All relative links will be interpreted relative to this tag. +You add arbitrary meta information to the header with the B<-meta> +argument. This argument expects a reference to an associative array +containing name/value pairs of meta information. These will be turned +into a series of header tags that look something like this: + + + + +To create an HTTP-EQUIV type of tag, use B<-head>, described +below. + +The B<-style> argument is used to incorporate cascading stylesheets +into your code. See the section on CASCADING STYLESHEETS for more +information. + +The B<-lang> argument is used to incorporate a language attribute into +the tag. For example: + + print $q->start_html(-lang=>'fr-CA'); + +The default if not specified is "en-US" for US English, unless the +-dtd parameter specifies an HTML 2.0 or 3.2 DTD, in which case the +lang attribute is left off. You can force the lang attribute to left +off in other cases by passing an empty string (-lang=>''). + +The B<-encoding> argument can be used to specify the character set for +XHTML. It defaults to iso-8859-1 if not specified. + +You can place other arbitrary HTML elements to the section with the +B<-head> tag. For example, to place the rarely-used element in the +head section, use this: + + print start_html(-head=>Link({-rel=>'next', + -href=>'http://www.capricorn.com/s2.html'})); + +To incorporate multiple HTML elements into the section, just pass an +array reference: + + print start_html(-head=>[ + Link({-rel=>'next', + -href=>'http://www.capricorn.com/s2.html'}), + Link({-rel=>'previous', + -href=>'http://www.capricorn.com/s1.html'}) + ] + ); + +And here's how to create an HTTP-EQUIV tag: + + print start_html(-head=>meta({-http_equiv => 'Content-Type', + -content => 'text/html'})) + + +JAVASCRIPTING: The B<-script>, B<-noScript>, B<-onLoad>, +B<-onMouseOver>, B<-onMouseOut> and B<-onUnload> parameters are used +to add Netscape JavaScript calls to your pages. B<-script> should +point to a block of text containing JavaScript function definitions. +This block will be placed within a \n"; + warningsToBrowser(1); # re-enable warnings + +Note: In this respect warningsToBrowser() differs fundamentally from +fatalsToBrowser(), which you should never call yourself! + +=head1 OVERRIDING THE NAME OF THE PROGRAM + +CGI::Carp includes the name of the program that generated the error or +warning in the messages written to the log and the browser window. +Sometimes, Perl can get confused about what the actual name of the +executed program was. In these cases, you can override the program +name that CGI::Carp will use for all messages. + +The quick way to do that is to tell CGI::Carp the name of the program +in its use statement. You can do that by adding +"name=cgi_carp_log_name" to your "use" statement. For example: + + use CGI::Carp qw(name=cgi_carp_log_name); + +. If you want to change the program name partway through the program, +you can use the C function instead. It is not +exported by default, you must import it explicitly by saying + + use CGI::Carp qw(set_progname); + +Once you've done that, you can change the logged name of the program +at any time by calling + + set_progname(new_program_name); + +You can set the program back to the default by calling + + set_progname(undef); + +Note that this override doesn't happen until after the program has +compiled, so any compile-time errors will still show up with the +non-overridden program name + +=head1 CHANGE LOG + +1.05 carpout() added and minor corrections by Marc Hedlund + on 11/26/95. + +1.06 fatalsToBrowser() no longer aborts for fatal errors within + eval() statements. + +1.08 set_message() added and carpout() expanded to allow for FileHandle + objects. + +1.09 set_message() now allows users to pass a code REFERENCE for + really custom error messages. croak and carp are now + exported by default. Thanks to Gunther Birznieks for the + patches. + +1.10 Patch from Chris Dean (ctdean@cogit.com) to allow + module to run correctly under mod_perl. + +1.11 Changed order of > and < escapes. + +1.12 Changed die() on line 217 to CORE::die to avoid B<-w> warning. + +1.13 Added cluck() to make the module orthogonal with Carp. + More mod_perl related fixes. + +1.20 Patch from Ilmari Karonen (perl@itz.pp.sci.fi): Added + warningsToBrowser(). Replaced tags with
     in
    +     fatalsToBrowser() output.
    +
    +1.23 ineval() now checks both $^S and inspects the message for the "eval" pattern
    +     (hack alert!) in order to accomodate various combinations of Perl and
    +     mod_perl.
    +
    +1.24 Patch from Scott Gifford (sgifford@suspectclass.com): Add support
    +     for overriding program name.
    +
    +1.26 Replaced CORE::GLOBAL::die with the evil $SIG{__DIE__} because the
    +     former isn't working in some people's hands.  There is no such thing
    +     as reliable exception handling in Perl.
    +
    +1.27 Replaced tell STDOUT with bytes=tell STDOUT.
    +
    +=head1 AUTHORS
    +
    +Copyright 1995-2002, Lincoln D. Stein.  All rights reserved.  
    +
    +This library is free software; you can redistribute it and/or modify
    +it under the same terms as Perl itself.
    +
    +Address bug reports and comments to: lstein@cshl.org
    +
    +=head1 SEE ALSO
    +
    +Carp, CGI::Base, CGI::BasePlus, CGI::Request, CGI::MiniSvr, CGI::Form,
    +CGI::Response
    +    if (defined($CGI::Carp::PROGNAME)) 
    +    {
    +      $file = $CGI::Carp::PROGNAME;
    +    }
    +
    +=cut
    +
    +require 5.000;
    +use Exporter;
    +#use Carp;
    +BEGIN { 
    +  require Carp; 
    +  *CORE::GLOBAL::die = \&CGI::Carp::die;
    +}
    +
    +use File::Spec;
    +
    +@ISA = qw(Exporter);
    +@EXPORT = qw(confess croak carp);
    +@EXPORT_OK = qw(carpout fatalsToBrowser warningsToBrowser wrap set_message set_progname cluck ^name= die);
    +
    +$main::SIG{__WARN__}=\&CGI::Carp::warn;
    +
    +$CGI::Carp::VERSION    = '1.28';
    +$CGI::Carp::CUSTOM_MSG = undef;
    +
    +
    +# fancy import routine detects and handles 'errorWrap' specially.
    +sub import {
    +    my $pkg = shift;
    +    my(%routines);
    +    my(@name);
    +  
    +    if (@name=grep(/^name=/,@_))
    +      {
    +        my($n) = (split(/=/,$name[0]))[1];
    +        set_progname($n);
    +        @_=grep(!/^name=/,@_);
    +      }
    +
    +    grep($routines{$_}++,@_,@EXPORT);
    +    $WRAP++ if $routines{'fatalsToBrowser'} || $routines{'wrap'};
    +    $WARN++ if $routines{'warningsToBrowser'};
    +    my($oldlevel) = $Exporter::ExportLevel;
    +    $Exporter::ExportLevel = 1;
    +    Exporter::import($pkg,keys %routines);
    +    $Exporter::ExportLevel = $oldlevel;
    +    $main::SIG{__DIE__} =\&CGI::Carp::die if $routines{'fatalsToBrowser'};
    +#    $pkg->export('CORE::GLOBAL','die');
    +}
    +
    +# These are the originals
    +sub realwarn { CORE::warn(@_); }
    +sub realdie { CORE::die(@_); }
    +
    +sub id {
    +    my $level = shift;
    +    my($pack,$file,$line,$sub) = caller($level);
    +    my($dev,$dirs,$id) = File::Spec->splitpath($file);
    +    return ($file,$line,$id);
    +}
    +
    +sub stamp {
    +    my $time = scalar(localtime);
    +    my $frame = 0;
    +    my ($id,$pack,$file,$dev,$dirs);
    +    if (defined($CGI::Carp::PROGNAME)) {
    +        $id = $CGI::Carp::PROGNAME;
    +    } else {
    +        do {
    +  	  $id = $file;
    +	  ($pack,$file) = caller($frame++);
    +        } until !$file;
    +    }
    +    ($dev,$dirs,$id) = File::Spec->splitpath($id);
    +    return "[$time] $id: ";
    +}
    +
    +sub set_progname {
    +    $CGI::Carp::PROGNAME = shift;
    +    return $CGI::Carp::PROGNAME;
    +}
    +
    +
    +sub warn {
    +    my $message = shift;
    +    my($file,$line,$id) = id(1);
    +    $message .= " at $file line $line.\n" unless $message=~/\n$/;
    +    _warn($message) if $WARN;
    +    my $stamp = stamp;
    +    $message=~s/^/$stamp/gm;
    +    realwarn $message;
    +}
    +
    +sub _warn {
    +    my $msg = shift;
    +    if ($EMIT_WARNINGS) {
    +	# We need to mangle the message a bit to make it a valid HTML
    +	# comment.  This is done by substituting similar-looking ISO
    +	# 8859-1 characters for <, > and -.  This is a hack.
    +	$msg =~ tr/<>-/\253\273\255/;
    +	chomp $msg;
    +	print STDOUT "\n";
    +    } else {
    +	push @WARNINGS, $msg;
    +    }
    +}
    +
    +
    +# The mod_perl package Apache::Registry loads CGI programs by calling
    +# eval.  These evals don't count when looking at the stack backtrace.
    +sub _longmess {
    +    my $message = Carp::longmess();
    +    $message =~ s,eval[^\n]+(ModPerl|Apache)/Registry\w*\.pm.*,,s
    +        if exists $ENV{MOD_PERL};
    +    return $message;
    +}
    +
    +sub ineval {
    +  (exists $ENV{MOD_PERL} ? 0 : $^S) || _longmess() =~ /eval [\{\']/m
    +}
    +
    +sub die {
    +  my ($arg,@rest) = @_;
    +  realdie ($arg,@rest) if ineval();
    +
    +  if (!ref($arg)) {
    +    $arg = join("", ($arg,@rest));
    +    my($file,$line,$id) = id(1);
    +    $arg .= " at $file line $line." unless $arg=~/\n$/;
    +    &fatalsToBrowser($arg) if $WRAP;
    +    if (($arg =~ /\n$/) || !exists($ENV{MOD_PERL})) {
    +      my $stamp = stamp;
    +      $arg=~s/^/$stamp/gm;
    +    }
    +    if ($arg !~ /\n$/) {
    +      $arg .= "\n";
    +    }
    +  }
    +  realdie $arg;
    +}
    +
    +sub set_message {
    +    $CGI::Carp::CUSTOM_MSG = shift;
    +    return $CGI::Carp::CUSTOM_MSG;
    +}
    +
    +sub confess { CGI::Carp::die Carp::longmess @_; }
    +sub croak   { CGI::Carp::die Carp::shortmess @_; }
    +sub carp    { CGI::Carp::warn Carp::shortmess @_; }
    +sub cluck   { CGI::Carp::warn Carp::longmess @_; }
    +
    +# We have to be ready to accept a filehandle as a reference
    +# or a string.
    +sub carpout {
    +    my($in) = @_;
    +    my($no) = fileno(to_filehandle($in));
    +    realdie("Invalid filehandle $in\n") unless defined $no;
    +    
    +    open(SAVEERR, ">&STDERR");
    +    open(STDERR, ">&$no") or 
    +	( print SAVEERR "Unable to redirect STDERR: $!\n" and exit(1) );
    +}
    +
    +sub warningsToBrowser {
    +    $EMIT_WARNINGS = @_ ? shift : 1;
    +    _warn(shift @WARNINGS) while $EMIT_WARNINGS and @WARNINGS;
    +}
    +
    +# headers
    +sub fatalsToBrowser {
    +  my($msg) = @_;
    +  $msg=~s/&/&/g;
    +  $msg=~s/>/>/g;
    +  $msg=~s/$ENV{SERVER_ADMIN})] :
    +      "this site's webmaster";
    +  my ($outer_message) = <Software error:
    +
    $msg
    +

    +$outer_message +

    +END + ; + + if ($mod_perl) { + require mod_perl; + if ($mod_perl::VERSION >= 1.99) { + $mod_perl = 2; + require Apache::RequestRec; + require Apache::RequestIO; + require Apache::RequestUtil; + require APR::Pool; + require ModPerl::Util; + require Apache::Response; + } + my $r = Apache->request; + # If bytes have already been sent, then + # we print the message out directly. + # Otherwise we make a custom error + # handler to produce the doc for us. + if ($r->bytes_sent) { + $r->print($mess); + $mod_perl == 2 ? ModPerl::Util::exit(0) : $r->exit; + } else { + # MSIE won't display a custom 500 response unless it is >512 bytes! + if ($ENV{HTTP_USER_AGENT} =~ /MSIE/) { + $mess = "\n$mess"; + } + $r->custom_response(500,$mess); + } + } else { + my $bytes_written = eval{tell STDOUT}; + if (defined $bytes_written && $bytes_written > 0) { + print STDOUT $mess; + } + else { + print STDOUT "Content-type: text/html\n\n"; + print STDOUT $mess; + } + } + + warningsToBrowser(1); # emit warnings before dying +} + +# Cut and paste from CGI.pm so that we don't have the overhead of +# always loading the entire CGI module. +sub to_filehandle { + my $thingy = shift; + return undef unless $thingy; + return $thingy if UNIVERSAL::isa($thingy,'GLOB'); + return $thingy if UNIVERSAL::isa($thingy,'FileHandle'); + if (!ref($thingy)) { + my $caller = 1; + while (my $package = caller($caller++)) { + my($tmp) = $thingy=~/[\':]/ ? $thingy : "$package\:\:$thingy"; + return $tmp if defined(fileno($tmp)); + } + } + return undef; +} + +1; diff --git a/lib/CGI/Cookie.pm b/lib/CGI/Cookie.pm new file mode 100644 index 0000000..27a93c5 --- /dev/null +++ b/lib/CGI/Cookie.pm @@ -0,0 +1,478 @@ +package CGI::Cookie; + +# See the bottom of this file for the POD documentation. Search for the +# string '=head'. + +# You can run this file through either pod2man or pod2html to produce pretty +# documentation in manual or html file format (these utilities are part of the +# Perl 5 distribution). + +# Copyright 1995-1999, Lincoln D. Stein. All rights reserved. +# It may be used and modified freely, but I do request that this copyright +# notice remain attached to the file. You may modify this module as you +# wish, but if you redistribute a modified version, please attach a note +# listing the modifications you have made. + +$CGI::Cookie::VERSION='1.24'; + +use CGI::Util qw(rearrange unescape escape); +use overload '""' => \&as_string, + 'cmp' => \&compare, + 'fallback'=>1; + +# Turn on special checking for Doug MacEachern's modperl +my $MOD_PERL = 0; +if (exists $ENV{MOD_PERL}) { + eval "require mod_perl"; + if (defined $mod_perl::VERSION) { + if ($mod_perl::VERSION >= 1.99) { + $MOD_PERL = 2; + require Apache::RequestUtil; + } else { + $MOD_PERL = 1; + require Apache; + } + } +} + +# fetch a list of cookies from the environment and +# return as a hash. the cookies are parsed as normal +# escaped URL data. +sub fetch { + my $class = shift; + my $raw_cookie = get_raw_cookie(@_) or return; + return $class->parse($raw_cookie); +} + +# Fetch a list of cookies from the environment or the incoming headers and +# return as a hash. The cookie values are not unescaped or altered in any way. + sub raw_fetch { + my $class = shift; + my $raw_cookie = get_raw_cookie(@_) or return; + my %results; + my($key,$value); + + my(@pairs) = split("; ?",$raw_cookie); + foreach (@pairs) { + s/\s*(.*?)\s*/$1/; + if (/^([^=]+)=(.*)/) { + $key = $1; + $value = $2; + } + else { + $key = $_; + $value = ''; + } + $results{$key} = $value; + } + return \%results unless wantarray; + return %results; +} + +sub get_raw_cookie { + my $r = shift; + $r ||= eval { Apache->request() } if $MOD_PERL; + if ($r) { + $raw_cookie = $r->headers_in->{'Cookie'}; + } else { + if ($MOD_PERL && !exists $ENV{REQUEST_METHOD}) { + die "Run $r->subprocess_env; before calling fetch()"; + } + $raw_cookie = $ENV{HTTP_COOKIE} || $ENV{COOKIE}; + } +} + + +sub parse { + my ($self,$raw_cookie) = @_; + my %results; + + my(@pairs) = split("; ?",$raw_cookie); + foreach (@pairs) { + s/\s*(.*?)\s*/$1/; + my($key,$value) = split("=",$_,2); + + # Some foreign cookies are not in name=value format, so ignore + # them. + next if !defined($value); + my @values = (); + if ($value ne '') { + @values = map unescape($_),split(/[&;]/,$value.'&dmy'); + pop @values; + } + $key = unescape($key); + # A bug in Netscape can cause several cookies with same name to + # appear. The FIRST one in HTTP_COOKIE is the most recent version. + $results{$key} ||= $self->new(-name=>$key,-value=>\@values); + } + return \%results unless wantarray; + return %results; +} + +sub new { + my $class = shift; + $class = ref($class) if ref($class); + my($name,$value,$path,$domain,$secure,$expires) = + rearrange([NAME,[VALUE,VALUES],PATH,DOMAIN,SECURE,EXPIRES],@_); + + # Pull out our parameters. + my @values; + if (ref($value)) { + if (ref($value) eq 'ARRAY') { + @values = @$value; + } elsif (ref($value) eq 'HASH') { + @values = %$value; + } + } else { + @values = ($value); + } + + bless my $self = { + 'name'=>$name, + 'value'=>[@values], + },$class; + + # IE requires the path and domain to be present for some reason. + $path ||= "/"; + # however, this breaks networks which use host tables without fully qualified + # names, so we comment it out. + # $domain = CGI::virtual_host() unless defined $domain; + + $self->path($path) if defined $path; + $self->domain($domain) if defined $domain; + $self->secure($secure) if defined $secure; + $self->expires($expires) if defined $expires; +# $self->max_age($expires) if defined $expires; + return $self; +} + +sub as_string { + my $self = shift; + return "" unless $self->name; + + my(@constant_values,$domain,$path,$expires,$max_age,$secure); + + push(@constant_values,"domain=$domain") if $domain = $self->domain; + push(@constant_values,"path=$path") if $path = $self->path; + push(@constant_values,"expires=$expires") if $expires = $self->expires; + push(@constant_values,"max-age=$max_age") if $max_age = $self->max_age; + push(@constant_values,"secure") if $secure = $self->secure; + + my($key) = escape($self->name); + my($cookie) = join("=",$key,join("&",map escape($_),$self->value)); + return join("; ",$cookie,@constant_values); +} + +sub compare { + my $self = shift; + my $value = shift; + return "$self" cmp $value; +} + +# accessors +sub name { + my $self = shift; + my $name = shift; + $self->{'name'} = $name if defined $name; + return $self->{'name'}; +} + +sub value { + my $self = shift; + my $value = shift; + if (defined $value) { + my @values; + if (ref($value)) { + if (ref($value) eq 'ARRAY') { + @values = @$value; + } elsif (ref($value) eq 'HASH') { + @values = %$value; + } + } else { + @values = ($value); + } + $self->{'value'} = [@values]; + } + return wantarray ? @{$self->{'value'}} : $self->{'value'}->[0] +} + +sub domain { + my $self = shift; + my $domain = shift; + $self->{'domain'} = $domain if defined $domain; + return $self->{'domain'}; +} + +sub secure { + my $self = shift; + my $secure = shift; + $self->{'secure'} = $secure if defined $secure; + return $self->{'secure'}; +} + +sub expires { + my $self = shift; + my $expires = shift; + $self->{'expires'} = CGI::Util::expires($expires,'cookie') if defined $expires; + return $self->{'expires'}; +} + +sub max_age { + my $self = shift; + my $expires = shift; + $self->{'max-age'} = CGI::Util::expire_calc($expires)-time() if defined $expires; + return $self->{'max-age'}; +} + +sub path { + my $self = shift; + my $path = shift; + $self->{'path'} = $path if defined $path; + return $self->{'path'}; +} + +1; + +=head1 NAME + +CGI::Cookie - Interface to Netscape Cookies + +=head1 SYNOPSIS + + use CGI qw/:standard/; + use CGI::Cookie; + + # Create new cookies and send them + $cookie1 = new CGI::Cookie(-name=>'ID',-value=>123456); + $cookie2 = new CGI::Cookie(-name=>'preferences', + -value=>{ font => Helvetica, + size => 12 } + ); + print header(-cookie=>[$cookie1,$cookie2]); + + # fetch existing cookies + %cookies = fetch CGI::Cookie; + $id = $cookies{'ID'}->value; + + # create cookies returned from an external source + %cookies = parse CGI::Cookie($ENV{COOKIE}); + +=head1 DESCRIPTION + +CGI::Cookie is an interface to Netscape (HTTP/1.1) cookies, an +innovation that allows Web servers to store persistent information on +the browser's side of the connection. Although CGI::Cookie is +intended to be used in conjunction with CGI.pm (and is in fact used by +it internally), you can use this module independently. + +For full information on cookies see + + http://www.ics.uci.edu/pub/ietf/http/rfc2109.txt + +=head1 USING CGI::Cookie + +CGI::Cookie is object oriented. Each cookie object has a name and a +value. The name is any scalar value. The value is any scalar or +array value (associative arrays are also allowed). Cookies also have +several optional attributes, including: + +=over 4 + +=item B<1. expiration date> + +The expiration date tells the browser how long to hang on to the +cookie. If the cookie specifies an expiration date in the future, the +browser will store the cookie information in a disk file and return it +to the server every time the user reconnects (until the expiration +date is reached). If the cookie species an expiration date in the +past, the browser will remove the cookie from the disk file. If the +expiration date is not specified, the cookie will persist only until +the user quits the browser. + +=item B<2. domain> + +This is a partial or complete domain name for which the cookie is +valid. The browser will return the cookie to any host that matches +the partial domain name. For example, if you specify a domain name +of ".capricorn.com", then Netscape will return the cookie to +Web servers running on any of the machines "www.capricorn.com", +"ftp.capricorn.com", "feckless.capricorn.com", etc. Domain names +must contain at least two periods to prevent attempts to match +on top level domains like ".edu". If no domain is specified, then +the browser will only return the cookie to servers on the host the +cookie originated from. + +=item B<3. path> + +If you provide a cookie path attribute, the browser will check it +against your script's URL before returning the cookie. For example, +if you specify the path "/cgi-bin", then the cookie will be returned +to each of the scripts "/cgi-bin/tally.pl", "/cgi-bin/order.pl", and +"/cgi-bin/customer_service/complain.pl", but not to the script +"/cgi-private/site_admin.pl". By default, the path is set to "/", so +that all scripts at your site will receive the cookie. + +=item B<4. secure flag> + +If the "secure" attribute is set, the cookie will only be sent to your +script if the CGI request is occurring on a secure channel, such as SSL. + +=back + +=head2 Creating New Cookies + + $c = new CGI::Cookie(-name => 'foo', + -value => 'bar', + -expires => '+3M', + -domain => '.capricorn.com', + -path => '/cgi-bin/database', + -secure => 1 + ); + +Create cookies from scratch with the B method. The B<-name> and +B<-value> parameters are required. The name must be a scalar value. +The value can be a scalar, an array reference, or a hash reference. +(At some point in the future cookies will support one of the Perl +object serialization protocols for full generality). + +B<-expires> accepts any of the relative or absolute date formats +recognized by CGI.pm, for example "+3M" for three months in the +future. See CGI.pm's documentation for details. + +B<-domain> points to a domain name or to a fully qualified host name. +If not specified, the cookie will be returned only to the Web server +that created it. + +B<-path> points to a partial URL on the current server. The cookie +will be returned to all URLs beginning with the specified path. If +not specified, it defaults to '/', which returns the cookie to all +pages at your site. + +B<-secure> if set to a true value instructs the browser to return the +cookie only when a cryptographic protocol is in use. + +=head2 Sending the Cookie to the Browser + +Within a CGI script you can send a cookie to the browser by creating +one or more Set-Cookie: fields in the HTTP header. Here is a typical +sequence: + + my $c = new CGI::Cookie(-name => 'foo', + -value => ['bar','baz'], + -expires => '+3M'); + + print "Set-Cookie: $c\n"; + print "Content-Type: text/html\n\n"; + +To send more than one cookie, create several Set-Cookie: fields. + +If you are using CGI.pm, you send cookies by providing a -cookie +argument to the header() method: + + print header(-cookie=>$c); + +Mod_perl users can set cookies using the request object's header_out() +method: + + $r->headers_out->set('Set-Cookie' => $c); + +Internally, Cookie overloads the "" operator to call its as_string() +method when incorporated into the HTTP header. as_string() turns the +Cookie's internal representation into an RFC-compliant text +representation. You may call as_string() yourself if you prefer: + + print "Set-Cookie: ",$c->as_string,"\n"; + +=head2 Recovering Previous Cookies + + %cookies = fetch CGI::Cookie; + +B returns an associative array consisting of all cookies +returned by the browser. The keys of the array are the cookie names. You +can iterate through the cookies this way: + + %cookies = fetch CGI::Cookie; + foreach (keys %cookies) { + do_something($cookies{$_}); + } + +In a scalar context, fetch() returns a hash reference, which may be more +efficient if you are manipulating multiple cookies. + +CGI.pm uses the URL escaping methods to save and restore reserved characters +in its cookies. If you are trying to retrieve a cookie set by a foreign server, +this escaping method may trip you up. Use raw_fetch() instead, which has the +same semantics as fetch(), but performs no unescaping. + +You may also retrieve cookies that were stored in some external +form using the parse() class method: + + $COOKIES = `cat /usr/tmp/Cookie_stash`; + %cookies = parse CGI::Cookie($COOKIES); + +If you are in a mod_perl environment, you can save some overhead by +passing the request object to fetch() like this: + + CGI::Cookie->fetch($r); + +=head2 Manipulating Cookies + +Cookie objects have a series of accessor methods to get and set cookie +attributes. Each accessor has a similar syntax. Called without +arguments, the accessor returns the current value of the attribute. +Called with an argument, the accessor changes the attribute and +returns its new value. + +=over 4 + +=item B + +Get or set the cookie's name. Example: + + $name = $c->name; + $new_name = $c->name('fred'); + +=item B + +Get or set the cookie's value. Example: + + $value = $c->value; + @new_value = $c->value(['a','b','c','d']); + +B is context sensitive. In a list context it will return +the current value of the cookie as an array. In a scalar context it +will return the B value of a multivalued cookie. + +=item B + +Get or set the cookie's domain. + +=item B + +Get or set the cookie's path. + +=item B + +Get or set the cookie's expiration time. + +=back + + +=head1 AUTHOR INFORMATION + +Copyright 1997-1998, Lincoln D. Stein. All rights reserved. + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +Address bug reports and comments to: lstein@cshl.org + +=head1 BUGS + +This section intentionally left blank. + +=head1 SEE ALSO + +L, L + +=cut diff --git a/lib/CGI/Fast.pm b/lib/CGI/Fast.pm new file mode 100644 index 0000000..43b8709 --- /dev/null +++ b/lib/CGI/Fast.pm @@ -0,0 +1,230 @@ +package CGI::Fast; + +# See the bottom of this file for the POD documentation. Search for the +# string '=head'. + +# You can run this file through either pod2man or pod2html to produce pretty +# documentation in manual or html file format (these utilities are part of the +# Perl 5 distribution). + +# Copyright 1995,1996, Lincoln D. Stein. All rights reserved. +# It may be used and modified freely, but I do request that this copyright +# notice remain attached to the file. You may modify this module as you +# wish, but if you redistribute a modified version, please attach a note +# listing the modifications you have made. + +# The most recent version and complete docs are available at: +# http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html +# ftp://ftp-genome.wi.mit.edu/pub/software/WWW/ +$CGI::Fast::VERSION='1.05'; + +use CGI; +use FCGI; +@ISA = ('CGI'); + +# workaround for known bug in libfcgi +while (($ignore) = each %ENV) { } + +# override the initialization behavior so that +# state is NOT maintained between invocations +sub save_request { + # no-op +} + +# If ENV{FCGI_SOCKET_PATH} is specified, we maintain a FCGI Request handle +# in this package variable. +use vars qw($Ext_Request); +BEGIN { + # If ENV{FCGI_SOCKET_PATH} is given, explicitly open the socket, + # and keep the request handle around from which to call Accept(). + if ($ENV{FCGI_SOCKET_PATH}) { + my $path = $ENV{FCGI_SOCKET_PATH}; + my $backlog = $ENV{FCGI_LISTEN_QUEUE} || 100; + my $socket = FCGI::OpenSocket( $path, $backlog ); + $Ext_Request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, + \%ENV, $socket, 1 ); + } +} + +# New is slightly different in that it calls FCGI's +# accept() method. +sub new { + my ($self, $initializer, @param) = @_; + unless (defined $initializer) { + if ($Ext_Request) { + return undef unless $Ext_Request->Accept() >= 0; + } else { + return undef unless FCGI::accept() >= 0; + } + } + return $CGI::Q = $self->SUPER::new($initializer, @param); +} + +1; + +=head1 NAME + +CGI::Fast - CGI Interface for Fast CGI + +=head1 SYNOPSIS + + use CGI::Fast qw(:standard); + $COUNTER = 0; + while (new CGI::Fast) { + print header; + print start_html("Fast CGI Rocks"); + print + h1("Fast CGI Rocks"), + "Invocation number ",b($COUNTER++), + " PID ",b($$),".", + hr; + print end_html; + } + +=head1 DESCRIPTION + +CGI::Fast is a subclass of the CGI object created by +CGI.pm. It is specialized to work well with the Open Market +FastCGI standard, which greatly speeds up CGI scripts by +turning them into persistently running server processes. Scripts +that perform time-consuming initialization processes, such as +loading large modules or opening persistent database connections, +will see large performance improvements. + +=head1 OTHER PIECES OF THE PUZZLE + +In order to use CGI::Fast you'll need a FastCGI-enabled Web +server. Open Market's server is FastCGI-savvy. There are also +freely redistributable FastCGI modules for NCSA httpd 1.5 and Apache. +FastCGI-enabling modules for Microsoft Internet Information Server and +Netscape Communications Server have been announced. + +In addition, you'll need a version of the Perl interpreter that has +been linked with the FastCGI I/O library. Precompiled binaries are +available for several platforms, including DEC Alpha, HP-UX and +SPARC/Solaris, or you can rebuild Perl from source with patches +provided in the FastCGI developer's kit. The FastCGI Perl interpreter +can be used in place of your normal Perl without ill consequences. + +You can find FastCGI modules for Apache and NCSA httpd, precompiled +Perl interpreters, and the FastCGI developer's kit all at URL: + + http://www.fastcgi.com/ + +=head1 WRITING FASTCGI PERL SCRIPTS + +FastCGI scripts are persistent: one or more copies of the script +are started up when the server initializes, and stay around until +the server exits or they die a natural death. After performing +whatever one-time initialization it needs, the script enters a +loop waiting for incoming connections, processing the request, and +waiting some more. + +A typical FastCGI script will look like this: + + #!/usr/local/bin/perl # must be a FastCGI version of perl! + use CGI::Fast; + &do_some_initialization(); + while ($q = new CGI::Fast) { + &process_request($q); + } + +Each time there's a new request, CGI::Fast returns a +CGI object to your loop. The rest of the time your script +waits in the call to new(). When the server requests that +your script be terminated, new() will return undef. You can +of course exit earlier if you choose. A new version of the +script will be respawned to take its place (this may be +necessary in order to avoid Perl memory leaks in long-running +scripts). + +CGI.pm's default CGI object mode also works. Just modify the loop +this way: + + while (new CGI::Fast) { + &process_request; + } + +Calls to header(), start_form(), etc. will all operate on the +current request. + +=head1 INSTALLING FASTCGI SCRIPTS + +See the FastCGI developer's kit documentation for full details. On +the Apache server, the following line must be added to srm.conf: + + AddType application/x-httpd-fcgi .fcgi + +FastCGI scripts must end in the extension .fcgi. For each script you +install, you must add something like the following to srm.conf: + + FastCgiServer /usr/etc/httpd/fcgi-bin/file_upload.fcgi -processes 2 + +This instructs Apache to launch two copies of file_upload.fcgi at +startup time. + +=head1 USING FASTCGI SCRIPTS AS CGI SCRIPTS + +Any script that works correctly as a FastCGI script will also work +correctly when installed as a vanilla CGI script. However it will +not see any performance benefit. + +=head1 EXTERNAL FASTCGI SERVER INVOCATION + +FastCGI supports a TCP/IP transport mechanism which allows FastCGI scripts to run +external to the webserver, perhaps on a remote machine. To configure the +webserver to connect to an external FastCGI server, you would add the following +to your srm.conf: + + FastCgiExternalServer /usr/etc/httpd/fcgi-bin/file_upload.fcgi -host sputnik:8888 + +Two environment variables affect how the C object is created, +allowing C to be used as an external FastCGI server. (See C +documentation for C for more information.) + +=over + +=item FCGI_SOCKET_PATH + +The address (TCP/IP) or path (UNIX Domain) of the socket the external FastCGI +script to which bind an listen for incoming connections from the web server. + +=item FCGI_LISTEN_QUEUE + +Maximum length of the queue of pending connections. + +=back + +For example: + + #!/usr/local/bin/perl # must be a FastCGI version of perl! + use CGI::Fast; + &do_some_initialization(); + $ENV{FCGI_SOCKET_PATH} = "sputnik:8888"; + $ENV{FCGI_LISTEN_QUEUE} = 100; + while ($q = new CGI::Fast) { + &process_request($q); + } + +=head1 CAVEATS + +I haven't tested this very much. + +=head1 AUTHOR INFORMATION + +Copyright 1996-1998, Lincoln D. Stein. All rights reserved. + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +Address bug reports and comments to: lstein@cshl.org + +=head1 BUGS + +This section intentionally left blank. + +=head1 SEE ALSO + +L, L + +=cut diff --git a/lib/CGI/Pretty.pm b/lib/CGI/Pretty.pm new file mode 100644 index 0000000..d824a02 --- /dev/null +++ b/lib/CGI/Pretty.pm @@ -0,0 +1,275 @@ +package CGI::Pretty; + +# See the bottom of this file for the POD documentation. Search for the +# string '=head'. + +# You can run this file through either pod2man or pod2html to produce pretty +# documentation in manual or html file format (these utilities are part of the +# Perl 5 distribution). + +use strict; +use CGI (); + +$CGI::Pretty::VERSION = '1.08'; +$CGI::DefaultClass = __PACKAGE__; +$CGI::Pretty::AutoloadClass = 'CGI'; +@CGI::Pretty::ISA = qw( CGI ); + +initialize_globals(); + +sub _prettyPrint { + my $input = shift; + return if !$$input; + return if !$CGI::Pretty::LINEBREAK || !$CGI::Pretty::INDENT; + +# print STDERR "'", $$input, "'\n"; + + foreach my $i ( @CGI::Pretty::AS_IS ) { + if ( $$input =~ m{}si ) { + my ( $a, $b, $c ) = $$input =~ m{(.*)(<$i[\s/>].*?)(.*)}si; + next if !$b; + $a ||= ""; + $c ||= ""; + + _prettyPrint( \$a ) if $a; + _prettyPrint( \$c ) if $c; + + $b ||= ""; + $$input = "$a$b$c"; + return; + } + } + $$input =~ s/$CGI::Pretty::LINEBREAK/$CGI::Pretty::LINEBREAK$CGI::Pretty::INDENT/g; +} + +sub comment { + my($self,@p) = CGI::self_or_CGI(@_); + + my $s = "@p"; + $s =~ s/$CGI::Pretty::LINEBREAK/$CGI::Pretty::LINEBREAK$CGI::Pretty::INDENT/g if $CGI::Pretty::LINEBREAK; + + return $self->SUPER::comment( "$CGI::Pretty::LINEBREAK$CGI::Pretty::INDENT$s$CGI::Pretty::LINEBREAK" ) . $CGI::Pretty::LINEBREAK; +} + +sub _make_tag_func { + my ($self,$tagname) = @_; + + # As Lincoln as noted, the last else clause is VERY hairy, and it + # took me a while to figure out what I was trying to do. + # What it does is look for tags that shouldn't be indented (e.g. PRE) + # and makes sure that when we nest tags, those tags don't get + # indented. + # For an example, try print td( pre( "hello\nworld" ) ); + # If we didn't care about stuff like that, the code would be + # MUCH simpler. BTW: I won't claim to be a regular expression + # guru, so if anybody wants to contribute something that would + # be quicker, easier to read, etc, I would be more than + # willing to put it in - Brian + + my $func = qq" + sub $tagname {"; + + $func .= q' + shift if $_[0] && + (ref($_[0]) && + (substr(ref($_[0]),0,3) eq "CGI" || + UNIVERSAL::isa($_[0],"CGI"))); + my($attr) = ""; + if (ref($_[0]) && ref($_[0]) eq "HASH") { + my(@attr) = make_attributes(shift()||undef,1); + $attr = " @attr" if @attr; + }'; + + if ($tagname=~/start_(\w+)/i) { + $func .= qq! + return "<\L$1\E\$attr>\$CGI::Pretty::LINEBREAK";} !; + } elsif ($tagname=~/end_(\w+)/i) { + $func .= qq! + return "<\L/$1\E>\$CGI::Pretty::LINEBREAK"; } !; + } else { + $func .= qq# + return ( \$CGI::XHTML ? "<\L$tagname\E\$attr />" : "<\L$tagname\E\$attr>" ) . + \$CGI::Pretty::LINEBREAK unless \@_; + my(\$tag,\$untag) = ("<\L$tagname\E\$attr>","\E"); + + my \%ASIS = map { lc("\$_") => 1 } \@CGI::Pretty::AS_IS; + my \@args; + if ( \$CGI::Pretty::LINEBREAK || \$CGI::Pretty::INDENT ) { + if(ref(\$_[0]) eq 'ARRAY') { + \@args = \@{\$_[0]} + } else { + foreach (\@_) { + \$args[0] .= \$_; + \$args[0] .= \$CGI::Pretty::LINEBREAK if \$args[0] !~ /\$CGI::Pretty::LINEBREAK\$/ && 0; + chomp \$args[0] if exists \$ASIS{ "\L$tagname\E" }; + + \$args[0] .= \$" if \$args[0] !~ /\$CGI::Pretty::LINEBREAK\$/ && 1; + } + chop \$args[0]; + } + } + else { + \@args = ref(\$_[0]) eq 'ARRAY' ? \@{\$_[0]} : "\@_"; + } + + my \@result; + if ( exists \$ASIS{ "\L$tagname\E" } ) { + \@result = map { "\$tag\$_\$untag\$CGI::Pretty::LINEBREAK" } + \@args; + } + else { + \@result = map { + chomp; + my \$tmp = \$_; + CGI::Pretty::_prettyPrint( \\\$tmp ); + \$tag . \$CGI::Pretty::LINEBREAK . + \$CGI::Pretty::INDENT . \$tmp . \$CGI::Pretty::LINEBREAK . + \$untag . \$CGI::Pretty::LINEBREAK + } \@args; + } + local \$" = "" if \$CGI::Pretty::LINEBREAK || \$CGI::Pretty::INDENT; + return "\@result"; + }#; + } + + return $func; +} + +sub start_html { + return CGI::start_html( @_ ) . $CGI::Pretty::LINEBREAK; +} + +sub end_html { + return CGI::end_html( @_ ) . $CGI::Pretty::LINEBREAK; +} + +sub new { + my $class = shift; + my $this = $class->SUPER::new( @_ ); + + if ($CGI::MOD_PERL) { + my $r = Apache->request; + if ($CGI::MOD_PERL == 1) { + $r->register_cleanup(\&CGI::Pretty::_reset_globals); + } + else { + $r->pool->cleanup_register(\&CGI::Pretty::_reset_globals); + } + } + $class->_reset_globals if $CGI::PERLEX; + + return bless $this, $class; +} + +sub initialize_globals { + # This is the string used for indentation of tags + $CGI::Pretty::INDENT = "\t"; + + # This is the string used for seperation between tags + $CGI::Pretty::LINEBREAK = $/; + + # These tags are not prettify'd. + @CGI::Pretty::AS_IS = qw( a pre code script textarea td ); + + 1; +} +sub _reset_globals { initialize_globals(); } + +1; + +=head1 NAME + +CGI::Pretty - module to produce nicely formatted HTML code + +=head1 SYNOPSIS + + use CGI::Pretty qw( :html3 ); + + # Print a table with a single data element + print table( TR( td( "foo" ) ) ); + +=head1 DESCRIPTION + +CGI::Pretty is a module that derives from CGI. It's sole function is to +allow users of CGI to output nicely formatted HTML code. + +When using the CGI module, the following code: + print table( TR( td( "foo" ) ) ); + +produces the following output: +
    foo
    + +If a user were to create a table consisting of many rows and many columns, +the resultant HTML code would be quite difficult to read since it has no +carriage returns or indentation. + +CGI::Pretty fixes this problem. What it does is add a carriage +return and indentation to the HTML code so that one can easily read +it. + + print table( TR( td( "foo" ) ) ); + +now produces the following output: + + + + +
    + foo +
    + + +=head2 Tags that won't be formatted + +The and
     tags are not formatted.  If these tags were formatted, the
    +user would see the extra indentation on the web browser causing the page to
    +look different than what would be expected.  If you wish to add more tags to
    +the list of tags that are not to be touched, push them onto the C<@AS_IS> array:
    +
    +    push @CGI::Pretty::AS_IS,qw(CODE XMP);
    +
    +=head2 Customizing the Indenting
    +
    +If you wish to have your own personal style of indenting, you can change the
    +C<$INDENT> variable:
    +
    +    $CGI::Pretty::INDENT = "\t\t";
    +
    +would cause the indents to be two tabs.
    +
    +Similarly, if you wish to have more space between lines, you may change the
    +C<$LINEBREAK> variable:
    +
    +    $CGI::Pretty::LINEBREAK = "\n\n";
    +
    +would create two carriage returns between lines.
    +
    +If you decide you want to use the regular CGI indenting, you can easily do 
    +the following:
    +
    +    $CGI::Pretty::INDENT = $CGI::Pretty::LINEBREAK = "";
    +
    +=head1 BUGS
    +
    +This section intentionally left blank.
    +
    +=head1 AUTHOR
    +
    +Brian Paulsen , with minor modifications by
    +Lincoln Stein  for incorporation into the CGI.pm
    +distribution.
    +
    +Copyright 1999, Brian Paulsen.  All rights reserved.
    +
    +This library is free software; you can redistribute it and/or modify
    +it under the same terms as Perl itself.
    +
    +Bug reports and comments to Brian@ThePaulsens.com.  You can also write
    +to lstein@cshl.org, but this code looks pretty hairy to me and I'm not
    +sure I understand it!
    +
    +=head1 SEE ALSO
    +
    +L
    +
    +=cut
    diff --git a/lib/CGI/Push.pm b/lib/CGI/Push.pm
    new file mode 100644
    index 0000000..8356c60
    --- /dev/null
    +++ b/lib/CGI/Push.pm
    @@ -0,0 +1,328 @@
    +package CGI::Push;
    +
    +# See the bottom of this file for the POD documentation.  Search for the
    +# string '=head'.
    +
    +# You can run this file through either pod2man or pod2html to produce pretty
    +# documentation in manual or html file format (these utilities are part of the
    +# Perl 5 distribution).
    +
    +# Copyright 1995-2000, Lincoln D. Stein.  All rights reserved.
    +# It may be used and modified freely, but I do request that this copyright
    +# notice remain attached to the file.  You may modify this module as you
    +# wish, but if you redistribute a modified version, please attach a note
    +# listing the modifications you have made.
    +
    +# The most recent version and complete docs are available at:
    +#   http://stein.cshl.org/WWW/software/CGI/
    +
    +$CGI::Push::VERSION='1.04';
    +use CGI;
    +use CGI::Util 'rearrange';
    +@ISA = ('CGI');
    +
    +$CGI::DefaultClass = 'CGI::Push';
    +$CGI::Push::AutoloadClass = 'CGI';
    +
    +# add do_push() and push_delay() to exported tags
    +push(@{$CGI::EXPORT_TAGS{':standard'}},'do_push','push_delay');
    +
    +sub do_push {
    +    my ($self,@p) = CGI::self_or_default(@_);
    +
    +    # unbuffer output
    +    $| = 1;
    +    srand;
    +    my ($random) = sprintf("%08.0f",rand()*1E8);
    +    my ($boundary) = "----=_NeXtPaRt$random";
    +
    +    my (@header);
    +    my ($type,$callback,$delay,$last_page,$cookie,$target,$expires,$nph,$handle,@other) = rearrange([TYPE,NEXT_PAGE,DELAY,LAST_PAGE,[COOKIE,COOKIES],TARGET,EXPIRES,NPH,HANDLE],@p);
    +    $type = 'text/html' unless $type;
    +    $callback = \&simple_counter unless $callback && ref($callback) eq 'CODE';
    +    $delay = 1 unless defined($delay);
    +    $self->push_delay($delay);
    +    $nph = 1 unless defined($nph);
    +    $handle = \*STDOUT unless defined($handle);
    +
    +sdf;kjsdlfsdfkl
    +
    +    my(@o);
    +    foreach (@other) { push(@o,split("=")); }
    +    push(@o,'-Target'=>$target) if defined($target);
    +    push(@o,'-Cookie'=>$cookie) if defined($cookie);
    +    push(@o,'-Type'=>"multipart/x-mixed-replace;boundary=\"$boundary\"");
    +    push(@o,'-Server'=>"CGI.pm Push Module") if $nph;
    +    push(@o,'-Status'=>'200 OK');
    +    push(@o,'-nph'=>1) if $nph;
    +    $handle->print($self->header(@o));
    +
    +    $boundary = "$CGI::CRLF--$boundary";
    +
    +    $handle->print("WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY.${boundary}$CGI::CRLF");
    +
    +    my (@contents) = &$callback($self,++$COUNTER);
    +
    +    # now we enter a little loop
    +    while (1) {
    +        $handle->print("Content-type: ${type}$CGI::CRLF$CGI::CRLF") unless $type =~ /^dynamic|heterogeneous$/i;
    +        $handle->print(@contents);
    +        @contents = &$callback($self,++$COUNTER);
    +        if ((@contents) && defined($contents[0])) {
    +            $handle->print("${boundary}$CGI::CRLF");
    +            do_sleep($self->push_delay()) if $self->push_delay();
    +        } else {
    +            if ($last_page && ref($last_page) eq 'CODE') {
    +                $handle->print("${boundary}$CGI::CRLF");
    +                do_sleep($self->push_delay()) if $self->push_delay();
    +                $handle->print("Content-type: ${type}$CGI::CRLF$CGI::CRLF") unless $type =~ /^dynamic|heterogeneous$/i;
    +                $handle->print(&$last_page($self,$COUNTER));
    +            }
    +            $handle->print("${boundary}--$CGI::CRLF");
    +            last;
    +        }
    +    }
    +    $handle->print("WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY.${boundary}$CGI::CRLF");
    +}
    +
    +sub simple_counter {
    +    my ($self,$count) = @_;
    +    return $self->start_html("CGI::Push Default Counter"),
    +           $self->h1("CGI::Push Default Counter"),
    +           "This page has been updated ",$self->strong($count)," times.",
    +           $self->hr(),
    +           $self->a({'-href'=>'http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html'},'CGI.pm home page'),
    +           $self->end_html;
    +}
    +
    +sub do_sleep {
    +    my $delay = shift;
    +    if ( ($delay >= 1) && ($delay!~/\./) ){
    +        sleep($delay);
    +    } else {
    +        select(undef,undef,undef,$delay);
    +    }
    +}
    +
    +sub push_delay {
    +    my ($self,$delay) = CGI::self_or_default(@_);
    +    return defined($delay) ? $self->{'.delay'} =
    +        $delay : $self->{'.delay'};
    +}
    +
    +1;
    +
    +=head1 NAME
    +
    +CGI::Push - Simple Interface to Server Push
    +
    +=head1 SYNOPSIS
    +
    +    use CGI::Push qw(:standard);
    +
    +    do_push(-next_page=>\&next_page,
    +            -last_page=>\&last_page,
    +            -delay=>0.5);
    +
    +    sub next_page {
    +        my($q,$counter) = @_;
    +        return undef if $counter >= 10;
    +        return start_html('Test'),
    +               h1('Visible'),"\n",
    +               "This page has been called ", strong($counter)," times",
    +               end_html();
    +    }
    +
    +    sub last_page {
    +        my($q,$counter) = @_;
    +        return start_html('Done'),
    +               h1('Finished'),
    +               strong($counter - 1),' iterations.',
    +               end_html;
    +    }
    +
    +=head1 DESCRIPTION
    +
    +CGI::Push is a subclass of the CGI object created by CGI.pm.  It is
    +specialized for server push operations, which allow you to create
    +animated pages whose content changes at regular intervals.
    +
    +You provide CGI::Push with a pointer to a subroutine that will draw
    +one page.  Every time your subroutine is called, it generates a new
    +page.  The contents of the page will be transmitted to the browser
    +in such a way that it will replace what was there beforehand.  The
    +technique will work with HTML pages as well as with graphics files,
    +allowing you to create animated GIFs.
    +
    +Only Netscape Navigator supports server push.  Internet Explorer
    +browsers do not.
    +
    +=head1 USING CGI::Push
    +
    +CGI::Push adds one new method to the standard CGI suite, do_push().
    +When you call this method, you pass it a reference to a subroutine
    +that is responsible for drawing each new page, an interval delay, and
    +an optional subroutine for drawing the last page.  Other optional
    +parameters include most of those recognized by the CGI header()
    +method.
    +
    +You may call do_push() in the object oriented manner or not, as you
    +prefer:
    +
    +    use CGI::Push;
    +    $q = new CGI::Push;
    +    $q->do_push(-next_page=>\&draw_a_page);
    +
    +        -or-
    +
    +    use CGI::Push qw(:standard);
    +    do_push(-next_page=>\&draw_a_page);
    +
    +Parameters are as follows:
    +
    +=over 4
    +
    +=item -next_page
    +
    +    do_push(-next_page=>\&my_draw_routine);
    +
    +This required parameter points to a reference to a subroutine responsible for
    +drawing each new page.  The subroutine should expect two parameters
    +consisting of the CGI object and a counter indicating the number
    +of times the subroutine has been called.  It should return the
    +contents of the page as an B of one or more items to print.
    +It can return a false value (or an empty array) in order to abort the
    +redrawing loop and print out the final page (if any)
    +
    +    sub my_draw_routine {
    +        my($q,$counter) = @_;
    +        return undef if $counter > 100;
    +        return start_html('testing'),
    +               h1('testing'),
    +               "This page called $counter times";
    +    }
    +
    +You are of course free to refer to create and use global variables
    +within your draw routine in order to achieve special effects.
    +
    +=item -last_page
    +
    +This optional parameter points to a reference to the subroutine
    +responsible for drawing the last page of the series.  It is called
    +after the -next_page routine returns a false value.  The subroutine
    +itself should have exactly the same calling conventions as the
    +-next_page routine.
    +
    +=item -type
    +
    +This optional parameter indicates the content type of each page.  It
    +defaults to "text/html".  Normally the module assumes that each page
    +is of a homogenous MIME type.  However if you provide either of the
    +magic values "heterogeneous" or "dynamic" (the latter provided for the
    +convenience of those who hate long parameter names), you can specify
    +the MIME type -- and other header fields -- on a per-page basis.  See
    +"heterogeneous pages" for more details.
    +
    +=item -delay
    +
    +This indicates the delay, in seconds, between frames.  Smaller delays
    +refresh the page faster.  Fractional values are allowed.
    +
    +B
    +
    +=item -cookie, -target, -expires, -nph
    +
    +These have the same meaning as the like-named parameters in
    +CGI::header().
    +
    +If not specified, -nph will default to 1 (as needed for many servers, see below).
    +
    +=back
    +
    +=head2 Heterogeneous Pages
    +
    +Ordinarily all pages displayed by CGI::Push share a common MIME type.
    +However by providing a value of "heterogeneous" or "dynamic" in the
    +do_push() -type parameter, you can specify the MIME type of each page
    +on a case-by-case basis.
    +
    +If you use this option, you will be responsible for producing the
    +HTTP header for each page.  Simply modify your draw routine to
    +look like this:
    +
    +    sub my_draw_routine {
    +        my($q,$counter) = @_;
    +        return header('text/html'),   # note we're producing the header here
    +               start_html('testing'),
    +               h1('testing'),
    +               "This page called $counter times";
    +    }
    +
    +You can add any header fields that you like, but some (cookies and
    +status fields included) may not be interpreted by the browser.  One
    +interesting effect is to display a series of pages, then, after the
    +last page, to redirect the browser to a new URL.  Because redirect()
    +does b work, the easiest way is with a -refresh header field,
    +as shown below:
    +
    +    sub my_draw_routine {
    +        my($q,$counter) = @_;
    +        return undef if $counter > 10;
    +        return header('text/html'),   # note we're producing the header here
    +               start_html('testing'),
    +               h1('testing'),
    +               "This page called $counter times";
    +    }
    +
    +    sub my_last_page {
    +        return header(-refresh=>'5; URL=http://somewhere.else/finished.html',
    +                      -type=>'text/html'),
    +               start_html('Moved'),
    +               h1('This is the last page'),
    +               'Goodbye!'
    +               hr,
    +               end_html;
    +    }
    +
    +=head2 Changing the Page Delay on the Fly
    +
    +If you would like to control the delay between pages on a page-by-page
    +basis, call push_delay() from within your draw routine.  push_delay()
    +takes a single numeric argument representing the number of seconds you
    +wish to delay after the current page is displayed and before
    +displaying the next one.  The delay may be fractional.  Without
    +parameters, push_delay() just returns the current delay.
    +
    +=head1 INSTALLING CGI::Push SCRIPTS
    +
    +Server push scripts must be installed as no-parsed-header (NPH)
    +scripts in order to work correctly on many servers.  On Unix systems,
    +this is most often accomplished by prefixing the script's name with "nph-".
    +Recognition of NPH scripts happens automatically with WebSTAR and
    +Microsoft IIS.  Users of other servers should see their documentation
    +for help.
    +
    +Apache web server from version 1.3b2 on does not need server
    +push scripts installed as NPH scripts: the -nph parameter to do_push()
    +may be set to a false value to disable the extra headers needed by an
    +NPH script.
    +
    +=head1 AUTHOR INFORMATION
    +
    +Copyright 1995-1998, Lincoln D. Stein.  All rights reserved.
    +
    +This library is free software; you can redistribute it and/or modify
    +it under the same terms as Perl itself.
    +
    +Address bug reports and comments to: lstein@cshl.org
    +
    +=head1 BUGS
    +
    +This section intentionally left blank.
    +
    +=head1 SEE ALSO
    +
    +L, L
    +
    +=cut
    +
    diff --git a/lib/CGI/Switch.pm b/lib/CGI/Switch.pm
    new file mode 100644
    index 0000000..b8cc9ef
    --- /dev/null
    +++ b/lib/CGI/Switch.pm
    @@ -0,0 +1,27 @@
    +use CGI;
    +
    +$VERSION = '1.00';
    +
    +1;
    +
    +__END__
    +
    +=head1 NAME
    +
    +CGI::Switch - Backward compatibility module for defunct CGI::Switch
    +
    +=head1 SYNOPSIS
    +
    +Do not use this module.  It is deprecated.
    +
    +=head1 ABSTRACT
    +
    +=head1 DESCRIPTION
    +
    +=head1 AUTHOR INFORMATION
    +
    +=head1 BUGS
    +
    +=head1 SEE ALSO
    +
    +=cut
    diff --git a/lib/CGI/Util.pm b/lib/CGI/Util.pm
    new file mode 100644
    index 0000000..6af42de
    --- /dev/null
    +++ b/lib/CGI/Util.pm
    @@ -0,0 +1,317 @@
    +package CGI::Util;
    +
    +use strict;
    +use vars qw($VERSION @EXPORT_OK @ISA $EBCDIC @A2E @E2A);
    +require Exporter;
    +@ISA = qw(Exporter);
    +@EXPORT_OK = qw(rearrange make_attributes unescape escape 
    +		expires ebcdic2ascii ascii2ebcdic);
    +
    +$VERSION = '1.5';
    +
    +$EBCDIC = "\t" ne "\011";
    +# (ord('^') == 95) for codepage 1047 as on os390, vmesa
    +@A2E = (
    +   0,  1,  2,  3, 55, 45, 46, 47, 22,  5, 21, 11, 12, 13, 14, 15,
    +  16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31,
    +  64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97,
    + 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111,
    + 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214,
    + 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109,
    + 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150,
    + 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161,  7,
    +  32, 33, 34, 35, 36, 37,  6, 23, 40, 41, 42, 43, 44,  9, 10, 27,
    +  48, 49, 26, 51, 52, 53, 54,  8, 56, 57, 58, 59,  4, 20, 62,255,
    +  65,170, 74,177,159,178,106,181,187,180,154,138,176,202,175,188,
    + 144,143,234,250,190,160,182,179,157,218,155,139,183,184,185,171,
    + 100,101, 98,102, 99,103,158,104,116,113,114,115,120,117,118,119,
    + 172,105,237,238,235,239,236,191,128,253,254,251,252,186,174, 89,
    +  68, 69, 66, 70, 67, 71,156, 72, 84, 81, 82, 83, 88, 85, 86, 87,
    + 140, 73,205,206,203,207,204,225,112,221,222,219,220,141,142,223
    +	 );
    +@E2A = (
    +   0,  1,  2,  3,156,  9,134,127,151,141,142, 11, 12, 13, 14, 15,
    +  16, 17, 18, 19,157, 10,  8,135, 24, 25,146,143, 28, 29, 30, 31,
    + 128,129,130,131,132,133, 23, 27,136,137,138,139,140,  5,  6,  7,
    + 144,145, 22,147,148,149,150,  4,152,153,154,155, 20, 21,158, 26,
    +  32,160,226,228,224,225,227,229,231,241,162, 46, 60, 40, 43,124,
    +  38,233,234,235,232,237,238,239,236,223, 33, 36, 42, 41, 59, 94,
    +  45, 47,194,196,192,193,195,197,199,209,166, 44, 37, 95, 62, 63,
    + 248,201,202,203,200,205,206,207,204, 96, 58, 35, 64, 39, 61, 34,
    + 216, 97, 98, 99,100,101,102,103,104,105,171,187,240,253,254,177,
    + 176,106,107,108,109,110,111,112,113,114,170,186,230,184,198,164,
    + 181,126,115,116,117,118,119,120,121,122,161,191,208, 91,222,174,
    + 172,163,165,183,169,167,182,188,189,190,221,168,175, 93,180,215,
    + 123, 65, 66, 67, 68, 69, 70, 71, 72, 73,173,244,246,242,243,245,
    + 125, 74, 75, 76, 77, 78, 79, 80, 81, 82,185,251,252,249,250,255,
    +  92,247, 83, 84, 85, 86, 87, 88, 89, 90,178,212,214,210,211,213,
    +  48, 49, 50, 51, 52, 53, 54, 55, 56, 57,179,219,220,217,218,159
    +	 );
    +
    +if ($EBCDIC && ord('^') == 106) { # as in the BS2000 posix-bc coded character set
    +     $A2E[91] = 187;   $A2E[92] = 188;  $A2E[94] = 106;  $A2E[96] = 74;
    +     $A2E[123] = 251;  $A2E[125] = 253; $A2E[126] = 255; $A2E[159] = 95;
    +     $A2E[162] = 176;  $A2E[166] = 208; $A2E[168] = 121; $A2E[172] = 186;
    +     $A2E[175] = 161;  $A2E[217] = 224; $A2E[219] = 221; $A2E[221] = 173;
    +     $A2E[249] = 192;
    +
    +     $E2A[74] = 96;   $E2A[95] = 159;  $E2A[106] = 94;  $E2A[121] = 168;
    +     $E2A[161] = 175; $E2A[173] = 221; $E2A[176] = 162; $E2A[186] = 172;
    +     $E2A[187] = 91;  $E2A[188] = 92;  $E2A[192] = 249; $E2A[208] = 166;
    +     $E2A[221] = 219; $E2A[224] = 217; $E2A[251] = 123; $E2A[253] = 125;
    +     $E2A[255] = 126;
    +   }
    +elsif ($EBCDIC && ord('^') == 176) { # as in codepage 037 on os400
    +  $A2E[10] = 37;  $A2E[91] = 186;  $A2E[93] = 187; $A2E[94] = 176;
    +  $A2E[133] = 21; $A2E[168] = 189; $A2E[172] = 95; $A2E[221] = 173;
    +
    +  $E2A[21] = 133; $E2A[37] = 10;  $E2A[95] = 172; $E2A[173] = 221;
    +  $E2A[176] = 94; $E2A[186] = 91; $E2A[187] = 93; $E2A[189] = 168;
    +}
    +
    +# Smart rearrangement of parameters to allow named parameter
    +# calling.  We do the rearangement if:
    +# the first parameter begins with a -
    +sub rearrange {
    +    my($order,@param) = @_;
    +    return () unless @param;
    +
    +    if (ref($param[0]) eq 'HASH') {
    +	@param = %{$param[0]};
    +    } else {
    +	return @param 
    +	    unless (defined($param[0]) && substr($param[0],0,1) eq '-');
    +    }
    +
    +    # map parameters into positional indices
    +    my ($i,%pos);
    +    $i = 0;
    +    foreach (@$order) {
    +	foreach (ref($_) eq 'ARRAY' ? @$_ : $_) { $pos{lc($_)} = $i; }
    +	$i++;
    +    }
    +
    +    my (@result,%leftover);
    +    $#result = $#$order;  # preextend
    +    while (@param) {
    +	my $key = lc(shift(@param));
    +	$key =~ s/^\-//;
    +	if (exists $pos{$key}) {
    +	    $result[$pos{$key}] = shift(@param);
    +	} else {
    +	    $leftover{$key} = shift(@param);
    +	}
    +    }
    +
    +    push (@result,make_attributes(\%leftover,1)) if %leftover;
    +    @result;
    +}
    +
    +sub make_attributes {
    +    my $attr = shift;
    +    return () unless $attr && ref($attr) && ref($attr) eq 'HASH';
    +    my $escape = shift || 0;
    +    my(@att);
    +    foreach (keys %{$attr}) {
    +	my($key) = $_;
    +	$key=~s/^\-//;     # get rid of initial - if present
    +
    +	# old way: breaks EBCDIC!
    +	# $key=~tr/A-Z_/a-z-/; # parameters are lower case, use dashes
    +
    +	($key="\L$key") =~ tr/_/-/; # parameters are lower case, use dashes
    +
    +	my $value = $escape ? simple_escape($attr->{$_}) : $attr->{$_};
    +	push(@att,defined($attr->{$_}) ? qq/$key="$value"/ : qq/$key/);
    +    }
    +    return @att;
    +}
    +
    +sub simple_escape {
    +  return unless defined(my $toencode = shift);
    +  $toencode =~ s{&}{&}gso;
    +  $toencode =~ s{<}{<}gso;
    +  $toencode =~ s{>}{>}gso;
    +  $toencode =~ s{\"}{"}gso;
    +# Doesn't work.  Can't work.  forget it.
    +#  $toencode =~ s{\x8b}{‹}gso;
    +#  $toencode =~ s{\x9b}{›}gso;
    +  $toencode;
    +}
    +
    +sub utf8_chr {
    +        my $c = shift(@_);
    +
    +        if ($c < 0x80) {
    +                return sprintf("%c", $c);
    +        } elsif ($c < 0x800) {
    +                return sprintf("%c%c", 0xc0 | ($c >> 6), 0x80 | ($c & 0x3f));
    +        } elsif ($c < 0x10000) {
    +                return sprintf("%c%c%c",
    +                                           0xe0 |  ($c >> 12),
    +                                           0x80 | (($c >>  6) & 0x3f),
    +                                           0x80 | ( $c          & 0x3f));
    +        } elsif ($c < 0x200000) {
    +                return sprintf("%c%c%c%c",
    +                                           0xf0 |  ($c >> 18),
    +                                           0x80 | (($c >> 12) & 0x3f),
    +                                           0x80 | (($c >>  6) & 0x3f),
    +                                           0x80 | ( $c          & 0x3f));
    +        } elsif ($c < 0x4000000) {
    +                return sprintf("%c%c%c%c%c",
    +                                           0xf8 |  ($c >> 24),
    +                                           0x80 | (($c >> 18) & 0x3f),
    +                                           0x80 | (($c >> 12) & 0x3f),
    +                                           0x80 | (($c >>  6) & 0x3f),
    +                                           0x80 | ( $c          & 0x3f));
    +
    +        } elsif ($c < 0x80000000) {
    +                return sprintf("%c%c%c%c%c%c",
    +                                           0xfc |  ($c >> 30),
    +                                           0x80 | (($c >> 24) & 0x3f),
    +                                           0x80 | (($c >> 18) & 0x3f),
    +                                           0x80 | (($c >> 12) & 0x3f),
    +                                           0x80 | (($c >> 6)  & 0x3f),
    +                                           0x80 | ( $c          & 0x3f));
    +        } else {
    +                return utf8_chr(0xfffd);
    +        }
    +}
    +
    +# unescape URL-encoded data
    +sub unescape {
    +  shift() if @_ > 1 and (ref($_[0]) || (defined $_[1] && $_[0] eq $CGI::DefaultClass));
    +  my $todecode = shift;
    +  return undef unless defined($todecode);
    +  $todecode =~ tr/+/ /;       # pluses become spaces
    +    $EBCDIC = "\t" ne "\011";
    +    if ($EBCDIC) {
    +      $todecode =~ s/%([0-9a-fA-F]{2})/chr $A2E[hex($1)]/ge;
    +    } else {
    +      $todecode =~ s/%(?:([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/
    +	defined($1)? chr hex($1) : utf8_chr(hex($2))/ge;
    +    }
    +  return $todecode;
    +}
    +
    +# URL-encode data
    +sub escape {
    +  shift() if @_ > 1 and ( ref($_[0]) || (defined $_[1] && $_[0] eq $CGI::DefaultClass));
    +  my $toencode = shift;
    +  return undef unless defined($toencode);
    +  # force bytes while preserving backward compatibility -- dankogai
    +  $toencode = pack("C*", unpack("C*", $toencode));
    +    if ($EBCDIC) {
    +      $toencode=~s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",$E2A[ord($1)])/eg;
    +    } else {
    +      $toencode=~s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg;
    +    }
    +  return $toencode;
    +}
    +
    +# This internal routine creates date strings suitable for use in
    +# cookies and HTTP headers.  (They differ, unfortunately.)
    +# Thanks to Mark Fisher for this.
    +sub expires {
    +    my($time,$format) = @_;
    +    $format ||= 'http';
    +
    +    my(@MON)=qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
    +    my(@WDAY) = qw/Sun Mon Tue Wed Thu Fri Sat/;
    +
    +    # pass through preformatted dates for the sake of expire_calc()
    +    $time = expire_calc($time);
    +    return $time unless $time =~ /^\d+$/;
    +
    +    # make HTTP/cookie date string from GMT'ed time
    +    # (cookies use '-' as date separator, HTTP uses ' ')
    +    my($sc) = ' ';
    +    $sc = '-' if $format eq "cookie";
    +    my($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime($time);
    +    $year += 1900;
    +    return sprintf("%s, %02d$sc%s$sc%04d %02d:%02d:%02d GMT",
    +                   $WDAY[$wday],$mday,$MON[$mon],$year,$hour,$min,$sec);
    +}
    +
    +# This internal routine creates an expires time exactly some number of
    +# hours from the current time.  It incorporates modifications from 
    +# Mark Fisher.
    +sub expire_calc {
    +    my($time) = @_;
    +    my(%mult) = ('s'=>1,
    +                 'm'=>60,
    +                 'h'=>60*60,
    +                 'd'=>60*60*24,
    +                 'M'=>60*60*24*30,
    +                 'y'=>60*60*24*365);
    +    # format for time can be in any of the forms...
    +    # "now" -- expire immediately
    +    # "+180s" -- in 180 seconds
    +    # "+2m" -- in 2 minutes
    +    # "+12h" -- in 12 hours
    +    # "+1d"  -- in 1 day
    +    # "+3M"  -- in 3 months
    +    # "+2y"  -- in 2 years
    +    # "-3m"  -- 3 minutes ago(!)
    +    # If you don't supply one of these forms, we assume you are
    +    # specifying the date yourself
    +    my($offset);
    +    if (!$time || (lc($time) eq 'now')) {
    +        $offset = 0;
    +    } elsif ($time=~/^\d+/) {
    +        return $time;
    +    } elsif ($time=~/^([+-]?(?:\d+|\d*\.\d*))([mhdMy]?)/) {
    +        $offset = ($mult{$2} || 1)*$1;
    +    } else {
    +        return $time;
    +    }
    +    return (time+$offset);
    +}
    +
    +sub ebcdic2ascii {
    +  my $data = shift;
    +  $data =~ s/(.)/chr $E2A[ord($1)]/ge;
    +  $data;
    +}
    +
    +sub ascii2ebcdic {
    +  my $data = shift;
    +  $data =~ s/(.)/chr $A2E[ord($1)]/ge;
    +  $data;
    +}
    +
    +1;
    +
    +__END__
    +
    +=head1 NAME
    +
    +CGI::Util - Internal utilities used by CGI module
    +
    +=head1 SYNOPSIS
    +
    +none
    +
    +=head1 DESCRIPTION
    +
    +no public subroutines
    +
    +=head1 AUTHOR INFORMATION
    +
    +Copyright 1995-1998, Lincoln D. Stein.  All rights reserved.  
    +
    +This library is free software; you can redistribute it and/or modify
    +it under the same terms as Perl itself.
    +
    +Address bug reports and comments to: lstein@cshl.org.  When sending
    +bug reports, please provide the version of CGI.pm, the version of
    +Perl, the name and version of your Web server, and the name and
    +version of the operating system you are using.  If the problem is even
    +remotely browser dependent, please provide information about the
    +affected browers as well.
    +
    +=head1 SEE ALSO
    +
    +L
    +
    +=cut
    diff --git a/lib/Class/MakeMethods.pm b/lib/Class/MakeMethods.pm
    new file mode 100644
    index 0000000..2865a4c
    --- /dev/null
    +++ b/lib/Class/MakeMethods.pm
    @@ -0,0 +1,1520 @@
    +### Class::MakeMethods
    +  # Copyright 2002, 2003 Matthew Simon Cavalletto
    +  # See documentation, license, and other information after _END_.
    +
    +package Class::MakeMethods;
    +
    +require 5.00307; # for the UNIVERSAL::isa method.
    +use strict;
    +use Carp;
    +
    +use vars qw( $VERSION );
    +$VERSION = 1.010;
    +
    +use vars qw( %CONTEXT %DIAGNOSTICS );
    +
    +########################################################################
    +### MODULE IMPORT: import(), _import_version()
    +########################################################################
    +
    +sub import {
    +  my $class = shift;
    +
    +  if ( scalar @_ and $_[0] =~ m/^\d/ ) {
    +    $class->_import_version( shift );
    +  }
    +  
    +  if ( scalar @_ == 1 and $_[0] eq '-isasubclass' ) {
    +    shift;
    +    my $target_class = ( caller )[0];
    +    no strict;
    +    push @{"$target_class\::ISA"}, $class;
    +  }
    +  
    +  $class->make( @_ ) if ( scalar @_ );
    +}
    +
    +sub _import_version {
    +  my $class = shift;
    +  my $wanted = shift;
    +  
    +  no strict;
    +  my $version = ${ $class.'::VERSION '};
    +  
    +  # If passed a version number, ensure that we measure up.
    +  # Based on similar functionality in Exporter.pm
    +  if ( ! $version or $version < $wanted ) {
    +    my $file = "$class.pm";
    +    $file =~ s!::!/!g;
    +    $file = $INC{$file} ? " ($INC{$file})" : '';
    +    _diagnostic('mm_version_fail', $class, $wanted, $version || '(undef)', $file);
    +  }
    +}
    +
    +########################################################################
    +### METHOD GENERATION: make()
    +########################################################################
    +
    +sub make {
    +  local $CONTEXT{MakerClass} = shift;
    +  
    +  # Find the first class in the caller() stack that's not a subclass of us 
    +  local $CONTEXT{TargetClass};
    +  my $i = 0;
    +  do {
    +    $CONTEXT{TargetClass} = ( caller($i ++) )[0];
    +  } while UNIVERSAL::isa($CONTEXT{TargetClass}, __PACKAGE__ );
    +  
    +  my @methods;
    +  
    +  # For compatibility with 5.004, which fails to splice use's constant @_
    +  my @declarations = @_; 
    +  
    +  if (@_ % 2) { _diagnostic('make_odd_args', $CONTEXT{MakerClass}); }
    +  while ( scalar @declarations ) {
    +    # The list passed to import should alternate between the names of the
    +    # meta-method to call to generate the methods, and arguments to it.
    +    my ($name, $args) = splice(@declarations, 0, 2);
    +    unless ( defined $name ) {
    +      croak "Undefined name";
    +    }
    +    
    +    # Leading dash on the first argument of a pair means it's a
    +    # global/general option to be stored in CONTEXT.
    +    if ( $name =~ s/^\-// ) {
    +      
    +      # To prevent difficult-to-predict retroactive behaviour, start by
    +      # flushing any pending methods before letting settings take effect
    +      if ( scalar @methods ) { 
    +	_install_methods( $CONTEXT{MakerClass}, @methods );
    +	@methods = ();
    +      }
    +      
    +      if ( $name eq 'MakerClass' ) {
    +	# Switch base package for remainder of args
    +	$CONTEXT{MakerClass} = _find_subclass($CONTEXT{MakerClass}, $args);
    +      } else {
    +	$CONTEXT{$name} = $args;
    +      }
    +      
    +      next;
    +    }
    +    
    +    # Argument normalization
    +    my @args = (
    +      ! ref($args) ? split(' ', $args) : # If a string, it is split on spaces.
    +      ref($args) eq 'ARRAY' ? (@$args) : # If an arrayref, use its contents.
    +      ( $args )     			 # If a hashref, it is used directly
    +    );
    +
    +    # If the type argument contains an array of method types, do the first
    +    # now, and put the others back in the queue to be processed subsequently.
    +    if ( ref($name) eq 'ARRAY' ) {	
    +      ($name, my @name) = @$name;	
    +      unshift @declarations, map { $_=>[@args] } @name;
    +    }
    +    
    +    # If the type argument contains space characters, use the first word
    +    # as the type, and prepend the remaining items to the argument list.
    +    if ( $name =~ /\s/ ) {
    +      my @items = split ' ', $name;
    +      $name = shift( @items );
    +      unshift @args, @items;
    +    }
    +    
    +    # If name contains a colon or double colon, treat the preceeding part 
    +    # as the subclass name but only for this one set of methods.
    +    local $CONTEXT{MakerClass} = _find_subclass($CONTEXT{MakerClass}, $1)
    +		if ($name =~ s/^(.*?)\:{1,2}(\w+)$/$2/);
    +    
    +    # Meta-method invocation via named_method or direct method call
    +    my @results = (
    +	$CONTEXT{MakerClass}->can('named_method') ? 
    +			$CONTEXT{MakerClass}->named_method( $name, @args ) : 
    +	$CONTEXT{MakerClass}->can($name) ?
    +			$CONTEXT{MakerClass}->$name( @args ) : 
    +	    croak "Can't generate $CONTEXT{MakerClass}->$name() methods"
    +    );
    +    # warn "$CONTEXT{MakerClass} $name - ", join(', ', @results) . "\n";
    +    
    +    ### A method-generator may be implemented in any of the following ways:
    +    
    +    # SELF-CONTAINED: It may return nothing, if there are no methods
    +    # to install, or if it has installed the methods itself.
    +    # (We also accept a single false value, for backward compatibility 
    +    # with generators that are written as foreach loops, which return ''!)
    +    if ( ! scalar @results or scalar @results == 1 and ! $results[0] ) { } 
    +    
    +    # ALIAS: It may return a string containing a meta-method type to run 
    +    # instead. Put the arguments back in the queue and go through again.
    +    elsif ( scalar @results == 1 and ! ref $results[0]) {
    +      unshift @declarations, $results[0], \@args;
    +    } 
    +    
    +    # REWRITER: It may return one or more array reference containing a meta-
    +    # method type and arguments which should be created to complete this 
    +    # request. Put the arguments back in the queue and go through again.
    +    elsif ( ! grep { ref $_ ne 'ARRAY' } @results ) {
    +      unshift @declarations, ( map { shift(@$_), $_ } @results );
    +    } 
    +    
    +    # CODE REFS: It may provide a list of name, code pairs to install
    +    elsif ( ! scalar @results % 2 and ! ref $results[0] ) {
    +      push @methods, @results;
    +    } 
    +    
    +    # GENERATOR OBJECT: It may return an object reference which will construct
    +    # the relevant methods.
    +    elsif ( UNIVERSAL::can( $results[0], 'make_methods' ) ) {
    +      push @methods, ( shift @results )->make_methods(@results, @args);
    +    } 
    +    
    +    else {
    +      _diagnostic('make_bad_meta', $name, join(', ', map "'$_'", @results));
    +    }
    +  }
    +  
    +  _install_methods( $CONTEXT{MakerClass}, @methods );
    +  
    +  return;
    +}
    +
    +########################################################################
    +### DECLARATION PARSING: _get_declarations()
    +########################################################################
    +
    +sub _get_declarations {
    +  my $class = shift;
    +  
    +  my @results;
    +  my %defaults;
    +  
    +  while (scalar @_) {
    +    my $m_name = shift @_;
    +    if ( ! defined $m_name or ! length $m_name ) {
    +      _diagnostic('make_empty') 
    +    }
    +
    +    # Various forms of default parameters
    +    elsif ( substr($m_name, 0, 1) eq '-' ) {
    +      if ( substr($m_name, 1, 1) ne '-' ) {
    +	# Parse default values in the format "-param => value"
    +	$defaults{ substr($m_name, 1) } = shift @_;
    +      } elsif ( length($m_name) == 2 ) {
    +	# Parse hash of default values in the format "-- => { ... }"
    +	ref($_[0]) eq 'HASH' or _diagnostic('make_unsupported', $m_name.$_[0]);
    +	%defaults = ( %defaults, %{ shift @_ } );
    +      } else {
    +	# Parse "special" arguments in the format "--foobar"
    +	$defaults{ '--' } .= $m_name;
    +      }
    +    }
    +    
    +    # Parse string and string-then-hash declarations
    +    elsif ( ! ref $m_name ) {  
    +      if ( scalar @_ and ref $_[0] eq 'HASH' and ! exists $_[0]->{'name'} ) {
    +	push @results, { %defaults, 'name' => $m_name, %{ shift @_ } };
    +      } else {
    +	push @results, { %defaults, 'name' => $m_name };
    +      }
    +    } 
    +    
    +    # Parse hash-only declarations
    +    elsif ( ref $m_name eq 'HASH' ) {
    +      if ( length $m_name->{'name'} ) {
    +	push @results, { %defaults, %$m_name };
    +      } else {
    +	_diagnostic('make_noname');
    +      }
    +    }
    +    
    +    # Normalize: If we've got an array of names, replace it with those names 
    +    elsif ( ref $m_name eq 'ARRAY' ) {
    +      my @items = @{ $m_name };
    +      # If array is followed by an params hash, each one gets the same params
    +      if ( scalar @_ and ref $_[0] eq 'HASH' and ! exists $_[0]->{'name'} ) {
    +	my $params = shift;
    +	@items = map { $_, $params } @items
    +      }
    +      unshift @_, @items;
    +      next;
    +    }
    +    
    +    else {
    +      _diagnostic('make_unsupported', $m_name);
    +    }
    +    
    +  }
    +  
    +  return @results;
    +}
    +
    +########################################################################
    +### FUNCTION INSTALLATION: _install_methods()
    +########################################################################
    +
    +sub _install_methods {
    +  my ($class, %methods) = @_;
    +  
    +  no strict 'refs';
    +  
    +  # print STDERR "CLASS: $class\n";
    +  my $package = $CONTEXT{TargetClass};
    +  
    +  my ($name, $code);
    +  while (($name, $code) = each %methods) {
    +    
    +    # Skip this if the target package already has a function by the given name.
    +    next if ( ! $CONTEXT{ForceInstall} and 
    +				defined *{$package. '::'. $name}{CODE} );
    +   
    +    if ( ! ref $code ) {
    +      local $SIG{__DIE__};
    +      local $^W;
    +      my $coderef = eval $code;
    +      if ( $@ ) {
    +	_diagnostic('inst_eval_syntax', $name, $@, $code);
    +      } elsif ( ref $coderef ne 'CODE' ) {
    +	_diagnostic('inst_eval_result', $name, $coderef, $code);
    +      }
    +      $code = $coderef;
    +    } elsif ( ref $code ne 'CODE' ) {
    +      _diagnostic('inst_result', $name, $code);
    +    }
    +    
    +    # Add the code refence to the target package
    +    # _diagnostic('debug_install', $package, $name, $code);
    +    local $^W = 0 if ( $CONTEXT{ForceInstall} );
    +    *{$package . '::' . $name} = $code;
    +
    +  }
    +  return;
    +}
    +
    +########################################################################
    +### SUBCLASS LOADING: _find_subclass()
    +########################################################################
    +
    +# $pckg = _find_subclass( $class, $optional_package_name );
    +sub _find_subclass {
    +  my $class = shift; 
    +  my $package = shift or die "No package for _find_subclass";
    +  
    +  $package =  $package =~ s/^::// ? $package :
    +		"Class::MakeMethods::$package";
    +  
    +  (my $file = $package . '.pm' ) =~ s|::|/|go;
    +  return $package if ( $::INC{ $file } );
    +  
    +  no strict 'refs';
    +  return $package if ( @{$package . '::ISA'} );
    +  
    +  local $SIG{__DIE__} = '';
    +  eval { require $file };
    +  $::INC{ $package } = $::INC{ $file };
    +  if ( $@ ) { _diagnostic('mm_package_fail', $package, $@) }
    +  
    +  return $package
    +}
    +
    +########################################################################
    +### CONTEXT: _context(), %CONTEXT
    +########################################################################
    +
    +sub _context {
    +  my $class = shift; 
    +  return %CONTEXT if ( ! scalar @_ );
    +  my $key = shift;
    +  return $CONTEXT{$key} if ( ! scalar @_ );
    +  $CONTEXT{$key} = shift;
    +}
    +
    +BEGIN {
    +  $CONTEXT{Debug} ||= 0;
    +}
    +
    +########################################################################
    +### DIAGNOSTICS: _diagnostic(), %DIAGNOSTICS
    +########################################################################
    +
    +sub _diagnostic {
    +  my $case = shift;
    +  my $message = $DIAGNOSTICS{$case};
    +  $message =~ s/\A\s*\((\w)\)\s*//;
    +  my $severity = $1 || 'I';
    +  if ( $severity eq 'Q' ) {
    +    carp( sprintf( $message, @_ ) ) if ( $CONTEXT{Debug} );
    +  } elsif ( $severity eq 'W' ) {
    +    carp( sprintf( $message, @_ ) ) if ( $^W );
    +  } elsif ( $severity eq 'F' ) {
    +    croak( sprintf( $message, @_ ) )
    +  } else {
    +    confess( sprintf( $message, @_ ) )
    +  }
    +}
    +
    +
    +BEGIN { %DIAGNOSTICS = (
    +
    +  ### BASE CLASS DIAGNOSTICS
    +  
    +  # _diagnostic('debug_install', $package, $name, $code)
    +  debug_install => q|(W) Installing function %s::%s (%s)|,
    +  
    +  # _diagnostic('make_odd_args', $CONTEXT{MakerClass})
    +  make_odd_args => q|(F) Odd number of arguments passed to %s method generator|,
    +  
    +  # _diagnostic('make_bad_meta', $name, join(', ', map "'$_'", @results)
    +  make_bad_meta => q|(I) Unexpected return value from method constructor %s: %s|,
    +  
    +  # _diagnostic('inst_eval_syntax', $name, $@, $code)
    +  inst_eval_syntax => q|(I) Unable to compile generated method %s(): %s| . 
    +      qq|\n  (There's probably a syntax error in this generated code.)\n%s\n|,
    +  
    +  # _diagnostic('inst_eval_result', $name, $coderef, $code)
    +  inst_eval_result => q|(I) Unexpected return value from compilation of %s(): '%s'| . 
    +      qq|\n  (This generated code should have returned a code ref.)\n%s\n|,
    +  
    +  # _diagnostic('inst_result', $name, $code)
    +  inst_result => q|(I) Unable to install code for %s() method: '%s'|,
    +  
    +  # _diagnostic('mm_package_fail', $package, $@)
    +  mm_package_fail => q|(F) Unable to dynamically load %s: %s|,
    +  
    +  # _diagnostic('mm_version_fail', $class, $wanted, $version || '(undef)
    +  mm_version_fail => q|(F) %s %s required--this is only version %s%s|,
    +  
    +  ### STANDARD SUBCLASS DIAGNOSTICS
    +  
    +  # _diagnostic('make_empty')
    +  make_empty => q|(F) Can't parse meta-method declaration: argument is empty or undefined|,
    +  
    +  # _diagnostic('make_noname')
    +  make_noname => q|(F) Can't parse meta-method declaration: missing name attribute.| . 
    +      qq|\n  (Perhaps a trailing attributes hash has become separated from its name?)|,
    +  
    +  # _diagnostic('make_unsupported', $m_name)
    +  make_unsupported => q|(F) Can't parse meta-method declaration: unsupported declaration type '%s'|,
    +  
    +  ### TEMPLATE SUBCLASS DIAGNOSTICS 
    +    # ToDo: Should be moved to the Class::MakeMethods::Template package
    +  
    +  debug_declaration => q|(Q) Meta-method declaration parsed: %s|,
    +  debug_make_behave => q|(Q) Building meta-method behavior %s: %s(%s)|,
    +  mmdef_not_interpretable => qq|(I) Not an interpretable meta-method: '%s'| .
    +      qq|\n  (Perhaps a meta-method attempted to import from a non-templated meta-method?)|,
    +  make_bad_modifier => q|(F) Can't parse meta-method declaration: unknown option for %s: %s|,
    +  make_bad_behavior => q|(F) Can't make method %s(): template specifies unknown behavior '%s'|,
    +  behavior_mod_unknown => q|(F) Unknown modification to %s behavior: -%s|,
    +  debug_template_builder => qq|(Q) Template interpretation for %s:\n%s|.
    +      qq|\n---------\n%s\n---------\n|,
    +  debug_template => q|(Q) Parsed template '%s': %s|,
    +  debug_eval_builder => q|(Q) Compiling behavior builder '%s':| . qq|\n%s|,
    +  make_behavior_mod => q|(F) Can't apply modifiers (%s) to code behavior %s|,
    +  behavior_eval => q|(I) Class::MakeMethods behavior compilation error: %s| . 
    +      qq|\n  (There's probably a syntax error in the below code.)\n%s|,
    +  tmpl_unkown => q|(F) Can't interpret meta-method template: unknown template name '%s'|,
    +  tmpl_empty => q|(F) Can't interpret meta-method template: argument is empty or undefined|,
    +  tmpl_unsupported => q|(F) Can't interpret meta-method template: unsupported template type '%s'|,
    +) }
    +
    +1;
    +
    +__END__
    +
    +
    +=head1 NAME
    +
    +Class::MakeMethods - Generate common types of methods
    +
    +
    +=head1 SYNOPSIS
    +
    +  # Generates methods for your object when you "use" it.
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Hash (
    +    'new'       => 'new',
    +    'scalar'    => 'foo',
    +    'scalar'    => 'bar',
    +  );
    +  
    +  # The generated methods can be called just like normal ones
    +  my $obj = MyObject->new( foo => "Foozle", bar => "Bozzle" );
    +  print $obj->foo();
    +  $obj->bar("Barbados");
    +
    +
    +=head1 DESCRIPTION
    +
    +The Class::MakeMethods framework allows Perl class developers to
    +quickly define common types of methods. When a module Cs
    +Class::MakeMethods or one of its subclasses, it can select from a
    +variety of supported method types, and specify a name for each
    +method desired. The methods are dynamically generated and installed
    +in the calling package.
    +
    +Construction of the individual methods is handled by subclasses.
    +This delegation approach allows for a wide variety of method-generation
    +techniques to be supported, each by a different subclass. Subclasses
    +can also be added to provide support for new types of methods.
    +
    +Over a dozen subclasses are available, including implementations of
    +a variety of different method-generation techniques. Each subclass
    +generates several types of methods, with some supporting their own
    +open-eneded extension syntax, for hundreds of possible combinations
    +of method types.
    +
    +
    +=head1 GETTING STARTED
    +
    +=head2 Motivation
    +
    +  "Make easy things easier."
    +
    +This module addresses a problem encountered in object-oriented
    +development wherein numerous methods are defined which differ only
    +slightly from each other.
    +
    +A common example is accessor methods for hash-based object attributes,
    +which allow you to get and set the value $self-E{'foo'} by
    +calling a method $self-Efoo().
    +
    +These methods are generally quite simple, requiring only a couple
    +of lines of Perl, but in sufficient bulk, they can cut down on the
    +maintainability of large classes.
    +
    +Class::MakeMethods allows you to simply declare those methods to
    +be of a predefined type, and it generates and installs the necessary
    +methods in your package at compile-time.
    +
    +=head2 A Contrived Example
    +
    +Object-oriented Perl code is widespread -- you've probably seen code like the below a million times:
    +
    +  my $obj = MyStruct->new( foo=>"Foozle", bar=>"Bozzle" );
    +  if ( $obj->foo() =~ /foo/i ) {
    +    $obj->bar("Barbados!");
    +  }
    +  print $obj->summary();
    +
    +(If this doesn't look familiar, take a moment to read L
    +and you'll soon learn more than's good for you.)
    +
    +Typically, this involves creating numerous subroutines that follow
    +a handful of common patterns, like constructor methods and accessor
    +methods. The classic example is accessor methods for hash-based
    +object attributes, which allow you to get and set the value
    +I-E{I} by calling a method I-EI().
    +These methods are generally quite simple, requiring only a couple
    +of lines of Perl, but in sufficient bulk, they can cut down on the
    +maintainability of large classes.
    +
    +Here's a possible implementation for the class whose interface is
    +shown above:
    +
    +  package MyStruct;
    +  
    +  sub new {
    +    my $callee = shift;
    +    my $self = bless { @_ }, (ref $callee || $callee);
    +    return $self;
    +  }
    +
    +  sub foo {
    +    my $self = shift;
    +    if ( scalar @_ ) {
    +      $self->{'foo'} = shift();
    +    } else {
    +      $self->{'foo'}
    +    }
    +  }
    +
    +  sub bar {
    +    my $self = shift;
    +    if ( scalar @_ ) {
    +      $self->{'bar'} = shift();
    +    } else {
    +      $self->{'bar'}
    +    }
    +  }
    +
    +  sub summary {
    +    my $self = shift;
    +    join(', ', map { "\u$_: " . $self->$_() } qw( foo bar ) )
    +  }
    +
    +Note in particular that the foo and bar methods are almost identical,
    +and that the new method could be used for almost any class; this
    +is precisely the type of redundancy Class::MakeMethods addresses.
    +
    +Class::MakeMethods allows you to simply declare those methods to
    +be of a predefined type, and it generates and installs the necessary
    +methods in your package at compile-time.
    +
    +Here's the equivalent declaration for that same basic class:
    +
    +  package MyStruct;
    +  use Class::MakeMethods::Standard::Hash (
    +    'new'       => 'new',
    +    'scalar'    => 'foo',
    +    'scalar'    => 'bar',
    +  );
    +  
    +  sub summary {
    +    my $self = shift;
    +    join(', ', map { "\u$_: " . $self->$_() } qw( foo bar ) )
    +  }
    +
    +This is the basic purpose of Class::MakeMethods: The "boring" pieces
    +of code have been replaced by succinct declarations, placing the
    +focus on the "unique" or "custom" pieces.
    +
    +=head2 Finding the Method Types You Need
    +
    +Once you've grasped the basic idea -- simplifying repetitive code
    +by generating and installing methods on demand -- the remaining
    +complexity basically boils down to figuring out which arguments to
    +pass to generate the specific methods you want.
    +
    +Unfortunately, this is not a trivial task, as there are dozens of
    +different types of methods that can be generated, each with a
    +variety of options, and several alternative ways to write each
    +method declaration. You may prefer to start by just finding a few
    +examples that you can modify to accomplish your immediate needs,
    +and defer investigating all of the extras until you're ready to
    +take a closer look.
    +
    +=head2 Other Documentation
    +
    +The remainder of this document focuses on points of usage that are
    +common across all subclasses, and describes how to create your own
    +subclasses.
    +
    +If this is your first exposure to Class::MakeMethods, you may want
    +to skim over the rest of this document, then take a look at the
    +examples and one or two of the method-generating subclasses to get
    +a more concrete sense of typical usage, before returning to the
    +details presented below.
    +
    +=over 4
    +
    +=item *
    +
    +A collection of sample uses is available in
    +L.
    +
    +=item *
    +
    +Some of the most common object and class methods are available from 
    +L,
    +L and
    +L.
    +
    +=item *
    +
    +If you need a bit more flexibility, see L
    +for method generators which offer more customization options,
    +including pre- and post-method callback hooks.
    +
    +=item *
    +
    +For the largest collection of methods and options, see
    +L, which uses a system of dynamic
    +code generation to allow endless variation.
    +
    +=item *
    +
    +A listing of available method types from each of the different
    +subclasses is provided in L.
    +
    +=back
    +
    +=head1 CLASS ARCHITECTURE
    +
    +Because there are so many common types of methods one might wish
    +to generate, the Class::MakeMethods framework provides an extensible
    +system based on subclasses.
    +
    +When your code requests a method, the MakeMethods base class performs
    +some standard argument parsing, delegates the construction of the
    +actual method to the appropriate subclass, and then installs whatever
    +method the subclass returns.
    +
    +=head2 The MakeMethods Base Class
    +
    +The Class::MakeMethods package defines a superclass for method-generating
    +modules, and provides a calling convention, on-the-fly subclass
    +loading, and subroutine installation that will be shared by all
    +subclasses.
    +
    +The superclass also lets you generate several different types of
    +methods in a single call, and will automatically load named subclasses
    +the first time they're used.
    +
    +=head2 The Method Generator Subclasses
    +
    +The type of method that gets created is controlled by the specific
    +subclass and generator function you request. For example,
    +C has a generator function
    +C, which is responsible for generating simple scalar-accessor
    +methods for blessed-hash objects.
    +
    +Each generator function specified is passed the arguments specifying
    +the method the caller wants, and produces a closure or eval-able
    +sequence of Perl statements representing the ready-to-install
    +function.
    +
    +=head2 Included Subclasses
    +
    +Because each subclass defines its own set of method types and
    +customization options, a key step is to find your way to the
    +appropriate subclasses.
    +
    +=over 4 
    +
    +=item Standard (See L.)
    +
    +Generally you will want to begin with the Standard::Hash subclass,
    +to create constructor and accessor methods for working with
    +blessed-hash objects (or you might choose the Standard::Array
    +subclass instead).  The Standard::Global subclass provides methods
    +for class data shared by all objects in a class.
    +
    +Each Standard method declaration can optionally include a hash of
    +associated parameters, which allows you to tweak some of the
    +characteristics of the methods. Subroutines are bound as closures
    +to a hash of each method's name and parameters. Standard::Hash and
    +Standard::Array provide object constructor and accessors. The
    +Standard::Global provides for static data shared by all instances
    +and subclasses, while the data for Standard::Inheritable methods
    +trace the inheritance tree to find values, and can be overriden
    +for any subclass or instance.
    +
    +=item Composite (See L.)
    +
    +For additional customization options, check out the Composite
    +subclasses, which allow you to select from a more varied set of
    +implementations and which allow you to adjust any specific method
    +by adding your own code-refs to be run before or after it.
    +
    +Subroutines are bound as closures to a hash of each method's name
    +and optional additional data, and to one or more subroutine references
    +which make up the composite behavior of the method. Composite::Hash
    +and Composite::Array provide object constructor and accessors. The
    +Composite::Global provides for static data shared by all instances
    +and subclasses, while the data for Composite::Inheritable methods
    +can be overriden for any subclass or instance.
    +
    +=item Template (See L.)
    +
    +The Template subclasses provide an open-ended structure for objects
    +that assemble Perl code on the fly into cachable closure-generating
    +subroutines; if the method you need isn't included, you can extend
    +existing methods by re-defining just the snippet of code that's
    +different.
    +
    +Class::MakeMethods::Template extends MakeMethods with a text
    +templating system that can assemble Perl code fragments into a
    +desired subroutine. The code for generated methods is eval'd once
    +for each type, and then repeatedly bound as closures to method-specific
    +data for better performance.
    +
    +Templates for dozens of types of constructor, accessor, and mutator
    +methods are included, ranging from from the mundane (constructors
    +and value accessors for hash and array slots) to the esoteric
    +(inheritable class data and "inside-out" accessors with external
    +indexes).
    +
    +=item Basic (See L.)
    +
    +The Basic subclasses provide stripped down method generators with
    +no configurable options, for minimal functionality (and minimum
    +overhead).
    +
    +Subroutines are bound as closures to the name of each method.
    +Basic::Hash and Basic::Array provide simple object constructors
    +and accessors. Basic::Global provides basic global-data accessors.
    +
    +=item Emulators (See L.)
    +
    +In several cases, Class::MakeMethods provides functionality closely
    +equivalent to that of an existing module, and it is simple to map
    +the existing module's interface to that of Class::MakeMethods.
    +
    +Emulators are included for Class::MethodMaker, Class::Accessor::Fast,
    +Class::Data::Inheritable, Class::Singleton, and Class::Struct, each
    +of which passes the original module's test suite, usually requiring
    +only that the name of the module be changed.
    +
    +=item Extending
    +
    +Class::MakeMethods can be extended by creating subclasses that
    +define additional method-generation functions. Callers can then
    +specify the name of your subclass and generator function in their
    +C statements and your function will be
    +invoked to produce the required closures. See L for
    +more information.
    +
    +=back
    +
    +=head2 Naming Convention for Generated Method Types
    +
    +Method generation functions in this document are often referred to using the 'I:I' or 'I::I:I' naming conventions. As you will see, these are simply the names of Perl packages and the names of functions that are contained in those packages.
    +
    +The included subclasses are grouped into several major groups, so the names used by the included subclasses and method types reflect three axes of variation, "I::I:I":
    +
    +=over 4
    +
    +=item Maker Group
    +
    +Each group shares a similar style of technical implementation and level of complexity. For example, the C packages are all simple, while the C packages all support pre- and post-conditions.
    +
    +(For a listing of the four main groups of included subclasses, see L<"/Included Subclasses">.)
    +
    +=item Maker Subclass
    +
    +Each subclass generates methods for a similar level of scoping or underlying object type. For example, the C<*::Hash> packages all make methods for objects based on blessed hashes, while the C<*::Global> packages make methods that access class-wide data that will be shared between all objects in a class.
    +
    +=item Method Type
    +
    +Each method type produces a similar type of constructor or accessor. For examples, the C<*:new> methods are all constructors, while the C<::scalar> methods are all accessors that allow you to get and set a single scalar value.
    +
    +=back
    +
    +Bearing that in mind, you should be able to guess the intent of many of the method types based on their names alone; when you see "Standard::Hash:scalar" you can read it as "a type of method to access a I value stored in a I-based object, with a I implementation style" and know that it's going to call the scalar() function in the Class::MakeMethods::Standard::Hash package to generate the requested method.
    +
    +
    +=head1 USAGE
    +
    +The supported method types, and the kinds of arguments they expect, vary from subclass to subclass; see the documentation of each subclass for details. 
    +
    +However, the features described below are applicable to all subclasses.
    +
    +=head2 Invocation
    +
    +Methods are dynamically generated and installed into the calling
    +package when you C or one of its
    +subclasses, or if you later call Cmake(...)>.
    +
    +The arguments to C or C should be pairs of a generator
    +type name and an associated array of method-name arguments to pass to
    +the generator. 
    +
    +=over 4
    +
    +=item *
    +
    +use Class::MakeMethods::I ( 
    +    'I' => [ I ], I<...>
    +  );
    +
    +=item *
    +
    +Class::MakeMethods::I->make ( 
    +    'I' => [ I ], I<...>
    +  );
    +
    +=back
    +
    +You may select a specific subclass of Class::MakeMethods for
    +a single generator-type/argument pair by prefixing the type name
    +with a subclass name and a colon.
    +
    +=over 4
    +
    +=item *
    +
    +use Class::MakeMethods ( 
    +    'I:I' => [ I ], I<...>
    +  );
    +
    +=item *
    +
    +Class::MakeMethods->make ( 
    +    'I:I' => [ I ], I<...>
    +  );
    +
    +=back
    +
    +The difference between C and C is primarily one of precedence; the C keyword acts as a BEGIN block, and is thus evaluated before C would be. (See L for additional discussion of this issue.)
    +
    +=head2 Alternative Invocation
    +
    +If you want methods to be declared at run-time when a previously-unknown
    +method is invoked, see L.
    +
    +=over 4
    +
    +=item *
    +
    +use Class::MakeMethods::Autoload 'I:I';
    +
    +=back
    +
    +If you are using Perl version 5.6 or later, see
    +L for an additional declaration
    +syntax for generated methods.
    +
    +=over 4
    +
    +=item *
    +
    +use Class::MakeMethods::Attribute 'I';
    +
    +sub I :MakeMethod('I' => I);
    +
    +=back
    +
    +=head2 About Precedence
    +
    +Rather than passing the method declaration arguments when you C one of these packages, you may instead pass them to a subsequent call to the class method C. 
    +
    +The difference between C and C is primarily one of precedence; the C keyword acts as a BEGIN block, and is thus evaluated before C would be. In particular, a C at the top of a file will be executed before any subroutine declarations later in the file have been seen, whereas a C at the same point in the file will not. 
    +
    +By default, Class::MakeMethods will not install generated methods over any pre-existing methods in the target class. To override this you can pass C<-ForceInstall =E 1> as initial arguments to C or C. 
    +
    +If the same method is declared multiple times, earlier calls to
    +C or C win over later ones, but within each call,
    +later declarations superceed earlier ones.
    +
    +Here are some examples of the results of these precedence rules:
    +
    +  # 1 - use, before
    +  use Class::MakeMethods::Standard::Hash (
    +    'scalar'=>['baz'] # baz() not seen yet, so we generate, install
    +  );
    +  sub baz { 1 } # Subsequent declaration overwrites it, with warning
    +  
    +  # 2 - use, after
    +  sub foo { 1 }
    +  use Class::MakeMethods::Standard::Hash (
    +    'scalar'=>['foo'] # foo() is already declared, so has no effect
    +  );
    +  
    +  # 3 - use, after, Force
    +  sub bar { 1 }
    +  use Class::MakeMethods::Standard::Hash ( 
    +      -ForceInstall => 1, # Set flag for following methods...
    +    'scalar' => ['bar']   # ... now overwrites pre-existing bar()
    +  );
    +  
    +  # 4 - make, before
    +  Class::MakeMethods::Standard::Hash->make(
    +    'scalar'=>['blip'] # blip() is already declared, so has no effect
    +  );
    +  sub blip { 1 } # Although lower than make(), this "happens" first
    +  
    +  # 5 - make, after, Force
    +  sub ping { 1 } 
    +  Class::MakeMethods::Standard::Hash->make(
    +      -ForceInstall => 1, # Set flag for following methods...
    +    'scalar' => ['ping']  # ... now overwrites pre-existing ping()
    +  );
    +
    +=head2 Global Options
    +
    +Global options may be specified as an argument pair with a leading hyphen. (This distinguishes them from type names, which must be valid Perl subroutine names, and thus will never begin with a hyphen.) 
    +
    +use Class::MakeMethods::I ( 
    +    '-I' => I,
    +    'I' => [ I ], I<...>
    +  );
    +
    +Option settings apply to all subsequent method declarations within a single C or C call.
    +
    +The below options allow you to control generation and installation of the requested methods. (Some subclasses may support additional options; see their documentation for details.)
    +
    +=over 4 
    +
    +=item -TargetClass
    +
    +By default, the methods are installed in the first package in the caller() stack that is not a Class::MakeMethods subclass; this is generally the package in which your use or make statement was issued. To override this you can pass C<-TargetClass =E I> as initial arguments to C or C. 
    +
    +This allows you to construct or modify classes "from the outside":
    +
    +  package main;
    +  
    +  use Class::MakeMethods::Basic::Hash( 
    +    -TargetClass => 'MyWidget',
    +    'new' => ['create'],
    +    'scalar' => ['foo', 'bar'],
    +  );
    +  
    +  $o = MyWidget->new( foo => 'Foozle' );
    +  print $o->foo();
    +
    +=item -MakerClass
    +
    +By default, meta-methods are looked up in the package you called
    +use or make on.
    +
    +You can override this by passing the C<-MakerClass> flag, which
    +allows you to switch packages for the remainder of the meta-method
    +types and arguments.
    +
    +use Class::MakeMethods ( 
    +    '-MakerClass'=>'I', 
    +    'I' => [ I ] 
    +  );
    +
    +When specifying the MakerClass, you may provide either the trailing
    +part name of a subclass inside of the C
    +namespace, or a full package name prefixed by C<::>. 
    +
    +For example, the following four statements are equivalent ways of
    +declaring a Basic::Hash scalar method named 'foo':
    +
    +  use Class::MakeMethods::Basic::Hash ( 
    +    'scalar' => [ 'foo' ] 
    +  );
    +  
    +  use Class::MakeMethods ( 
    +    'Basic::Hash:scalar' => [ 'foo' ] 
    +  );
    +  
    +  use Class::MakeMethods ( 
    +    '-MakerClass'=>'Basic::Hash', 
    +    'scalar' =>  [ 'foo' ] 
    +  );
    +  
    +  use Class::MakeMethods ( 
    +    '-MakerClass'=>'::Class::MakeMethods::Basic::Hash', 
    +    'scalar' =>  [ 'foo' ] 
    +  );
    +
    +=item -ForceInstall
    +
    +By default, Class::MakeMethods will not install generated methods over any pre-existing methods in the target class. To override this you can pass C<-ForceInstall =E 1> as initial arguments to C or C. 
    +
    +Note that the C keyword acts as a BEGIN block, so a C at the top of a file will be executed before any subroutine declarations later in the file have been seen. (See L for additional discussion of this issue.)
    +
    +=back
    +
    +=head2 Mixing Method Types
    +
    +A single calling class can combine generated methods from different MakeMethods subclasses. In general, the only mixing that's problematic is combinations of methods which depend on different underlying object types, like using *::Hash and *::Array methods together -- the methods will be generated, but some of them  are guaranteed to fail when called, depending on whether your object happens to be a blessed hashref or arrayref. 
    +
    +For example, it's common to mix and match various *::Hash methods, with a scattering of Global or Inheritable methods:
    +
    +  use Class::MakeMethods (
    +    'Basic::Hash:scalar'      => 'foo',
    +    'Composite::Hash:scalar'  => [ 'bar' => { post_rules => [] } ],
    +    'Standard::Global:scalar' => 'our_shared_baz'
    +  );
    +
    +=head2 Declaration Syntax
    +
    +The following types of Simple declarations are supported:
    +
    +=over 4
    +
    +=item *
    +
    +I => 'I'
    +
    +=item *
    +
    +I => 'I I...'
    +
    +=item *
    +
    +I => [ 'I', 'I', ...]
    +
    +=back
    +
    +For a list of the supported values of I, see
    +L, or the documentation
    +for each subclass.
    +
    +For each method name you provide, a subroutine of the indicated
    +type will be generated and installed under that name in your module.
    +
    +Method names should start with a letter, followed by zero or more
    +letters, numbers, or underscores.
    +
    +=head2 Argument Normalization
    +
    +The following expansion rules are applied to argument pairs to
    +enable the use of simple strings instead of arrays of arguments.
    +
    +=over 4
    +
    +=item *
    +
    +Each type can be followed by a single meta-method definition, or by a
    +reference to an array of them.
    +
    +=item *
    +
    +If the argument is provided as a string containing spaces, it is
    +split and each word is treated as a separate argument.
    +
    +=item *
    +
    +It the meta-method type string contains spaces, it is split and
    +only the first word is used as the type, while the remaining words
    +are placed at the front of the argument list.
    +
    +=back
    +
    +For example, the following statements are equivalent ways of
    +declaring a pair of Basic::Hash scalar methods named 'foo' and 'bar':
    +
    +  use Class::MakeMethods::Basic::Hash ( 
    +    'scalar' => [ 'foo', 'bar' ], 
    +  );
    +  
    +  use Class::MakeMethods::Basic::Hash ( 
    +    'scalar' => 'foo', 
    +    'scalar' => 'bar', 
    +  );
    +  
    +  use Class::MakeMethods::Basic::Hash ( 
    +    'scalar' => 'foo bar', 
    +  );
    +  
    +  use Class::MakeMethods::Basic::Hash ( 
    +    'scalar foo' => 'bar', 
    +  );
    +
    +(The last of these is clearly a bit peculiar and potentially misleading if used as shown, but it enables advanced subclasses to provide convenient formatting for declarations with  defaults or modifiers, such as C<'Template::Hash:scalar --private' =E 'foo'>, discussed elsewhere.)
    +
    +=head2 Parameter Syntax
    +
    +The Standard syntax also provides several ways to optionally
    +associate a hash of additional parameters with a given method
    +name. 
    +
    +=over 4
    +
    +=item *
    +
    +I => [ 
    +    'I' => { I=>I... }, I<...>
    +  ]
    +
    +A hash of parameters to use just for this method name. 
    +
    +(Note: to prevent confusion with self-contained definition hashes,
    +described below, parameter hashes following a method name must not
    +contain the key C<'name'>.)
    +
    +=item *
    +
    +I => [ 
    +    [ 'I', 'I', ... ] => { I=>I... }
    +  ]
    +
    +Each of these method names gets a copy of the same set of parameters.
    +
    +=item *
    +
    +I => [ 
    +    { 'name'=>'I', I=>I... }, I<...>
    +  ]
    +
    +By including the reserved parameter C<'name'>, you create a self-contained declaration with that name and any associated hash values.
    +
    +=back
    +
    +Simple declarations, as shown in the prior section, are treated as if they had an empty parameter hash.
    +
    +=head2 Default Parameters
    +
    +A set of default parameters to be used for several declarations
    +may be specified using any of the following types of arguments to
    +a method generator call:
    +
    +=over 4
    +
    +=item * 
    +
    +I => [ 
    +    '-I' => 'I', 'I', 'I', I<...>
    +  ]
    +
    +Set a default value for the specified parameter to be passed to all subsequent declarations.
    +
    +=item * 
    +
    +I => [ 
    +    '--' => { 'I' => 'I', ... }, 'I', 'I', I<...>
    +  ]
    +
    +Set default values for one or more parameters to be passed to all subsequent declarations. Equivalent to a series of '-I' => 'I' pairs for each pair in the referenced hash.
    +
    +=item * 
    +
    +I => [ 
    +    '--I', 'I', 'I', I<...>
    +  ]
    +
    +Appends to the default value for a special parameter named "--". This parameter is currently only used by some subclasses; for details see L
    +
    +=back
    +
    +Parameters set in these ways are passed to each declaration that
    +follows it until the end of the method-generator argument array,
    +or until overridden by another declaration. Parameters specified
    +in a hash for a specific method name, as discussed above, will
    +override the defaults of the same name for that particular method.
    +
    +
    +=head1 DIAGNOSTICS
    +
    +The following warnings and errors may be produced when using
    +Class::MakeMethods to generate methods. (Note that this list does not
    +include run-time messages produced by calling the generated methods.)
    +
    +These messages are classified as follows (listed in increasing order of
    +desperation): 
    +
    +    (Q) A debugging message, only shown if $CONTEXT{Debug} is true
    +    (W) A warning.
    +    (D) A deprecation.
    +    (F) A fatal error in caller's use of the module.
    +    (I) An internal problem with the module or subclasses.
    +
    +Portions of the message which may vary are denoted with a %s.
    +
    +=over 4
    +
    +=item Can't interpret meta-method template: argument is empty or
    +undefined
    +
    +(F)
    +
    +=item Can't interpret meta-method template: unknown template name
    +'%s'
    +
    +(F)
    +
    +=item Can't interpret meta-method template: unsupported template
    +type '%s'
    +
    +(F)
    +
    +=item Can't make method %s(): template specifies unknown behavior
    +'%s'
    +
    +(F)
    +
    +=item Can't parse meta-method declaration: argument is empty or
    +undefined
    +
    +(F) You passed an undefined value or an empty string in the list
    +of meta-method declarations to use or make.
    +
    +=item Can't parse meta-method declaration: missing name attribute.
    +
    +(F) You included an hash-ref-style meta-method declaration that
    +did not include the required name attribute. You may have meant
    +this to be an attributes hash for a previously specified name, but
    +if so we were unable to locate it.
    +
    +=item Can't parse meta-method declaration: unknown template name
    +'%s'
    +
    +(F) You included a template specifier of the form C<'-I'>
    +in a the list of meta-method declaration, but that template is not
    +available.
    +
    +=item Can't parse meta-method declaration: unsupported declaration
    +type '%s'
    +
    +(F) You included an unsupported type of value in a list of meta-method
    +declarations.
    +
    +=item Compilation error: %s
    +
    +(I)
    +
    +=item Not an interpretable meta-method: '%s'
    +
    +(I)
    +
    +=item Odd number of arguments passed to %s make
    +
    +(F) You specified an odd number of arguments in a call to use or
    +make.  The arguments should be key => value pairs.
    +
    +=item Unable to compile generated method %s(): %s
    +
    +(I) The install_methods subroutine attempted to compile a subroutine
    +by calling eval on a provided string, which failed for the indicated
    +reason, usually some type of Perl syntax error.
    +
    +=item Unable to dynamically load $package: $%s
    +
    +(F)
    +
    +=item Unable to install code for %s() method: '%s'
    +
    +(I) The install_methods subroutine was passed an unsupported value
    +as the code to install for the named method.
    +
    +=item Unexpected return value from compilation of %s(): '%s'
    +
    +(I) The install_methods subroutine attempted to compile a subroutine
    +by calling eval on a provided string, but the eval returned something
    +other than than the code ref we expect.
    +
    +=item Unexpected return value from meta-method constructor %s: %s
    +
    +(I) The requested method-generator was invoked, but it returned an unacceptable value.
    +
    +=back
    +
    +
    +=head1 EXTENDING
    +
    +Class::MakeMethods can be extended by creating subclasses that
    +define additional meta-method types. Callers then select your
    +subclass using any of the several techniques described above.
    +
    +=head2 Creating A Subclass
    +
    +The begining of a typical extension might look like the below:
    +
    +  package My::UpperCaseMethods;
    +  use strict;
    +  use Class::MakeMethods '-isasubclass';
    +  
    +  sub my_method_type { ... }
    +
    +You can name your subclass anything you want; it does not need to
    +begin with Class::MakeMethods.
    +
    +The '-isasubclass' flag is a shortcut that automatically puts
    +Class::MakeMethods into your package's @ISA array so that it will
    +inherit the import() and make() class methods. If you omit this
    +flag, you will need to place the superclass in your @ISA explicitly.
    +
    +Typically, the subclass should B inherit from Exporter; both
    +Class::MakeMethods and Exporter are based on inheriting an import
    +class method, and getting a subclass to support both would require
    +additional effort.
    +
    +=head2 Naming Method Types
    +
    +Each type of method that can be generated is defined in a subroutine
    +of the same name. You can give your meta-method type any name that
    +is a legal subroutine identifier.
    +
    +(Names begining with an underscore, and the names C and
    +C, are reserved for internal use by Class::MakeMethods.)
    +
    +If you plan on distributing your extension, you may wish to follow
    +the "Naming Convention for Generated Method Types" described above
    +to facilitate reuse by others.
    +
    +=head2 Implementation Options
    +
    +Each method generation subroutine can be implemented in any one of
    +the following ways:
    +
    +=over 4
    +
    +=item *
    +
    +Subroutine Generation
    +
    +Returns a list of subroutine name/code pairs.
    +
    +The code returned may either be a coderef, or a string containing
    +Perl code that can be evaled and will return a coderef. If the eval
    +fails, or anything other than a coderef is returned, then
    +Class::MakeMethods croaks.
    +
    +For example a simple sub-class with a method type upper_case_get_set
    +that generates an accessor method for each argument provided might
    +look like this:
    +
    +  package My::UpperCaseMethods;
    +  use Class::MakeMethods '-isasubclass';
    +  
    +  sub uc_scalar {
    +    my $class = shift;
    +    map { 
    +      my $name = $_;
    +      $name => sub {
    +	my $self = shift;
    +	if ( scalar @_ ) { 
    +	  $self->{ $name } = uc( shift ) 
    +	} else {
    +	  $self->{ $name };
    +	}
    +      }
    +    } @_;
    +  }
    +
    +Callers could then generate these methods as follows:
    +
    +  use My::UpperCaseMethods ( 'uc_scalar' => 'foo' );
    +
    +=item *
    +
    +Aliasing
    +
    +Returns a string containing a different meta-method type to use
    +for those same arguments.
    +
    +For example a simple sub-class that defines a method type stored_value
    +might look like this:
    +
    +  package My::UpperCaseMethods;
    +  use Class::MakeMethods '-isasubclass';
    +
    +  sub regular_scalar { return 'Basic::Hash:scalar' }
    +
    +And here's an example usage:
    +
    +  use My::UpperCaseMethods ( 'regular_scalar' => [ 'foo' ] );
    +
    +=item *
    +
    +Rewriting
    +
    +Returns one or more array references with different meta-method
    +types and arguments to use.
    +
    +For example, the below meta-method definition reviews the name of
    +each method it's passed and creates different types of meta-methods
    +based on whether the declared name is in all upper case:
    +
    +  package My::UpperCaseMethods;
    +  use Class::MakeMethods '-isasubclass';
    +
    +  sub auto_detect { 
    +    my $class = shift;
    +    my @rewrite = ( [ 'Basic::Hash:scalar' ], 
    +		    [ '::My::UpperCaseMethods:uc_scalar' ] );
    +    foreach ( @_ ) {
    +      my $name_is_uppercase = ( $_ eq uc($_) ) ? 1 : 0;
    +      push @{ $rewrite[ $name_is_uppercase ] }, $_
    +    }
    +    return @rewrite;
    +  }
    +
    +The following invocation would then generate a regular scalar accessor method foo, and a uc_scalar method BAR:
    +
    +  use My::UpperCaseMethods ( 'auto_detect' => [ 'foo', 'BAR' ] );
    +
    +=item * 
    +
    +Generator Object
    +
    +Returns an object with a method named make_methods which will be responsible for returning subroutine name/code pairs. 
    +
    +See L for an example.
    +
    +=item *
    +
    +Self-Contained
    +
    +Your code may do whatever it wishes, and return an empty list.
    +
    +=back
    +
    +=head2 Access to Options
    +
    +Global option values are available through the _context() class method at the time that method generation is being performed.
    +
    +  package My::Maker;
    +  sub my_methodtype {
    +    my $class = shift;
    +    warn "Installing in " . $class->_context('TargetClass');
    +    ...
    +  }
    +
    +=over 4
    +
    +=item *
    +
    +TargetClass
    +
    +Class into which code should be installed.
    +
    +=item *
    +
    +MakerClass
    +
    +Which subclass of Class::MakeMethods will generate the methods?
    +
    +=item *
    +
    +ForceInstall
    +
    +Controls whether generated methods will be installed over pre-existing methods in the target package.
    +
    +=back
    +
    +
    +=head1 SEE ALSO
    +
    +=head2 License and Support
    +
    +For distribution, installation, support, copyright and license 
    +information, see L.
    +
    +=head2 Package Documentation
    +
    +A collection of sample uses is available in
    +L.
    +
    +See the documentation for each family of subclasses:
    +
    +=over 4
    +
    +=item *
    +
    +L
    +
    +=item *
    +
    +L
    +
    +=item *
    +
    +L
    +
    +=item *
    +
    +L
    +
    +=back
    +
    +A listing of available method types from each of the different subclasses
    +is provided in L.
    +
    +=head2 Related Modules
    +
    +For a brief survey of the numerous modules on CPAN which offer some type
    +of method generation, see L.
    +
    +In several cases, Class::MakeMethods provides functionality closely
    +equivalent to that of an existing module, and emulator modules are provided
    +to map the existing module's interface to that of Class::MakeMethods.
    +See L for more information.
    +
    +If you have used Class::MethodMaker, you will note numerous similarities
    +between the two.  Class::MakeMethods is based on Class::MethodMaker, but
    +has been substantially revised in order to provide a range of new features.
    +Backward compatibility and conversion documentation is provded in
    +L.
    +
    +=head2 Perl Docs
    +
    +See L for a quick introduction to objects for beginners.  For
    +an extensive discussion of various approaches to class construction, see
    +L and L (called L in the most recent
    +versions of Perl).
    +
    +See L, point 4 for more information on
    +closures. (FWIW, I think there's a big opportunity for a "perlfunt" podfile
    +bundled with Perl in the tradition of "perlboot" and "perltoot", exploring
    +the utility of function references, callbacks, closures, and
    +continuations... There are a bunch of useful references available, but
    +not a good overview of how they all interact in a Perlish way.)
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Attribute.pm b/lib/Class/MakeMethods/Attribute.pm
    new file mode 100644
    index 0000000..b8fe71d
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Attribute.pm
    @@ -0,0 +1,143 @@
    +package Class::MakeMethods::Attribute;
    +
    +require 5.006;
    +use strict;
    +use Carp;
    +use Attribute::Handlers;
    +
    +use Class::MakeMethods;
    +use Class::MakeMethods::Utility::Inheritable 'get_vvalue';
    +
    +our $VERSION = 1.005;
    +
    +our %DefaultMaker;
    +
    +sub import {
    +  my $class = shift;
    +
    +  if ( scalar @_ and $_[0] =~ m/^\d/ ) {
    +    Class::MakeMethods::_import_version( $class, shift );
    +  }
    +  
    +  if ( scalar @_ == 1 ) {
    +    my $target_class = ( caller(0) )[0];
    +    $DefaultMaker{ $target_class } = shift;
    +  }
    +}
    +
    +sub UNIVERSAL::MakeMethod :ATTR(CODE) {
    +  my ($package, $symbol, $referent, $attr, $data) = @_;
    +  if ( $symbol eq 'ANON' or $symbol eq 'LEXICAL' ) {
    +    croak "Can't apply MakeMethod attribute to $symbol declaration."
    +  }
    +  if ( ! $data ) {
    +    croak "No method type provided for MakeMethod attribute."
    +  }
    +  my $symname = *{$symbol}{NAME};
    +  if ( ref $data eq 'ARRAY' ) {
    +    local $_ = shift @$data;
    +    $symname = [ @$data, $symname ];
    +    $data = $_;
    +  }
    +  unless ( $DefaultMaker{$package} ) {
    +    local $_ = get_vvalue( \%DefaultMaker, $package );
    +    $DefaultMaker{$package} = $_ if ( $_ );
    +  }
    +  Class::MakeMethods->make( 
    +    -TargetClass => $package,
    +    -ForceInstall => 1, 
    +    ( $DefaultMaker{$package} ? ('-MakerClass'=>$DefaultMaker{$package}) : () ),
    +    $data => $symname
    +  );
    +}
    +
    +1;
    +
    +__END__
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Attribute - Declare generated subs with attribute syntax
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Attribute 'Standard::Hash';
    +  
    +  sub new    :MakeMethod('new');
    +  sub foo    :MakeMethod('scalar');
    +  sub bar    :MakeMethod('scalar', { hashkey => 'bar_data' });
    +  sub debug  :MakeMethod('Standard::Global:scalar');
    +
    +=head1 DESCRIPTION
    +
    +This package allows common types of methods to be generated via a subroutine attribute declaration. (Available in Perl 5.6 and later.)
    +
    +Adding the :MakeMethod() attribute to a subroutine declaration causes Class::MakeMethods to create and install a subroutine based on the parameters given to the :MakeMethod attribute.
    +
    +You can declare a default method-generation class by passing the name of a MakeMethods subclass in the use Class::MakeMethods::Attribute statement. This default method-generation class will also apply as the default to any subclasses declared at compile time. If no default method-generation class is selected, you will need to fully-qualify all method type declarations.
    +
    +=head1 EXAMPLE
    +
    +Here's a typical use of Class::MakeMethods::Attribute:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Attribute 'Standard::Hash';
    +  
    +  sub new    :MakeMethod('new');
    +  sub foo    :MakeMethod('scalar');
    +  sub bar    :MakeMethod('scalar', { hashkey => 'bar_data' });
    +  sub debug  :MakeMethod('Standard::Global:scalar');
    +
    +  package MySubclass;
    +  use base 'MyObject';
    +
    +  sub bazzle :MakeMethod('scalar');
    +
    +This is equivalent to the following explicit Class::MakeMethods invocations:
    +
    +  package MyObject;
    +  
    +  use Class::MakeMethods ( 
    +    -MakerClass => 'Standard::Hash',
    +    new => 'new',
    +    scalar => 'foo',
    +    scalar => [ 'ba', { hashkey => 'bar_data' } ],
    +    'Standard::Global:scalar' => 'debug',
    +  );
    +  
    +  package MySubclass;
    +  use base 'MyObject';
    +  
    +  use Class::MakeMethods ( 
    +    -MakerClass => 'Standard::Hash',
    +    scalar => 'bazzle',
    +  );
    +
    +=head1 DIAGNOSTICS
    +
    +The following warnings and errors may be produced when using
    +Class::MakeMethods::Attribute to generate methods. (Note that this
    +list does not include run-time messages produced by calling the
    +generated methods, or the standard messages produced by
    +Class::MakeMethods.)
    +
    +=over
    +
    +=item Can't apply MakeMethod attribute to %s declaration.
    +
    +You can not use the C<:MakeMethod> attribute with lexical or anonymous subroutine declarations. 
    +
    +=item No method type provided for MakeMethod attribute.
    +
    +You called C<:MakeMethod()> without the required method-type argument.
    +
    +=back
    +
    +=head1 SEE ALSO
    +
    +See L byÊDamian Conway.
    +
    +See L for general information about this distribution. 
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Autoload.pm b/lib/Class/MakeMethods/Autoload.pm
    new file mode 100644
    index 0000000..ab1a6ca
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Autoload.pm
    @@ -0,0 +1,182 @@
    +package Class::MakeMethods::Autoload;
    +
    +use strict;
    +use Carp;
    +require Exporter;
    +
    +use Class::MakeMethods;
    +use Class::MakeMethods::Utility::Inheritable 'get_vvalue';
    +
    +use vars qw( $VERSION @ISA @EXPORT_OK );
    +
    +$VERSION = 1.000;
    +@ISA = qw(Exporter);
    +@EXPORT_OK = qw( AUTOLOAD );
    +
    +########################################################################
    +
    +use vars qw( $AUTOLOAD %DefaultType );
    +
    +sub import {
    +  my $class = shift;
    +  my $target_class = ( caller(0) )[0];
    +  
    +  if ( scalar @_ and $_[0] =~ m/^\d/ ) {
    +    Class::MakeMethods::_import_version( $class, shift );
    +  }
    +  
    +  if ( scalar @_ == 1 ) {
    +    $DefaultType{ $target_class } = shift;
    +  }
    +  
    +  __PACKAGE__->Exporter::export_to_level(1, $class, 'AUTOLOAD');
    +}
    +
    +sub AUTOLOAD {
    +  my $sym = $AUTOLOAD;
    +  my ($package, $func) = ($sym =~ /(.*)::([^:]+)$/);
    +  
    +  unless ( $DefaultType{$package} ) {
    +    local $_ = get_vvalue( \%DefaultType, $package );
    +    $DefaultType{$package} = $_ if ( $_ );
    +  }
    +  
    +  my $type = $DefaultType{$package} 
    +      or croak(__PACKAGE__ . ": No default method type for $package; can't auto-generate $func");
    +  
    +  if ( ref $type eq 'HASH' ) { 
    +    my $n_type = $type->{ $func } ||
    +	( map $type->{$_}, grep { $func =~ m/\A$_\Z/ } sort { length($b) <=> length($a) } keys %$type )[0] ||
    +	$type->{ '' } 
    +      or croak(__PACKAGE__ . ": Can't find best match for '$func' in type map (" . join(', ', keys %$type ) . ")");
    +    $type = $n_type;
    +  } elsif ( ref $type eq 'CODE' ) {
    +    $type = &$type( $func )
    +      or croak(__PACKAGE__ . ": Can't find match for '$func' in type map ($type)");
    +  }
    +  
    +  # warn "Autoload $func ($type)";
    +  Class::MakeMethods->make( 
    +    -TargetClass => $package,
    +    -ForceInstall => 1, 
    +    $type => $func
    +  );
    +  
    +  if ( my $sub = $package->can( $func ) ) {
    +    goto &$sub;
    +  } else {
    +    croak(__PACKAGE__ . ": Construction of $type method ${package}::$func failed to produce usable method")
    +  }
    +}
    +
    +1;
    +
    +__END__
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Autoload - Declare generated subs with AUTOLOAD
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Autoload 'Standard::Hash::scalar';
    +  
    +  package main;
    +  my $obj = bless {}, 'MyObject';
    +  
    +  $obj->foo("Foozle");
    +  print $obj->foo();
    +
    +=head1 DESCRIPTION
    +
    +This package provides a generate-on-demand interface to Class::MakeMethods. 
    +
    +When your class uses this package, it imports an AUTOLOAD function that resolves missing methods by using Class::MakeMethods to generate and install a standard type of method.
    +
    +You must specify the type of method to be generated by passing a single argument to your use Class::MakeMethods::Autoload statement, which can take any of these forms:
    +
    +=over 4
    +
    +=item *
    +
    +A Class::MakeMethods generator name and method type.
    +
    +Here are three examples:
    +
    +  use Class::MakeMethods::Autoload 'Standard::Hash:scalar';
    +  
    +  use Class::MakeMethods::Autoload 'Basic::Universal::no_op';
    +  
    +  use Class::MakeMethods::Autoload 
    +		'::Class::MakeMethod::Composite::Global:array';
    +
    +=item *
    +
    +A reference to a subroutine which will be called for each requested function name and which is expected to return the name of the method generator to use.
    +
    +Here's a contrived example which generates scalar accessors for methods except those with a digit in their name, which are treated as globals.
    +
    +  use Class::MakeMethods::Autoload sub { 
    +    my $name = shift;
    +    ( $name =~ /\d/ ) ? 'Standard::Global::scalar' 
    +		      : 'Standard::Hash::scalar'
    +  };
    +
    +=item *
    +
    +A reference to a hash which defines which method type to use based on the name of the requested method. If a key exists which is an exact match for the requested function name, the associated value is used; otherwise, each of the keys is used as a regular expression, and the value of the first one that matches the function name is used. (For regular expression matching, the keys are tested in reverse length order, longest to shortest.)
    +
    +Here's an example which provides a new() constructor, a DESTROY() method that does nothing, and a wildcard match that provides scalar accessors for all other Autoloaded methods:
    +
    +  use Class::MakeMethods::Autoload { 
    +    'new'     => 'Standard::Hash::new', 
    +    '.*'      => 'Standard::Hash::scalar',
    +    'DESTROY' => 'Standard::Universal::no_op',
    +  };
    +
    +Here's a more sophisticated example which causes all-upper-case method names to be generated as globals, those with a leading upper-case letter to be generated as inheritable data methods, and others to be normal accessors:
    +
    +  use Class::MakeMethods::Autoload { 
    +    'new'     => 'Standard::Hash::new', 
    +    '.*'      => 'Standard::Hash::scalar',
    +    '[A-Z].*' => 'Standard::Inheritable::scalar',
    +    '[A-Z0-9]+' => 'Standard::Global::scalar',
    +    'DESTROY' => 'Standard::Universal::no_op',
    +  };
    +
    +=back
    +
    +=head1 DIAGNOSTICS
    +
    +The following warnings and errors may be produced when using
    +Class::MakeMethods::Attribute to generate methods. (Note that this
    +list does not include run-time messages produced by calling the
    +generated methods, or the standard messages produced by
    +Class::MakeMethods.)
    +
    +=over
    +
    +=item No default method type; can't autoload
    +
    +You must declare a default method type, generally by passing its
    +name to a C statement, prior to
    +autoloading any methods.
    +
    +=item Construction of %s method %s failed to produce usable method
    +
    +Indicates that Autoload succesfully called Class::MakeMethods->make
    +to generate the requested method, but afterwards was not able to
    +invoke the generated method. You may have selected an incompatible
    +method type, or the method may not have been installed sucesfully.
    +
    +=back
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +For distribution, installation, support, copyright and license 
    +information, see L.
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Basic.pm b/lib/Class/MakeMethods/Basic.pm
    new file mode 100644
    index 0000000..f893f5b
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Basic.pm
    @@ -0,0 +1,98 @@
    +package Class::MakeMethods::Basic;
    +
    +use Class::MakeMethods '-isasubclass';
    +
    +$VERSION = 1.000;
    +
    +1;
    +
    +__END__
    +
    +########################################################################
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Basic - Make really simple methods
    +
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Hash (
    +    'new'     => [ 'new' ],
    +    'scalar'  => [ 'foo', 'bar' ]
    +  );
    +
    +  package main;   
    + 
    +  my $obj = MyObject->new( foo => "Foozle", bar => "Bozzle" );
    +  print $obj->foo();
    +  $obj->bar("Barbados");
    +
    +
    +=head1 DESCRIPTION
    +
    +This document describes the various subclasses of Class::MakeMethods
    +included under the Basic::* namespace, and the method types each
    +one provides.
    +
    +The Basic subclasses provide stripped-down method-generation implementations. 
    +
    +Subroutines are generated as closures bound to each method name.
    +
    +=head2 Calling Conventions
    +
    +When you C a subclass of this package, the method declarations you provide
    +as arguments cause subroutines to be generated and installed in
    +your module. You can also omit the arguments to C and instead make methods
    +at runtime by passing the declarations to a subsequent call to
    +C.
    +
    +You may include any number of declarations in each call to C
    +or C. If methods with the same name already exist, earlier
    +calls to C or C win over later ones, but within each
    +call, later declarations superceed earlier ones.
    +
    +You can install methods in a different package by passing C<-TargetClass =E I> as your first arguments to C or C. 
    +
    +See L for more details.
    +
    +=head2 Declaration Syntax
    +
    +The following types of declarations are supported:
    +
    +=over 4
    +
    +=item *
    +
    +I => 'I'
    +
    +=item *
    +
    +I => 'I I...'
    +
    +=item *
    +
    +I => [ 'I', 'I', ...]
    +
    +=back
    +
    +For a list of the supported values of I, see
    +L, or the documentation
    +for each subclass.
    +
    +For each method name you provide, a subroutine of the indicated
    +type will be generated and installed under that name in your module.
    +
    +Method names should start with a letter, followed by zero or more
    +letters, numbers, or underscores.
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +For distribution, installation, support, copyright and license 
    +information, see L.
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Basic/Array.pm b/lib/Class/MakeMethods/Basic/Array.pm
    new file mode 100644
    index 0000000..c537866
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Basic/Array.pm
    @@ -0,0 +1,422 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Basic::Array - Basic array methods
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Array (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +  ...
    +  
    +  # Constructor
    +  my $obj = MyObject->new( foo => 'Foozle' );
    +  
    +  # Scalar Accessor
    +  print $obj->foo();
    +  
    +  $obj->bar('Barbados');
    +  print $obj->bar();
    +  
    +  # Array accessor
    +  $obj->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print $obj->my_list(1);
    +  
    +  # Hash accessor
    +  $obj->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print $obj->my_index('foo');
    +
    +
    +=head1 DESCRIPTION
    +
    +The Basic::Array subclass of MakeMethods provides a basic
    +constructor and accessors for blessed-array object instances.
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for a summary, or L for full details.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. Valid method-type names for this
    +package are listed in L<"METHOD GENERATOR TYPES">.
    +
    +See L for more
    +syntax information.
    +
    +=cut
    +
    +package Class::MakeMethods::Basic::Array;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods '-isasubclass';
    +
    +########################################################################
    +
    +=head2 About Positional Accessors
    +
    +Each accessor method claims the next available spot in the array
    +to store its value in.
    +
    +The mapping between method names and array positions is stored in
    +a hash named %FIELDS in the target package. When the first positional
    +accessor is defined for a package, its %FIELDS are initialized by
    +searching its inheritance tree.
    +
    +B: Subclassing packages that use positional accessors is
    +somewhat fragile, since you may end up with two distinct methods
    +assigned to the same position. Specific cases to avoid are:
    +
    +=over 4
    +
    +=item *
    +
    +If you inherit from more than one class with positional accessors,
    +the positions used by the two sets of methods will overlap.
    +
    +=item *
    +
    +If your superclass adds additional positional accessors after you
    +declare your first, they will overlap yours.
    +
    +=back
    +
    +=cut
    +
    +sub _array_index {
    +  my $class = shift;
    +  my $name = shift;
    +  no strict;
    +  local $^W = 0;
    +  if ( ! scalar %{$class . "::FIELDS"} ) {
    +    my @classes = @{$class . "::ISA"};
    +    my @fields;
    +    while ( @classes ) {
    +      my $superclass = shift @classes;
    +      if ( scalar %{$superclass . "::FIELDS"} ) {
    +	push @fields, %{$superclass . "::FIELDS"};
    +      } else {
    +	unshift @classes, @{$superclass . "::ISA"}
    +      }
    +    }
    +    %{$class . "::FIELDS"} = @fields
    +  }
    +  my $field_hash = \%{$class . "::FIELDS"};
    +  $field_hash->{$name} or $field_hash->{$name} = scalar keys %$field_hash
    +}
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 new - Constructor
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +If called as a class method, makes a new array and blesses it into that class.
    +
    +=item *
    +
    +If called on an array-based instance, makes a copy of it and blesses the copy into the same class as the original instance.
    +
    +=item *
    +
    +If passed a list of method-value pairs, calls each named method with the associated value as an argument. 
    +
    +=item *
    +
    +Returns the new instance.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Array (
    +    new => 'new',
    +  );
    +  ...
    +  
    +  # Bare constructor
    +  my $empty = MyObject->new();
    +  
    +  # Constructor with initial sequence of method calls
    +  my $obj = MyObject->new( foo => 'Foozle', bar => 'Barbados' );
    +  
    +  # Copy with overriding sequence of method calls
    +  my $copy = $obj->new( bar => 'Bob' );
    +
    +=cut
    +
    +sub new {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    $name => sub {
    +      my $callee = shift;
    +      my $self = ref($callee) ? bless( [@$callee], ref($callee) ) 
    +			      : bless( [], $callee );
    +      while ( scalar @_ ) {
    +	my $method = shift;
    +	$self->$method( shift );
    +      }
    +      return $self;
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head2 scalar - Instance Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value.
    +
    +=item *
    +
    +If called without any arguments returns the current value (or undef).
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Array (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo('Foozle');
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +sub scalar {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    my $index = _array_index( $class->_context('TargetClass'), $name );
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar @_ ) {
    +	$self->[$index] = shift;
    +      } else {
    +	$self->[$index];
    +      }
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head2 array - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value.
    +
    +=item * 
    +
    +The value for each instance will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current array-ref value (or undef).
    +
    +=item *
    +
    +If called with one argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef). If the single argument is an array ref, then a slice of the referenced array is returned.
    +
    +=item *
    +
    +If called with a list of index-value pairs, stores the value at the given index in the referenced array. If the instance's value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Array (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Set values by position
    +  $obj->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  $obj->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print $obj->bar(1);
    +  
    +  # Retrieve slice of values by position
    +  print join(', ', $obj->bar( [0, 2] ) );
    +  
    +  # Direct access to referenced array
    +  print scalar @{ $obj->bar() };
    +  
    +  # Reset the array contents to empty
    +  @{ $obj->bar() } = ();
    +
    +=cut
    +
    +sub array {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    my $index = _array_index( $class->_context('TargetClass'), $name );
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	return $self->[$index];
    +      } elsif ( scalar(@_) == 1 ) {
    +	return $self->[$index]->[ shift() ];
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to $name";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  my $k = shift();
    +	  $self->[$index]->[ $k ] = shift();
    +	}
    +	return $self->[$index];
    +      }
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head2 hash - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value.
    +
    +=item * 
    +
    +The value for each instance will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current hash-ref value (or undef).
    +
    +=item *
    +
    +If called with one argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef). If the single argument is an array ref, then a slice of the referenced hash is returned.
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the instance's value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the current hash-ref value.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Array (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  $obj->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  $obj->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print $obj->baz('foo');
    +  
    +  # Retrieve slice of values by position
    +  print join(', ', $obj->baz( ['foo', 'bar'] ) );
    +  
    +  # Direct access to referenced hash
    +  print keys %{ $obj->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ $obj->baz() } = ();
    +
    +=cut
    +
    +sub hash {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    my $index = _array_index( $class->_context('TargetClass'), $name );
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	return $self->[$index];
    +      } elsif ( scalar(@_) == 1 ) {
    +	return $self->[$index]->{ shift() };
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to $name";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  my $k = shift();
    +	  $self->[$index]->{ $k } = shift();
    +	}
    +	return $self->[$index];
    +      }
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Basic/Global.pm b/lib/Class/MakeMethods/Basic/Global.pm
    new file mode 100644
    index 0000000..21116c4
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Basic/Global.pm
    @@ -0,0 +1,298 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Basic::Global - Basic shared methods
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Global (
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +  ....
    +  
    +  # Store and retrieve global values
    +  MyObject->foo('Foobar');
    +  print MyObject->foo();
    +  
    +  # All instances of your class access the same values
    +  $my_object->bar('Barbados'); 
    +  print $other_one->bar(); 
    +  
    +  # Array accessor
    +  MyObject->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print MyObject->my_list(1);
    +  
    +  # Hash accessor
    +  MyObject->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print MyObject->my_index('foo');
    +
    +
    +=head1 DESCRIPTION
    +
    +The Basic::Global subclass of MakeMethods provides basic accessors for data shared by an entire class, sometimes called "static" or "class data."
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for a summary, or L for full details.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. Valid method-type names for this
    +package are listed in L<"METHOD GENERATOR TYPES">.
    +
    +See L for more
    +syntax information.
    +
    +=cut
    +
    +package Class::MakeMethods::Basic::Global;
    +
    +$VERSION = 1.000;
    +use Class::MakeMethods '-isasubclass';
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 scalar - Shared Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or equivalently, on any object instance.
    +
    +=item *
    +
    +Stores a global value accessible only through this method.
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Hash (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  MyObject->foo('Foozle');
    +  
    +  # Retrieve value
    +  print MyObject->foo;
    +
    +=cut
    +
    +sub scalar {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar @_ ) {
    +	$value = shift;
    +      } else {
    +	$value;
    +      }
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head2 array - Shared Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or equivalently, on any object instance.
    +
    +=item *
    +
    +Stores a global value accessible only through this method.
    +
    +=item * 
    +
    +The value will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current array-ref value (or undef).
    +
    +=item *
    +
    +If called with one argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef). If the single argument is an array ref, then a slice of the referenced array is returned.
    +
    +=item *
    +
    +If called with a list of index-value pairs, stores the value at the given index in the referenced array. If the value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Hash (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Set values by position
    +  $obj->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  $obj->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print $obj->bar(1);
    +  
    +  # Retrieve slice of values by position
    +  print join(', ', $obj->bar( [0, 2] ) );
    +  
    +  # Direct access to referenced array
    +  print scalar @{ $obj->bar() };
    +  
    +  # Reset the array contents to empty
    +  @{ $obj->bar() } = ();
    +
    +=cut
    +
    +sub array {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    my $value = [];
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 1 ) {
    +	my $index = shift;
    +	ref($index) ? @{$value}[ @$index ] : $value->[ $index ];
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to $name";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  $value->[ shift() ] = shift();
    +	}
    +	return $value;
    +      }
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head2 hash - Shared Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or equivalently, on any object instance.
    +
    +=item *
    +
    +Stores a global value accessible only through this method.
    +
    +=item * 
    +
    +The value will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current hash-ref value (or undef).
    +
    +=item *
    +
    +If called with one argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef). If the single argument is an array ref, then a slice of the referenced hash is returned.
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the current hash-ref value.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Hash (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  $obj->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  $obj->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print $obj->baz('foo');
    +  
    +  # Retrieve slice of values by position
    +  print join(', ', $obj->baz( ['foo', 'bar'] ) );
    +  
    +  # Direct access to referenced hash
    +  print keys %{ $obj->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ $obj->baz() } = ();
    +
    +=cut
    +
    +sub hash {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    my $value = {};
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 1 ) {
    +	my $index = shift;
    +	ref($index) ? @{$value}{ @$index } : $value->{ $index };
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to $name";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  my $key = shift;
    +	  $value->{ $key } = shift();
    +	}
    +	$value;
    +      }
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Basic/Hash.pm b/lib/Class/MakeMethods/Basic/Hash.pm
    new file mode 100644
    index 0000000..7a55106
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Basic/Hash.pm
    @@ -0,0 +1,362 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Basic::Hash - Basic hash methods
    +
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Hash (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +  ...
    +  
    +  # Constructor
    +  my $obj = MyObject->new( foo => 'Foozle' );
    +  
    +  # Scalar Accessor
    +  print $obj->foo();
    +  
    +  $obj->bar('Barbados'); 
    +  print $obj->bar();
    +  
    +  # Array accessor
    +  $obj->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print $obj->my_list(1);
    +  
    +  # Hash accessor
    +  $obj->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print $obj->my_index('foo');
    +
    +
    +=head1 DESCRIPTION
    +
    +The Basic::Hash subclass of MakeMethods provides a basic constructor and accessors for blessed-hash object instances.
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for a summary, or L for full details.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. Valid method-type names for this
    +package are listed in L<"METHOD GENERATOR TYPES">.
    +
    +See L for more
    +syntax information.
    +
    +
    +=cut
    +
    +package Class::MakeMethods::Basic::Hash;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods '-isasubclass';
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 new - Constructor
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +If called as a class method, makes a new hash and blesses it into that class.
    +
    +=item *
    +
    +If called on a hash-based instance, makes a copy of it and blesses the copy into the same class as the original instance.
    +
    +=item *
    +
    +If passed a list of key-value pairs, appends them to the new hash. These arguments override any copied values, and later arguments with the same name will override earlier ones.
    +
    +=item *
    +
    +Returns the new instance.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Hash (
    +    new => 'new',
    +  );
    +  ...
    +  
    +  # Bare constructor
    +  my $empty = MyObject->new();
    +  
    +  # Constructor with initial values
    +  my $obj = MyObject->new( foo => 'Foozle', bar => 'Barbados' );
    +  
    +  # Copy with overriding value
    +  my $copy = $obj->new( bar => 'Bob' );
    +
    +=cut
    +
    +sub new {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    $name => sub {
    +      my $callee = shift;
    +      if ( ref $callee ) {
    +	bless { %$callee, @_ }, ref $callee;
    +      } else {
    +	bless { @_ }, $callee;
    +      }
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head2 scalar - Instance Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Uses the method name as a hash key to access the related value for each instance.
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Hash (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo('Foozle');
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +sub scalar {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    $name => sub {
    +      if ( scalar @_ > 1 ) {
    +	$_[0]->{$name} = $_[1];
    +      } else {
    +	$_[0]->{$name};
    +      }
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head2 array - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Uses the method name as a hash key to access the related value for each instance.
    +
    +=item * 
    +
    +The value for each instance will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current array-ref value (or undef).
    +
    +=item *
    +
    +If called with one argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef). 
    +
    +=item *
    +
    +If called with a list of index-value pairs, stores the value at the given index in the referenced array. If the instance's value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Hash (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Set values by position
    +  $obj->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  $obj->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print $obj->bar(1);
    +    
    +  # Direct access to referenced array
    +  print scalar @{ $obj->bar() };
    +  
    +  # Reset the array contents to empty
    +  @{ $obj->bar() } = ();
    +
    +=cut
    +
    +sub array {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	return $self->{$name};
    +      } elsif ( scalar(@_) == 1 ) {
    +	$self->{$name}->[ shift() ];
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to $name";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  my $key = shift();
    +	  $self->{$name}->[ $key ] = shift();
    +	}
    +	return $self->{$name};
    +      }
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head2 hash - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Uses the method name as a hash key to access the related value for each instance.
    +
    +=item * 
    +
    +The value for each instance will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current hash-ref value (or undef).
    +
    +=item *
    +
    +If called with one argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef). 
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the instance's value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the current hash-ref value.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyObject;
    +  use Class::MakeMethods::Basic::Hash (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  $obj->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  $obj->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print $obj->baz('foo');
    +  
    +  # Direct access to referenced hash
    +  print keys %{ $obj->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ $obj->baz() } = ();
    +
    +=cut
    +
    +sub hash {
    +  my $class = shift;
    +  map { 
    +    my $name = $_;
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	return $self->{$name};
    +      } elsif ( scalar(@_) == 1 ) {
    +	$self->{$name}->{ shift() };
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to $name";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  $self->{$name}->{ shift() } = shift();
    +	}
    +	return $self->{$name};
    +      }
    +    }
    +  } @_;
    +}
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +See L for equivalent functionality
    +based on blessed arrays. If all access to your object is through
    +constructors and accessors declared using this package, and your
    +class will not be extensively subclassed, consider switching to
    +Basic::Array to minimize resource consumption.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Composite.pm b/lib/Class/MakeMethods/Composite.pm
    new file mode 100644
    index 0000000..902c235
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Composite.pm
    @@ -0,0 +1,218 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Composite - Make extensible compound methods
    +
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Hash (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +
    +
    +=head1 DESCRIPTION
    +
    +This document describes the various subclasses of Class::MakeMethods
    +included under the Composite::* namespace, and the method types each
    +one provides.
    +
    +The Composite subclasses provide a parameterized set of method-generation
    +implementations.
    +
    +Subroutines are generated as closures bound to a hash containing
    +the method name and additional parameters, including the arrays of subroutine references that will provide the method's functionality.
    +
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for more information.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. 
    +
    +Valid method-type names for this package are listed in L<"METHOD
    +GENERATOR TYPES">.
    +
    +See L and L for more information.
    +
    +=cut
    +
    +package Class::MakeMethods::Composite;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods '-isasubclass';
    +use Carp;
    +
    +########################################################################
    +
    +=head2 About Composite Methods
    +
    +The methods generated by Class::MakeMethods::Composite are assembled
    +from groups of "fragment" subroutines, each of which provides some
    +aspect of the method's behavior.
    +
    +You can add pre- and post- operations to any composite method.
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Hash (
    +    new => 'new',
    +    scalar => [ 
    +      'foo' => { 
    +	'pre_rules' => [ 
    +	  sub {
    +	    # Don't automatically convert list to array-ref
    +	    croak "Too many arguments" if ( scalar @_ > 2 );
    +	  }
    +	],
    +	'post_rules' => [ 
    +	  sub {
    +	    # Don't let anyone see my credit card number!
    +	    ${(pop)->{result}} =~ s/\d{13,16}/****/g;
    +	  }
    +	],
    +      }
    +    ],
    +  );
    +
    +=cut
    +
    +use vars qw( $Method );
    +
    +sub CurrentMethod {
    +  $Method;
    +}
    +
    +sub CurrentResults {
    +  my $package = shift;
    +  if ( ! scalar @_ ) {
    +    ( ! $Method->{result} ) 	          ? () :
    +    ( ref($Method->{result}) eq 'ARRAY' ) ? @{$Method->{result}} :  
    +					    ${$Method->{result}};
    +  } elsif ( scalar @_ == 1) {
    +    my $value = shift;
    +    $Method->{result} = \$value; 
    +    $value
    +  } else {
    +    my @value = @_;
    +    $Method->{result} = \@value;
    +    @value;
    +  }
    +}
    +
    +sub _build_composite {
    +  my $class = shift;
    +  my $fragments = shift;
    +  map { 
    +    my $method = $_;
    +    my @fragments = @{ $fragments->{''} };
    +    foreach my $flagname ( grep $method->{$_}, qw/ permit modifier / ) {
    +      my $value = $method->{$flagname};
    +      my $fragment = $fragments->{$value}
    +		or croak "Unsupported $flagname flag '$value'";
    +      push @fragments, @$fragment;
    +    }
    +    _bind_composite( $method, @fragments );
    +  } $class->_get_declarations(@_)
    +}
    +
    +sub _assemble_fragments {
    +  my $method = shift;
    +  my @fragments = @_;
    +  while ( scalar @fragments ) {
    +    my ($rule, $sub) = splice( @fragments, 0, 2 );
    +    if ( $rule =~ s/\A\+// ) {
    +      unshift @{$method->{"${rule}_rules"}}, $sub  
    +    } elsif ( $rule =~ s/\+\Z// ) {
    +      push @{$method->{"${rule}_rules"}}, $sub  
    +    } elsif ( $rule =~ /\A\w+\Z/ ) {
    +      @{$method->{"${rule}_rules"}} = $sub;
    +    } else { 	
    +      croak "Unsupported rule type '$rule'"
    +    }
    +  }
    +}
    +
    +sub _bind_composite {
    +  my $method = shift;
    +  _assemble_fragments( $method, @_ );
    +  if ( my $subs = $method->{"init_rules"} ) {
    +    foreach my $sub ( @$subs ) {
    +      &$sub( $method );
    +    }
    +  }
    +  $method->{name} => sub {
    +    local $Method = $method;
    +    local $Method->{args} = [ @_ ];
    +    local $Method->{result};    
    +    local $Method->{scratch};
    +    # Strange but true: you can local a hash-value in hash that's not 
    +    # a package variable. Confirmed in in 5.004, 5.005, 5.6.0.
    +
    +    local $Method->{wantarray} = wantarray;
    +
    +    if ( my $subs = $Method->{"pre_rules"} ) {
    +      foreach my $sub ( @$subs ) {
    +	&$sub( @{$Method->{args}}, $Method );
    +      }
    +    }
    +    
    +    my $subs = $Method->{"do_rules"} 
    +	or Carp::confess("No operations provided for $Method->{name}");
    +    if ( ! defined $Method->{wantarray} ) {
    +      foreach my $sub ( @$subs ) {
    +	last if $Method->{result};
    +	&$sub( @{$Method->{args}}, $Method );	
    +      }
    +    } elsif ( ! $Method->{wantarray} ) {
    +      foreach my $sub ( @$subs ) {
    +	last if $Method->{result};
    +	my $value = &$sub( @{$Method->{args}}, $Method );
    +	if ( defined $value ) { 
    +	  $Method->{result} = \$value;
    +	}
    +      }
    +    } else {
    +      foreach my $sub ( @$subs ) {
    +	last if $Method->{result};
    +	my @value = &$sub( @{$Method->{args}}, $Method );
    +	if ( scalar @value ) { 
    +	  $Method->{result} = \@value;
    +	}
    +      }
    +    }
    +    
    +    if ( my $subs = $Method->{"post_rules"} ) {
    +      foreach my $sub ( @$subs ) {
    +	&$sub( @{$Method->{args}}, $Method );
    +      }
    +    }
    +    
    +    ( ! $Method->{result} ) 	          ? () :
    +    ( ref($Method->{result}) eq 'ARRAY' ) ? @{$Method->{result}} :  
    +					    ${$Method->{result}};
    +  }
    +}
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +For distribution, installation, support, copyright and license 
    +information, see L.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Composite/Array.pm b/lib/Class/MakeMethods/Composite/Array.pm
    new file mode 100644
    index 0000000..fe04eba
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Composite/Array.pm
    @@ -0,0 +1,794 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Composite::Array - Basic array methods
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Array (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +  ...
    +  
    +  my $obj = MyObject->new( foo => 'Foozle' );
    +  print $obj->foo();
    +  
    +  $obj->bar('Barbados');
    +  print $obj->bar();
    +  
    +  $obj->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print $obj->my_list(1);
    +  
    +  $obj->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print $obj->my_index('foo');
    +
    +=head1 DESCRIPTION
    +
    +The Composite::Array suclass of MakeMethods provides a basic
    +constructor and accessors for blessed-array object instances.
    +
    +=head2 Class::MakeMethods Calling Conventions
    +
    +When you C this package, the method declarations you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +You can also omit the arguments to C and instead make methods
    +at runtime by passing the declarations to a subsequent call to
    +C.
    +
    +You may include any number of declarations in each call to C
    +or C. If methods with the same name already exist, earlier
    +calls to C or C win over later ones, but within each
    +call, later declarations superceed earlier ones.
    +
    +You can install methods in a different package by passing C<-TargetClass =E I> as your first arguments to C or C. 
    +
    +See L for more details.
    +
    +=head2 Class::MakeMethods::Basic Declaration Syntax
    +
    +The following types of Basic declarations are supported:
    +
    +=over 4
    +
    +=item *
    +
    +I => "I"
    +
    +=item *
    +
    +I => "I I..."
    +
    +=item *
    +
    +I => [ "I", "I", ...]
    +
    +=back
    +
    +See the "METHOD GENERATOR TYPES" section below for a list of the supported values of I.
    +
    +For each method name you provide, a subroutine of the indicated
    +type will be generated and installed under that name in your module.
    +
    +Method names should start with a letter, followed by zero or more
    +letters, numbers, or underscores.
    +
    +=head2 Class::MakeMethods::Composite Declaration Syntax
    +
    +The Composite syntax also provides several ways to optionally
    +associate a hash of additional parameters with a given method
    +name. 
    +
    +=over 4
    +
    +=item *
    +
    +I => [ "I" => { I=>I... }, ... ]
    +
    +A hash of parameters to use just for this method name. 
    +
    +(Note: to prevent confusion with self-contained definition hashes,
    +described below, parameter hashes following a method name must not
    +contain the key 'name'.)
    +
    +=item *
    +
    +I => [ [ "I", "I", ... ] => { I=>I... } ]
    +
    +Each of these method names gets a copy of the same set of parameters.
    +
    +=item *
    +
    +I => [ { "name"=>"I", I=>I... }, ... ]
    +
    +By including the reserved parameter C, you create a self
    +contained declaration with that name and any associated hash values.
    +
    +=back
    +
    +Basic declarations, as described above, are treated as having an empty parameter hash.
    +
    +=cut
    +
    +package Class::MakeMethods::Composite::Array;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods::Composite '-isasubclass';
    +
    +########################################################################
    +
    +=head2 Positional Accessors and %FIELDS
    +
    +Each accessor method is assigned the next available array index at
    +which to store its value.
    +
    +The mapping between method names and array positions is stored in
    +a hash named %FIELDS in the declaring package. When a package
    +declares its first positional accessor, its %FIELDS are initialized
    +by searching its inheritance tree.
    +
    +B: Subclassing packages that use positional accessors is
    +somewhat fragile, since you may end up with two distinct methods assigned to the same position. Specific cases to avoid are:
    +
    +=over 4
    +
    +=item *
    +
    +If you inherit from more than one class with positional accessors,
    +the positions used by the two sets of methods will overlap.
    +
    +=item *
    +
    +If your superclass adds additional positional accessors after you
    +declare your first, they will overlap yours.
    +
    +=back
    +
    +=cut
    +
    +sub _array_index {
    +  my $class = shift;
    +  my $name = shift;
    +  no strict;
    +  local $^W = 0;
    +  if ( ! scalar %{$class . "::FIELDS"} ) {
    +    my @classes = @{$class . "::ISA"};
    +    my @fields;
    +    while ( @classes ) {
    +      my $superclass = shift @classes;
    +      if ( scalar %{$superclass . "::FIELDS"} ) {
    +	push @fields, %{$superclass . "::FIELDS"};
    +      } else {
    +	unshift @classes, @{$superclass . "::ISA"}
    +      }
    +    }
    +    %{$class . "::FIELDS"} = @fields
    +  }
    +  my $field_hash = \%{$class . "::FIELDS"};
    +  $field_hash->{$name} or $field_hash->{$name} = scalar keys %$field_hash
    +}
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 new - Constructor
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Has a reference to a sample item to copy. This defaults to a reference to an empty array, but you may override this with the C<'defaults' => I> method parameter. 
    +
    +=item *
    +
    +If called as a class method, makes a new array containing values from the sample item, and blesses it into that class.
    +
    +=item *
    +
    +If called on an array-based instance, makes a copy of it and blesses the copy into the same class as the original instance.
    +
    +=item *
    +
    +If passed a list of method-value pairs, calls each named method with the associated value as an argument. 
    +
    +=item *
    +
    +Returns the new instance.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Array (
    +    new => 'new',
    +  );
    +  ...
    +  
    +  # Bare constructor
    +  my $empty = MyObject->new();
    +  
    +  # Constructor with initial sequence of method calls
    +  my $obj = MyObject->new( foo => 'Foozle', bar => 'Barbados' );
    +  
    +  # Copy with overriding sequence of method calls
    +  my $copy = $obj->new( bar => 'Bob' );
    +
    +=cut
    +
    +use vars qw( %ConstructorFragments );
    +
    +sub new {
    +  (shift)->_build_composite( \%ConstructorFragments, @_ );
    +}
    +
    +%ConstructorFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my $method = pop @_;
    +	$method->{target_class} ||= $Class::MethodMaker::CONTEXT{TargetClass};
    +	$method->{defaults} ||= [];
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $obj = ref($self) ? bless( [ @$self ], ref $self ) 
    +			     : bless( { @[$method->{defaults}] }, $self );
    +	@_ = %{$_[0]} 
    +		if ( scalar @_ == 1 and ref $_[0] eq 'HASH' );
    +	while ( scalar @_ ) {
    +	  my $method = shift @_;
    +	  $obj->$method( shift @_ );
    +	}
    +	$obj;
    +      },
    +  ],
    +  'with_values' => [
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	@_ = @[$_[0]] 
    +		if ( scalar @_ == 1 and ref $_[0] eq 'ARRAY' );
    +	bless( [ @_ ], ref($self) || $self );
    +      }
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 new_with_values - Constructor
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or (equivalently) on any existing object of that class. 
    +
    +=item *
    +
    +Creates an array, blesses it into the class, and returns the new instance.
    +
    +=item *
    +
    +If no arguments are provided, the returned array will be empty. If passed a single array-ref argument, copies its contents into the new array. If called with multiple arguments, copies them into the new array. (Note that this is a "shallow" copy, not a "deep" clone.)
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Array (
    +    new => 'new',
    +  );
    +  ...
    +  
    +  # Bare constructor
    +  my $empty = MyObject->new();
    +  
    +  # Constructor with initial sequence of method calls
    +  my $obj = MyObject->new( foo => 'Foozle', bar => 'Barbados' );
    +  
    +  # Copy with overriding sequence of method calls
    +  my $copy = $obj->new( bar => 'Bob' );
    +
    +=cut
    +
    +########################################################################
    +
    +=head2 scalar - Instance Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I> method parameter, or by pre-filling the contents of %FIELDS. 
    +
    +=item *
    +
    +If called without any arguments returns the current value (or undef).
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=item * 
    +
    +If called with multiple arguments, stores a reference to a new array with those arguments as contents, and returns that array reference.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Array (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo('Foozle');
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +use vars qw( %ScalarFragments );
    +
    +sub scalar {
    +  (shift)->_build_composite( \%ScalarFragments, @_ );
    +}
    +
    +%ScalarFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{target_class} ||= $Class::MethodMaker::CONTEXT{TargetClass};
    +	$method->{array_index} ||= 
    +		_array_index( $method->{target_class}, $name );
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	if ( scalar(@_) == 0 ) {
    +	  $self->[$method->{array_index}];
    +	} elsif ( scalar(@_) == 1 ) {
    +	  $self->[$method->{array_index}] = shift;
    +	} else {
    +	  $self->[$method->{array_index}] = [@_];
    +	}
    +      },
    +  ],
    +  'rw' => [],
    +  'p' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( UNIVERSAL::isa((caller(1))[0], $method->{target_class}) ) {
    +	  croak "Method $method->{name} is protected";
    +	}
    +      },
    +  ],
    +  'pp' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( (caller(1))[0] eq $method->{target_class} ) {
    +	  croak "Method $method->{name} is private";
    +	}
    +      },
    +  ],
    +  'pw' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( @$args == 0 or UNIVERSAL::isa((caller(1))[0], $method->{target_class}) ) {
    +	  croak "Method $method->{name} is write-protected";
    +	}
    +      },
    +  ],
    +  'ppw' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( @$args == 0 or (caller(1))[0] eq $method->{target_class} ) {
    +	  croak "Method $method->{name} is write-private";
    +	}
    +      },
    +  ],
    +  'r' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	@$args = ();
    +      },
    +  ],
    +  'ro' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( @$args == 0 ) {
    +	  croak("Method $method->{name} is read-only");
    +	}
    +      },
    +  ],
    +  'wo' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	if ( @$args == 0 ) {
    +	  croak("Method $method->{name} is write-only");
    +	}
    +      },
    +  ],
    +  'return_original' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	$method->{scratch}{return_original} = $self->[$method->{array_index}];
    +      },
    +    '+post' => sub { 
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	$method->{result} = \{ $method->{scratch}{return_original} };
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 array - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I> method parameter, or by pre-filling the contents of %FIELDS. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current array-ref value (or undef).
    +
    +=item *
    +
    +If called with a single non-ref argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef).
    +
    +=item *
    +
    +If called with a single array ref argument, uses that list to return a slice of the referenced array.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with a non-ref index and an associated value, stores the value at the given index in the referenced array. If the instance's value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with the first item being a reference to an array of up to two numbers, loops over each pair and uses those numbers to splice the value array. 
    +
    +The first controlling number is the position at which the splice will begin. Zero will start before the first item in the list. Negative numbers count backwards from the end of the array. 
    +
    +The second number is the number of items to be removed from the list. If it is omitted, or undefined, or zero, no items are removed. If it is a positive integer, that many items will be returned.
    +
    +If both numbers are omitted, or are both undefined, they default to containing the entire value array.
    +
    +If the second argument is undef, no values will be inserted; if it is a non-reference value, that one value will be inserted; if it is an array-ref, its values will be copied.
    +
    +The method returns the items that removed from the array, if any.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Array (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Clear and set contents of list
    +  print $obj->bar([ 'Spume', 'Frost' ] );  
    +  
    +  # Set values by position
    +  $obj->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  $obj->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print $obj->bar(1);
    +  
    +  # Direct access to referenced array
    +  print scalar @{ $obj->bar() };
    +
    +There are also calling conventions for slice and splice operations:
    +
    +  # Retrieve slice of values by position
    +  print join(', ', $obj->bar( undef, [0, 2] ) );
    +  
    +  # Insert an item at position in the array
    +  $obj->bar([3], 'Potatoes' );  
    +  
    +  # Remove 1 item from position 3 in the array
    +  $obj->bar([3, 1], undef );  
    +  
    +  # Set a new value at position 2, and return the old value 
    +  print $obj->bar([2, 1], 'Froth' );
    +
    +=cut
    +
    +
    +use vars qw( %ArrayFragments );
    +
    +sub array {
    +  (shift)->_build_composite( \%ArrayFragments, @_ );
    +}
    +
    +%ArrayFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{target_class} ||= $Class::MethodMaker::CONTEXT{TargetClass};
    +	$method->{array_index} ||= 
    +		_array_index( $method->{target_class}, $name );
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	if ( scalar(@$args) == 0 ) {
    +	  if ( $method->{auto_init} and 
    +			! defined $self->[$method->{array_index}] ) {
    +	    $self->[$method->{array_index}] = [];
    +	  }
    +	  wantarray ? @{ $self->[$method->{array_index}] } : $self->[$method->{array_index}];
    +	} elsif ( scalar(@_) == 1 and ref $_[0] eq 'ARRAY' ) {
    +	  $self->[$method->{array_index}] = [ @{ $_[0] } ];
    +	  wantarray ? @{ $self->[$method->{array_index}] } : $self->[$method->{array_index}];
    +	} else {
    +	  $self->[$method->{array_index}] ||= [];
    +	  Class::MakeMethods::Composite::__array_ops( 
    +		$self->[$method->{array_index}], @$args );
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 hash - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I> method parameter, or by pre-filling the contents of %FIELDS. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the contents of the hash in list context, or a hash reference in scalar context (or undef).
    +
    +=item *
    +
    +If called with one non-ref argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef).
    +
    +=item *
    +
    +If called with one array-ref argument, uses the contents of that array to retrieve a slice of the referenced hash.
    +
    +=item *
    +
    +If called with one hash-ref argument, sets the contents of the referenced hash to match that provided.
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the instance's value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the contents of the hash in list context, or a hash reference in scalar context.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Array (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  $obj->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  $obj->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print $obj->baz('foo');
    +  
    +  # Retrive slice of values by position
    +  print join(', ', $obj->baz( ['foo', 'bar'] ) );
    +  
    +  # Direct access to referenced hash
    +  print keys %{ $obj->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ $obj->baz() } = ();
    +
    +=cut
    +
    +
    +use vars qw( %HashFragments );
    +
    +sub hash {
    +  (shift)->_build_composite( \%HashFragments, @_ );
    +}
    +
    +%HashFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $_->{name};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	if ( scalar(@$args) == 0 ) {
    +	  if ( $method->{auto_init} and ! defined $self->[$method->{array_index}] ) {
    +	    $self->[$method->{array_index}] = {};
    +	  }
    +	  wantarray ? %{ $self->[$method->{array_index}] } : $self->[$method->{array_index}];
    +	} elsif ( scalar(@$args) == 1 ) {
    +	  if ( ref($_[0]) eq 'HASH' ) {
    +	    %{$self->[$method->{array_index}]} = %{$_[0]};
    +	  } elsif ( ref($_[0]) eq 'ARRAY' ) {
    +	    return @{$self->[$method->{array_index}]}{ @{$_[0]} }
    +	  } else {
    +	    return $self->[$method->{array_index}]->{ $_[0] }
    +	  }
    +	} elsif ( scalar(@$args) % 2 ) {
    +	  croak "Odd number of items in assigment to $method->{name}";
    +	} else {
    +	  while ( scalar(@$args) ) {
    +	    my $key = shift @$args;
    +	    $self->[$method->{array_index}]->{ $key} = shift @$args;
    +	  }
    +	  wantarray ? %{ $self->[$method->{array_index}] } : $self->[$method->{array_index}];
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 object - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I> method parameter, or by pre-filling the contents of %FIELDS. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to an object (or undef).
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Hash (
    +    object => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo( Foozle->new() );
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +use vars qw( %ObjectFragments );
    +
    +sub object {
    +  (shift)->_build_composite( \%ObjectFragments, @_ );
    +}
    +
    +%ObjectFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $_->{name};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift;
    +	if ( scalar @_ ) {
    +	  my $value = shift;
    +	  if ( $method->{class} and ! UNIVERSAL::isa( $value, $method->{class} ) ) {
    +	    croak "Wrong argument type ('$value') in assigment to $method->{name}";
    +	  }
    +	  $self->[$method->{array_index}] = $value;
    +	} else {
    +	  if ( $method->{auto_init} and ! defined $self->[$method->{array_index}] ) {
    +	    my $class = $method->{class} 
    +				or die "Can't auto_init without a class";
    +	    my $new_method = $method->{new_method} || 'new';
    +	    $self->[$method->{array_index}] = $class->$new_method();
    +	  }
    +	  $self->[$method->{array_index}];
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Composite/Global.pm b/lib/Class/MakeMethods/Composite/Global.pm
    new file mode 100644
    index 0000000..cf9af0b
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Composite/Global.pm
    @@ -0,0 +1,588 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Composite::Global - Global data
    +
    +=head1 SYNOPSIS
    +
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Global (
    +    scalar => [ 'foo' ],
    +    array  => [ 'my_list' ],
    +    hash   => [ 'my_index' ],
    +  );
    +  ...
    +  
    +  MyClass->foo( 'Foozle' );
    +  print MyClass->foo();
    +
    +  print MyClass->new(...)->foo(); # same value for any instance
    +  print MySubclass->foo();        # ... and for any subclass
    +  
    +  MyClass->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print MyClass->my_list(1);
    +  
    +  MyClass->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print MyClass->my_index('foo');
    +
    +
    +=head1 DESCRIPTION
    +
    +The Composite::Global suclass of MakeMethods provides basic accessors for shared data.
    +
    +=head2 Class::MakeMethods Calling Interface
    +
    +When you C this package, the method declarations you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +You can also omit the arguments to C and instead make methods
    +at runtime by passing the declarations to a subsequent call to
    +C.
    +
    +You may include any number of declarations in each call to C
    +or C. If methods with the same name already exist, earlier
    +calls to C or C win over later ones, but within each
    +call, later declarations superceed earlier ones.
    +
    +You can install methods in a different package by passing C<-TargetClass =E I> as your first arguments to C or C. 
    +
    +See L for more details.
    +
    +=head2 Class::MakeMethods::Basic Declaration Syntax
    +
    +The following types of Basic declarations are supported:
    +
    +=over 4
    +
    +=item *
    +
    +I => "I"
    +
    +=item *
    +
    +I => "I I..."
    +
    +=item *
    +
    +I => [ "I", "I", ...]
    +
    +=back
    +
    +See the "METHOD GENERATOR TYPES" section below for a list of the supported values of I.
    +
    +For each method name you provide, a subroutine of the indicated
    +type will be generated and installed under that name in your module.
    +
    +Method names should start with a letter, followed by zero or more
    +letters, numbers, or underscores.
    +
    +=head2 Class::MakeMethods::Composite Declaration Syntax
    +
    +The Composite syntax also provides several ways to optionally
    +associate a hash of additional parameters with a given method
    +name. 
    +
    +=over 4
    +
    +=item *
    +
    +I => [ "I" => { I=>I... }, ... ]
    +
    +A hash of parameters to use just for this method name. 
    +
    +(Note: to prevent confusion with self-contained definition hashes,
    +described below, parameter hashes following a method name must not
    +contain the key 'name'.)
    +
    +=item *
    +
    +I => [ [ "I", "I", ... ] => { I=>I... } ]
    +
    +Each of these method names gets a copy of the same set of parameters.
    +
    +=item *
    +
    +I => [ { "name"=>"I", I=>I... }, ... ]
    +
    +By including the reserved parameter C, you create a self-contained declaration with that name and any associated hash values.
    +
    +=back
    +
    +Basic declarations, as described above, are given an empty parameter hash.
    +
    +=cut
    +
    +package Class::MakeMethods::Composite::Global;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods::Composite '-isasubclass';
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 scalar - Global Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, and behaves identically regardless of what it was called on.
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=item * 
    +
    +If called with multiple arguments, stores a reference to a new array with those arguments as contents, and returns that array reference.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Global (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  MyClass->foo('Foozle');
    +  
    +  # Retrieve value
    +  print MyClass->foo;
    +
    +=cut
    +
    +use vars qw( %ScalarFragments );
    +
    +sub scalar {
    +  (shift)->_build_composite( \%ScalarFragments, @_ );
    +}
    +
    +%ScalarFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{target_class} ||= $Class::MethodMaker::CONTEXT{TargetClass};
    +	$method->{array_index} ||= 
    +		_array_index( $method->{target_class}, $name );
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	if ( scalar(@_) == 0 ) {
    +	  $method->{global_data};
    +	} elsif ( scalar(@_) == 1 ) {
    +	  $method->{global_data} = shift;
    +	} else {
    +	  $method->{global_data} = [@_];
    +	}
    +      },
    +  ],
    +  'rw' => [],
    +  'p' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	unless ( UNIVERSAL::isa((caller(1))[0], $method->{target_class}) ) {
    +	  croak "Method $method->{name} is protected";
    +	}
    +      },
    +  ],
    +  'pp' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	unless ( (caller(1))[0] eq $method->{target_class} ) {
    +	  croak "Method $method->{name} is private";
    +	}
    +      },
    +  ],
    +  'pw' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( @$args == 0 or UNIVERSAL::isa((caller(1))[0], $method->{target_class}) ) {
    +	  croak "Method $method->{name} is write-protected";
    +	}
    +      },
    +  ],
    +  'ppw' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( @$args == 0 or (caller(1))[0] eq $method->{target_class} ) {
    +	  croak "Method $method->{name} is write-private";
    +	}
    +      },
    +  ],
    +  'r' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	@{$method->{args}} = ($self) if ( scalar @_ );
    +      },
    +  ],
    +  'ro' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( @$args == 0 ) {
    +	  croak("Method $method->{name} is read-only");
    +	}
    +      },
    +  ],
    +  'wo' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	if ( @$args == 0 ) {
    +	  croak("Method $method->{name} is write-only");
    +	}
    +      },
    +  ],
    +  'return_original' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	$method->{scratch}{return_original} = $method->{global_data};
    +      },
    +    '+post' => sub { 
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	$method->{result} = \{ $method->{scratch}{return_original} };
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 array - Global Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, and behaves identically regardless of what it was called on.
    +
    +=item * 
    +
    +The global value will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current array-ref value (or undef).
    +
    +
    +=item *
    +
    +If called with a single non-ref argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef).
    +
    +=item *
    +
    +If called with a single array ref argument, uses that list to return a slice of the referenced array.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with a non-ref index and an associated value, stores the value at the given index in the referenced array. If the global value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with the first item being a reference to an array of up to two numbers, loops over each pair and uses those numbers to splice the value array. 
    +
    +The first controlling number is the position at which the splice will begin. Zero will start before the first item in the list. Negative numbers count backwards from the end of the array. 
    +
    +The second number is the number of items to be removed from the list. If it is omitted, or undefined, or zero, no items are removed. If it is a positive integer, that many items will be returned.
    +
    +If both numbers are omitted, or are both undefined, they default to containing the entire value array.
    +
    +If the second argument is undef, no values will be inserted; if it is a non-reference value, that one value will be inserted; if it is an array-ref, its values will be copied.
    +
    +The method returns the items that removed from the array, if any.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Global (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Clear and set contents of list
    +  print MyClass->bar([ 'Spume', 'Frost' ] );  
    +  
    +  # Set values by position
    +  MyClass->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  MyClass->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print MyClass->bar(1);
    +  
    +  # Direct access to referenced array
    +  print scalar @{ MyClass->bar() };
    +
    +There are also calling conventions for slice and splice operations:
    +
    +  # Retrieve slice of values by position
    +  print join(', ', MyClass->bar( undef, [0, 2] ) );
    +  
    +  # Insert an item at position in the array
    +  MyClass->bar([3], 'Potatoes' );  
    +  
    +  # Remove 1 item from position 3 in the array
    +  MyClass->bar([3, 1], undef );  
    +  
    +  # Set a new value at position 2, and return the old value 
    +  print MyClass->bar([2, 1], 'Froth' );
    +
    +=cut
    +
    +
    +use vars qw( %ArrayFragments );
    +
    +sub array {
    +  (shift)->_build_composite( \%ArrayFragments, @_ );
    +}
    +
    +%ArrayFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $_->{name};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	if ( scalar(@$args) == 0 ) {
    +	  if ( $method->{auto_init} and 
    +			! defined $method->{global_data} ) {
    +	    $method->{global_data} = [];
    +	  }
    +	  wantarray ? @{ $method->{global_data} } : $method->{global_data}
    +	} elsif ( scalar(@_) == 1 and ref $_[0] eq 'ARRAY' ) {
    +	  $method->{global_data} = [ @{ $_[0] } ];
    +	  wantarray ? @{ $method->{global_data} } : $method->{global_data}
    +	} else {
    +	  $method->{global_data} ||= [];
    +	  Class::MakeMethods::Composite::__array_ops( 
    +		$method->{global_data}, @$args );
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 hash - Global Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, and behaves identically regardless of what it was called on.
    +
    +=item * 
    +
    +The global value will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the contents of the hash in list context, or a hash reference in scalar context (or undef).
    +
    +=item *
    +
    +If called with one non-ref argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef).
    +
    +=item *
    +
    +If called with one array-ref argument, uses the contents of that array to retrieve a slice of the referenced hash.
    +
    +=item *
    +
    +If called with one hash-ref argument, sets the contents of the referenced hash to match that provided.
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the global value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the contents of the hash in list context, or a hash reference in scalar context.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Global (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  MyClass->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  MyClass->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print MyClass->baz('foo');
    +  
    +  # Retrive slice of values by position
    +  print join(', ', MyClass->baz( ['foo', 'bar'] ) );
    +  
    +  # Direct access to referenced hash
    +  print keys %{ MyClass->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ MyClass->baz() } = ();
    +
    +=cut
    +
    +use vars qw( %HashFragments );
    +
    +sub hash {
    +  (shift)->_build_composite( \%HashFragments, @_ );
    +}
    +
    +%HashFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $_->{name};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	if ( scalar(@$args) == 0 ) {
    +	  if ( $method->{auto_init} and ! defined $method->{global_data} ) {
    +	    $method->{global_data} = {};
    +	  }
    +	  wantarray ? %{ $method->{global_data} } : $method->{global_data};
    +	} elsif ( scalar(@$args) == 1 ) {
    +	  if ( ref($_[0]) eq 'HASH' ) {
    +	    %{$method->{global_data}} = %{$_[0]};
    +	  } elsif ( ref($_[0]) eq 'ARRAY' ) {
    +	    return @{$method->{global_data}}{ @{$_[0]} }
    +	  } else {
    +	    return $method->{global_data}->{ $_[0] }
    +	  }
    +	} elsif ( scalar(@$args) % 2 ) {
    +	  croak "Odd number of items in assigment to $method->{name}";
    +	} else {
    +	  while ( scalar(@$args) ) {
    +	    my $key = shift @$args;
    +	    $method->{global_data}->{ $key} = shift @$args;
    +	  }
    +	  wantarray ? %{ $method->{global_data} } : $method->{global_data};
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 object - Global Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, and behaves identically regardless of what it was called on.
    +
    +=item * 
    +
    +The global value will be a reference to an object (or undef).
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Global (
    +    object => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  MyClass->foo( Foozle->new() );
    +  
    +  # Retrieve value
    +  print MyClass->foo;
    +
    +=cut
    +
    +use vars qw( %ObjectFragments );
    +
    +sub object {
    +  (shift)->_build_composite( \%ObjectFragments, @_ );
    +}
    +
    +%ObjectFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $_->{name};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift;
    +	if ( scalar @_ ) {
    +	  my $value = shift;
    +	  if ( $method->{class} and ! UNIVERSAL::isa( $value, $method->{class} ) ) {
    +	    croak "Wrong argument type ('$value') in assigment to $method->{name}";
    +	  }
    +	  $method->{global_data} = $value;
    +	} else {
    +	  if ( $method->{auto_init} and ! defined $method->{global_data} ) {
    +	    my $class = $method->{class} 
    +				or die "Can't auto_init without a class";
    +	    my $new_method = $method->{new_method} || 'new';
    +	    $method->{global_data} = $class->$new_method();
    +	  }
    +	  $method->{global_data};
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Composite/Hash.pm b/lib/Class/MakeMethods/Composite/Hash.pm
    new file mode 100644
    index 0000000..969bdd0
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Composite/Hash.pm
    @@ -0,0 +1,719 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Composite::Hash - Composite hash methods
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Hash (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +  ...
    +  
    +  my $obj = MyObject->new( foo => 'Foozle' );
    +  print $obj->foo();
    +  
    +  $obj->bar('Barbados'); 
    +  print $obj->bar();
    +  
    +  $obj->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print $obj->my_list(1);
    +  
    +  $obj->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print $obj->my_index('foo');
    +
    +=head1 DESCRIPTION
    +
    +The Composite::Hash suclass of MakeMethods provides a basic constructor and accessors for blessed-hash object instances.
    +
    +=head2 Class::MakeMethods Calling Interface
    +
    +When you C this package, the method declarations you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +You can also omit the arguments to C and instead make methods
    +at runtime by passing the declarations to a subsequent call to
    +C.
    +
    +You may include any number of declarations in each call to C
    +or C. If methods with the same name already exist, earlier
    +calls to C or C win over later ones, but within each
    +call, later declarations superceed earlier ones.
    +
    +You can install methods in a different package by passing C<-TargetClass =E I> as your first arguments to C or C. 
    +
    +See L for more details.
    +
    +=head2 Class::MakeMethods::Basic Declaration Syntax
    +
    +The following types of Basic declarations are supported:
    +
    +=over 4
    +
    +=item *
    +
    +I => "I"
    +
    +=item *
    +
    +I => "I I..."
    +
    +=item *
    +
    +I => [ "I", "I", ...]
    +
    +=back
    +
    +See the "METHOD GENERATOR TYPES" section below for a list of the supported values of I.
    +
    +For each method name you provide, a subroutine of the indicated
    +type will be generated and installed under that name in your module.
    +
    +Method names should start with a letter, followed by zero or more
    +letters, numbers, or underscores.
    +
    +=head2 Class::MakeMethods::Composite Declaration Syntax
    +
    +The Composite syntax also provides several ways to optionally
    +associate a hash of additional parameters with a given method
    +name. 
    +
    +=over 4
    +
    +=item *
    +
    +I => [ "I" => { I=>I... }, ... ]
    +
    +A hash of parameters to use just for this method name. 
    +
    +(Note: to prevent confusion with self-contained definition hashes,
    +described below, parameter hashes following a method name must not
    +contain the key 'name'.)
    +
    +=item *
    +
    +I => [ [ "I", "I", ... ] => { I=>I... } ]
    +
    +Each of these method names gets a copy of the same set of parameters.
    +
    +=item *
    +
    +I => [ { "name"=>"I", I=>I... }, ... ]
    +
    +By including the reserved parameter C, you create a self-contained declaration with that name and any associated hash values.
    +
    +=back
    +
    +Basic declarations, as described above, are given an empty parameter hash.
    +
    +=cut
    +
    +package Class::MakeMethods::Composite::Hash;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods::Composite '-isasubclass';
    +use Carp;
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 new - Constructor
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Has a reference to a sample item to copy. This defaults to a reference to an empty hash, but you may override this with the C<'defaults' =E I>  method parameter. 
    +
    +=item *
    +
    +If called as a class method, makes a new hash and blesses it into that class.
    +
    +=item *
    +
    +If called on a hash-based instance, makes a copy of it and blesses the copy into the same class as the original instance.
    +
    +=item *
    +
    +If passed a list of key-value pairs, appends them to the new hash. These arguments override any copied values, and later arguments with the same name will override earlier ones.
    +
    +=item *
    +
    +Returns the new instance.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Hash (
    +    new => 'new',
    +  );
    +  ...
    +  
    +  # Bare constructor
    +  my $empty = MyObject->new();
    +  
    +  # Constructor with initial values
    +  my $obj = MyObject->new( foo => 'Foozle', bar => 'Barbados' );
    +  
    +  # Copy with overriding value
    +  my $copy = $obj->new( bar => 'Bob' );
    +
    +=cut
    +
    +=head2 new --with_values - Constructor
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or (equivalently) on any existing object of that class. 
    +
    +=item *
    +
    +Creates a hash, blesses it into the class, and returns the new instance.
    +
    +=item *
    +
    +If no arguments are provided, the returned hash will be empty. If passed a single hash-ref argument, copies its contents into the new hash. If called with multiple arguments, treats them as key-value pairs, and copies them into the new hash. (Note that this is a "shallow" copy, not a "deep" clone.)
    +
    +=back
    +
    +=cut
    +
    +use vars qw( %ConstructorFragments );
    +
    +sub new {
    +  (shift)->_build_composite( \%ConstructorFragments, @_ );
    +}
    +
    +%ConstructorFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my $method = pop @_;
    +	$method->{target_class} ||= $Class::MethodMaker::CONTEXT{TargetClass};
    +	$method->{defaults} ||= {};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $obj = ref($self) ? bless( { %$self }, ref $self ) 
    +			     : bless( { %{$method->{defaults}} }, $self );
    +	@_ = %{$_[0]} 
    +		if ( scalar @_ == 1 and ref $_[0] eq 'HASH' );
    +	while ( scalar @_ ) {
    +	  my $method = shift @_;
    +	  my $value = shift @_;
    +	  $obj->$method( $value );
    +	}
    +	$obj;
    +      },
    +  ],
    +  'with_values' => [
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	@_ = %{$_[0]} 
    +		if ( scalar @_ == 1 and ref $_[0] eq 'HASH' );
    +	bless( { @_ }, ref($self) || $self );
    +      }
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 scalar - Instance Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Has a specific hash key to use to access the related value for each instance.
    +This defaults to the method name, but you may override this with the C<'hash_key' => I> method parameter. 
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it.
    +
    +=item * 
    +
    +If called with multiple arguments, stores a reference to a new array with those arguments as contents, and returns that array reference.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Hash (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo('Foozle');
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +use vars qw( %ScalarFragments );
    +
    +sub scalar {
    +  (shift)->_build_composite( \%ScalarFragments, @_ );
    +}
    +
    +%ScalarFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $method->{name};
    +	$method->{target_class} ||= $Class::MethodMaker::CONTEXT{TargetClass};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	if ( scalar(@_) == 0 ) {
    +	  $self->{$method->{hash_key}};
    +	} elsif ( scalar(@_) == 1 ) {
    +	  $self->{$method->{hash_key}} = shift;
    +	} else {
    +	  $self->{$method->{hash_key}} = [@_];
    +	}
    +      },
    +  ],
    +  'rw' => [],
    +  'p' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	unless ( UNIVERSAL::isa((caller(1))[0], $method->{target_class}) ) {
    +	  croak "Method $method->{name} is protected";
    +	}
    +      },
    +  ],
    +  'pp' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	unless ( (caller(1))[0] eq $method->{target_class} ) {
    +	  croak "Method $method->{name} is private";
    +	}
    +      },
    +  ],
    +  'pw' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( @$args == 0 or UNIVERSAL::isa((caller(1))[0], $method->{target_class}) ) {
    +	  croak "Method $method->{name} is write-protected";
    +	}
    +      },
    +  ],
    +  'ppw' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( @$args == 0 or (caller(1))[0] eq $method->{target_class} ) {
    +	  croak "Method $method->{name} is write-private";
    +	}
    +      },
    +  ],
    +  'r' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	@$args = ();
    +      },
    +  ],
    +  'ro' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	unless ( @$args == 0 ) {
    +	  croak("Method $method->{name} is read-only");
    +	}
    +      },
    +  ],
    +  'wo' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	if ( @$args == 0 ) {
    +	  croak("Method $method->{name} is write-only");
    +	}
    +      },
    +  ],
    +  'return_original' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	$method->{scratch}{return_original} = $self->{$method->{hash_key}};
    +      },
    +    '+post' => sub { 
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	${ $method->{result} } = $method->{scratch}{return_original};
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 array - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Has a specific hash key to use to access the related value for each instance.
    +This defaults to the method name, but you may override this with the C<'hash_key' => I> method parameter. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current array-ref value (or undef).
    +
    +
    +=item *
    +
    +If called with a single non-ref argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef).
    +
    +=item *
    +
    +If called with a single array ref argument, uses that list to return a slice of the referenced array.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with a non-ref index and an associated value, stores the value at the given index in the referenced array. If the instance's value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with the first item being a reference to an array of up to two numbers, loops over each pair and uses those numbers to splice the value array. 
    +
    +The first controlling number is the position at which the splice will begin. Zero will start before the first item in the list. Negative numbers count backwards from the end of the array. 
    +
    +The second number is the number of items to be removed from the list. If it is omitted, or undefined, or zero, no items are removed. If it is a positive integer, that many items will be returned.
    +
    +If both numbers are omitted, or are both undefined, they default to containing the entire value array.
    +
    +If the second argument is undef, no values will be inserted; if it is a non-reference value, that one value will be inserted; if it is an array-ref, its values will be copied.
    +
    +The method returns the items that removed from the array, if any.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Hash (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Clear and set contents of list
    +  print $obj->bar([ 'Spume', 'Frost' ] );  
    +  
    +  # Set values by position
    +  $obj->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  $obj->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print $obj->bar(1);
    +  
    +  # Direct access to referenced array
    +  print scalar @{ $obj->bar() };
    +
    +There are also calling conventions for slice and splice operations:
    +
    +  # Retrieve slice of values by position
    +  print join(', ', $obj->bar( undef, [0, 2] ) );
    +  
    +  # Insert an item at position in the array
    +  $obj->bar([3], 'Potatoes' );  
    +  
    +  # Remove 1 item from position 3 in the array
    +  $obj->bar([3, 1], undef );  
    +  
    +  # Set a new value at position 2, and return the old value 
    +  print $obj->bar([2, 1], 'Froth' );
    +
    +=cut
    +
    +use vars qw( %ArrayFragments );
    +
    +sub array {
    +  (shift)->_build_composite( \%ArrayFragments, @_ );
    +}
    +
    +%ArrayFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $_->{name};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	if ( scalar(@$args) == 0 ) {
    +	  if ( $method->{auto_init} and 
    +			! defined $self->{$method->{hash_key}} ) {
    +	    $self->{$method->{hash_key}} = [];
    +	  }
    +	  wantarray ? @{ $self->{$method->{hash_key}} } : $self->{$method->{hash_key}};
    +	} elsif ( scalar(@_) == 1 and ref $_[0] eq 'ARRAY' ) {
    +	  $self->{$method->{hash_key}} = [ @{ $_[0] } ];
    +	  wantarray ? @{ $self->{$method->{hash_key}} } : $self->{$method->{hash_key}};
    +	} else {
    +	  $self->{$method->{hash_key}} ||= [];
    +	  array_splicer( $self->{$method->{hash_key}}, @$args );
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 hash - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Has a specific hash key to use to access the related value for each instance.
    +This defaults to the method name, but you may override this with the C<'hash_key' => I> method parameter. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the contents of the hash in list context, or a hash reference in scalar context (or undef).
    +
    +=item *
    +
    +If called with one non-ref argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef).
    +
    +=item *
    +
    +If called with one array-ref argument, uses the contents of that array to retrieve a slice of the referenced hash.
    +
    +=item *
    +
    +If called with one hash-ref argument, sets the contents of the referenced hash to match that provided.
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the instance's value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the contents of the hash in list context, or a hash reference in scalar context.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Hash (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  $obj->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  $obj->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print $obj->baz('foo');
    +  
    +  # Retrive slice of values by position
    +  print join(', ', $obj->baz( ['foo', 'bar'] ) );
    +  
    +  # Direct access to referenced hash
    +  print keys %{ $obj->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ $obj->baz() } = ();
    +
    +=cut
    +
    +use vars qw( %HashFragments );
    +
    +sub hash {
    +  (shift)->_build_composite( \%HashFragments, @_ );
    +}
    +
    +%HashFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $_->{name};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $args = \@_;
    +	if ( scalar(@$args) == 0 ) {
    +	  if ( $method->{auto_init} and ! defined $self->{$method->{hash_key}} ) {
    +	    $self->{$method->{hash_key}} = {};
    +	  }
    +	  wantarray ? %{ $self->{$method->{hash_key}} } : $self->{$method->{hash_key}};
    +	} elsif ( scalar(@$args) == 1 ) {
    +	  if ( ref($_[0]) eq 'HASH' ) {
    +	    %{$self->{$method->{hash_key}}} = %{$_[0]};
    +	  } elsif ( ref($_[0]) eq 'ARRAY' ) {
    +	    return @{$self->{$method->{hash_key}}}{ @{$_[0]} }
    +	  } else {
    +	    return $self->{$method->{hash_key}}->{ $_[0] }
    +	  }
    +	} elsif ( scalar(@$args) % 2 ) {
    +	  croak "Odd number of items in assigment to $method->{name}";
    +	} else {
    +	  while ( scalar(@$args) ) {
    +	    my $key = shift @$args;
    +	    $self->{$method->{hash_key}}->{ $key} = shift @$args;
    +	  }
    +	  wantarray ? %{ $self->{$method->{hash_key}} } : $self->{$method->{hash_key}};
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 object - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Has a specific hash key to use to access the related value for each instance.
    +This defaults to the method name, but you may override this with the C<'hash_key' => I> method parameter. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to an object (or undef).
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Composite::Hash (
    +    object => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo( Foozle->new() );
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +use vars qw( %ObjectFragments );
    +
    +sub object {
    +  (shift)->_build_composite( \%ObjectFragments, @_ );
    +}
    +
    +%ObjectFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $_->{name};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift;
    +	if ( scalar @_ ) {
    +	  my $value = shift;
    +	  if ( $method->{class} and ! UNIVERSAL::isa( $value, $method->{class} ) ) {
    +	    croak "Wrong argument type ('$value') in assigment to $method->{name}";
    +	  }
    +	  $self->{$method->{hash_key}} = $value;
    +	} else {
    +	  if ( $method->{auto_init} and ! defined $self->{$method->{hash_key}} ) {
    +	    my $class = $method->{class} 
    +				or die "Can't auto_init without a class";
    +	    my $new_method = $method->{new_method} || 'new';
    +	    $self->{$method->{hash_key}} = $class->$new_method();
    +	  }
    +	  $self->{$method->{hash_key}};
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Composite/Inheritable.pm b/lib/Class/MakeMethods/Composite/Inheritable.pm
    new file mode 100644
    index 0000000..ca4be3e
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Composite/Inheritable.pm
    @@ -0,0 +1,613 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Composite::Inheritable - Overridable data
    +
    +=head1 SYNOPSIS
    +
    +  package MyClass;
    +
    +  use Class::MakeMethods( 'Composite::Inheritable:scalar' => 'foo' );
    +  # We now have an accessor method for an "inheritable" scalar value
    +  
    +  MyClass->foo( 'Foozle' );   # Set a class-wide value
    +  print MyClass->foo();	      # Retrieve class-wide value
    +  
    +  my $obj = MyClass->new(...);
    +  print $obj->foo();          # All instances "inherit" that value...
    +  
    +  $obj->foo( 'Foible' );      # until you set a value for an instance.
    +  print $obj->foo();          # This now finds object-specific value.
    +  ...
    +  
    +  package MySubClass;
    +  @ISA = 'MyClass';
    +  
    +  print MySubClass->foo();    # Intially same as superclass,
    +  MySubClass->foo('Foobar');  # but overridable per subclass,
    +  print $subclass_obj->foo(); # and shared by its instances
    +  $subclass_obj->foo('Fosil');# until you override them... 
    +  ...
    +  
    +  # Similar behaviour for hashes and arrays is currently incomplete
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Inheritable (
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +  
    +  MyClass->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print MyClass->my_list(1);
    +  
    +  MyClass->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print MyClass->my_index('foo');
    +
    +
    +=head1 DESCRIPTION
    +
    +The MakeMethods subclass provides accessor methods that search an inheritance tree to find a value. This allows you to set a shared or default value for a given class, optionally override it in a subclass, and then optionally override it on a per-instance basis. 
    +
    +Note that all MakeMethods methods are inheritable, in the sense that they work as expected for subclasses. These methods are different in that the I accessed by each method can be inherited or overridden in each subclass or instance. See L< Class::MakeMethods::Utility::Inheritable> for more about this type of "inheritable" or overridable" data.
    +
    +
    +=head2 Class::MakeMethods Calling Interface
    +
    +When you C this package, the method declarations you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for more information.
    +
    +=head2 Class::MakeMethods::Standard Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. 
    +
    +See the "METHOD GENERATOR TYPES" section below for a list of the supported values of I.
    +
    +See L and L for more information.
    +
    +=cut
    +
    +package Class::MakeMethods::Composite::Inheritable;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Carp;
    +
    +use Class::MakeMethods::Composite '-isasubclass';
    +use Class::MakeMethods::Utility::Inheritable qw(get_vvalue set_vvalue find_vself );
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 scalar - Overrideable Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class or instance method, on the declaring class or any subclass. 
    +
    +=item *
    +
    +If called without any arguments returns the current value for the callee. If the callee has not had a value defined for this method, searches up from instance to class, and from class to superclass, until a callee with a value is located.
    +
    +=item *
    +
    +If called with an argument, stores that as the value associated with the callee, whether instance or class, and returns it, 
    +
    +=item * 
    +
    +If called with multiple arguments, stores a reference to a new array with those arguments as contents, and returns that array reference.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Inheritable (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  MyClass->foo('Foozle');
    +  
    +  # Retrieve value
    +  print MyClass->foo;
    +
    +=cut
    +
    +use vars qw( %ScalarFragments );
    +
    +sub scalar {
    +  (shift)->_build_composite( \%ScalarFragments, @_ );
    +}
    +
    +%ScalarFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{target_class} ||= $Class::MethodMaker::CONTEXT{TargetClass};
    +	$method->{data} ||= {};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;	
    +	if ( scalar(@_) == 0 ) {
    +	  return get_vvalue($method->{data}, $self);
    +	} else {
    +	  my $value = (@_ == 1 ? $_[0] : [@_]);
    +	  set_vvalue($method->{data}, $self, $value);
    +	}
    +      },
    +  ],
    +  'rw' => [],
    +  'p' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	unless ( UNIVERSAL::isa((caller(1))[0], $method->{target_class}) ) {
    +	  croak "Method $method->{name} is protected";
    +	}
    +      },
    +  ],
    +  'pp' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	unless ( (caller(1))[0] eq $method->{target_class} ) {
    +	  croak "Method $method->{name} is private";
    +	}
    +      },
    +  ],
    +  'pw' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	unless ( @_ == 0 or UNIVERSAL::isa((caller(1))[0], $method->{target_class}) ) {
    +	  croak "Method $method->{name} is write-protected";
    +	}
    +      },
    +  ],
    +  'ppw' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	unless ( @_ == 0 or (caller(1))[0] eq $method->{target_class} ) {
    +	  croak "Method $method->{name} is write-private";
    +	}
    +      },
    +  ],
    +  'r' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	@{ $method->{args} } = ();
    +      },
    +  ],
    +  'ro' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	unless ( @_ == 0 ) {
    +	  croak("Method $method->{name} is read-only");
    +	}
    +      },
    +  ],
    +  'wo' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	if ( @_ == 0 ) {
    +	  croak("Method $method->{name} is write-only");
    +	}
    +      },
    +  ],
    +  'return_original' => [ 
    +    '+pre' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	my $v_self = find_vself($method->{data}, $self);
    +	$method->{scratch}{return_original} = 
    +					$v_self ? $method->{data}{$v_self} : ();
    +      },
    +    '+post' => sub { 
    +	my $method = pop @_;
    +	$method->{result} = \{ $method->{scratch}{return_original} };
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 array - Overrideable Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, Must be called on a hash-based instance.
    +
    +=item * 
    +
    +The class value will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current array-ref value (or undef).
    +
    +
    +=item *
    +
    +If called with a single non-ref argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef).
    +
    +=item *
    +
    +If called with a single array ref argument, uses that list to return a slice of the referenced array.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with a non-ref index and an associated value, stores the value at the given index in the referenced array. If the class value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with the first item being a reference to an array of up to two numbers, loops over each pair and uses those numbers to splice the value array. 
    +
    +The first controlling number is the position at which the splice will begin. Zero will start before the first item in the list. Negative numbers count backwards from the end of the array. 
    +
    +The second number is the number of items to be removed from the list. If it is omitted, or undefined, or zero, no items are removed. If it is a positive integer, that many items will be returned.
    +
    +If both numbers are omitted, or are both undefined, they default to containing the entire value array.
    +
    +If the second argument is undef, no values will be inserted; if it is a non-reference value, that one value will be inserted; if it is an array-ref, its values will be copied.
    +
    +The method returns the items that removed from the array, if any.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Inheritable (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Clear and set contents of list
    +  print MyClass->bar([ 'Spume', 'Frost' ] );  
    +  
    +  # Set values by position
    +  MyClass->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  MyClass->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print MyClass->bar(1);
    +  
    +  # Direct access to referenced array
    +  print scalar @{ MyClass->bar() };
    +
    +There are also calling conventions for slice and splice operations:
    +
    +  # Retrieve slice of values by position
    +  print join(', ', MyClass->bar( undef, [0, 2] ) );
    +  
    +  # Insert an item at position in the array
    +  MyClass->bar([3], 'Potatoes' );  
    +  
    +  # Remove 1 item from position 3 in the array
    +  MyClass->bar([3, 1], undef );  
    +  
    +  # Set a new value at position 2, and return the old value 
    +  print MyClass->bar([2, 1], 'Froth' );
    +
    +B 
    +
    +=cut
    +
    +use vars qw( %ArrayFragments );
    +
    +sub array {
    +  (shift)->_build_composite( \%ArrayFragments, @_ );
    +}
    +
    +%ArrayFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $_->{name};
    +	$method->{data} ||= {};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	
    +	if ( scalar(@_) == 0 ) {
    +	  my $v_self = find_vself($method->{data}, $self);
    +	  my $value = $v_self ? $method->{data}{$v_self} : ();
    +	  if ( $method->{auto_init} and ! $value ) {
    +	    $value = $method->{data}{$self} = [];
    +	  }
    +	  ( ! $value ) ? () : wantarray ? @$value : $value;
    +	  
    +	} elsif ( scalar(@_) == 1 and ref $_[0] eq 'ARRAY' ) {
    +	  $method->{data}{$self} = [ @{ $_[0] } ];
    +	  wantarray ? @{ $method->{data}{$self} } : $method->{data}{$self}
    +	  
    +	} else {
    +	  if ( ! exists $method->{data}{$self} ) {
    +	    my $v_self = find_vself($method->{data}, $self);
    +	    $method->{data}{$self} = [ $v_self ? @{$method->{data}{$v_self}} : () ];
    +	  }
    +	  return array_splicer( $method->{data}{$self}, @_ );
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 hash - Overrideable Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, Must be called on a hash-based instance.
    +
    +=item * 
    +
    +The class value will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments returns the contents of the hash in list context, or a hash reference in scalar context for the callee. If the callee has not had a value defined for this method, searches up from instance to class, and from class to superclass, until a callee with a value is located.
    +
    +=item *
    +
    +If called with one non-ref argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef). If the callee has not had a value defined for this method, searches up from instance to class, and from class to superclass, until a callee with a value is located. 
    +
    +=item *
    +
    +If called with one array-ref argument, uses the contents of that array to retrieve a slice of the referenced hash. If the callee has not had a value defined for this method, searches up from instance to class, and from class to superclass, until a callee with a value is located. 
    +
    +=item *
    +
    +If called with one hash-ref argument, sets the contents of the referenced hash to match that provided.
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the hash associated with the callee, whether instance or class. If the callee did not previously have a hash-ref value associated with it, searches up instance to class, and from class to superclass, until a callee with a value is located, and copies that hash before making the assignments. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the contents of the hash in list context, or a hash reference in scalar context.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Inheritable (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  MyClass->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  MyClass->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print MyClass->baz('foo');
    +  
    +  # Retrive slice of values by position
    +  print join(', ', MyClass->baz( ['foo', 'bar'] ) );
    +  
    +  # Direct access to referenced hash
    +  print keys %{ MyClass->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ MyClass->baz() } = ();
    +
    +B 
    +
    +=cut
    +
    +use vars qw( %HashFragments );
    +
    +sub hash {
    +  (shift)->_build_composite( \%HashFragments, @_ );
    +}
    +
    +%HashFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{hash_key} ||= $_->{name};
    +	$method->{data} ||= {};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	
    +	if ( scalar(@_) == 0 ) {
    +	  my $value = get_vvalue($method->{data}, $self);
    +	  if ( $method->{auto_init} and ! $value ) {
    +	    $value = set_vvalue( $method->{data}, $self, {} );
    +	  }
    +	  wantarray ? %$value : $value;
    +	} elsif ( scalar(@_) == 1 ) {
    +	  if ( ref($_[0]) eq 'HASH' ) {
    +	    %{$method->{data}{$self}} = %{$_[0]};
    +	  } elsif ( ref($_[0]) eq 'ARRAY' ) {
    +	    my $v_self = find_vself($method->{data}, $self) or return;
    +	    return @{ $method->{data}{$v_self} }{ @{$_[0]} }
    +	  } else {
    +	    my $v_self = find_vself($method->{data}, $self) or return;
    +	    return $method->{data}{$v_self}{ $_[0] }
    +	  }
    +
    +	} elsif ( scalar(@_) % 2 ) {
    +	  Carp::croak "Odd number of items in assigment to $method->{name}";
    +	} else {
    +	  if ( ! exists $method->{data}{$self} ) {
    +	    my $v_self = find_vself($method->{data}, $self);
    +	    $method->{data}{$self} = { $v_self ? %{ $method->{data}{$v_self} } : () };
    +	  }
    +	  while ( scalar(@_) ) {
    +	    my $key = shift();
    +	    $method->{data}{$self}->{ $key } = shift();
    +	  }
    +	  wantarray ? %{$method->{data}{$self}} : $method->{data}{$self};
    +	}
    +      },
    +  ],
    +);
    +
    +########################################################################
    +
    +=head2 hook - Overrideable array of subroutines
    +
    +A hook method is called from the outside as a normal method. However, internally, it contains an array of subroutine references, each of which are called in turn to produce the method's results.
    +
    +Subroutines may be added to the hook's array by calling it with a blessed subroutine reference, as shown below. Subroutines may be added on a class-wide basis or on an individual object. 
    +
    +You might want to use this type of method to provide an easy way for callbacks to be registered.
    +
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Inheritable ( 'hook' => 'init' );
    +  
    +  MyClass->init( Class::MakeMethods::Composite::Inheritable->Hook( sub { 
    +      my $callee = shift;
    +      warn "Init...";
    +  } );
    +  
    +  my $obj = MyClass->new;
    +  $obj->init();
    +
    +=cut
    +
    +use vars qw( %HookFragments );
    +
    +sub hook {
    +  (shift)->_build_composite( \%HookFragments, @_ );
    +}
    +
    +%HookFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my ($method) = @_;
    +	$method->{data} ||= {};
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $self = shift @_;
    +	
    +	if ( scalar(@_) and 
    +	    ref($_[0]) eq 'Class::MakeMethods::Composite::Inheritable::Hook' ) {
    +	  if ( ! exists $method->{data}{$self} ) {
    +	    my $v_self = find_vself($method->{data}, $self);
    +	    $method->{data}{$self} = [ $v_self ? @{ $method->{data}{$v_self} } : () ];
    +	  }
    +	  push @{ $method->{data}{$self} }, map $$_, @_;
    +	} else {
    +	  my $v_self = find_vself($method->{data}, $self);
    +	  my $subs = $v_self ? $method->{data}{$v_self} : ();
    +	  my @subs = ( ( ! $subs ) ? () : @$subs );
    +	  
    +	  if ( ! defined $method->{wantarray} ) {
    +	    foreach my $sub ( @subs ) {
    +	      &$sub( @{$method->{args}} );	
    +	    }
    +	  } elsif ( ! $method->{wantarray} ) {
    +	    foreach my $sub ( @subs ) {
    +	      my $value = &$sub( @{$method->{args}} );
    +	      if ( defined $value ) { 
    +		$method->{result} = \$value;
    +	      }
    +	    }
    +	  } else {
    +	    foreach my $sub ( @subs ) {
    +	      my @value = &$sub( @{$method->{args}} );
    +	      if ( scalar @value ) { 
    +		push @{ $method->{result} }, @value;
    +	      }
    +	    }
    +	  }
    +	  
    +	}
    +	return Class::MakeMethods::Composite->CurrentResults();
    +      },
    +  ],
    +);
    +
    +sub Hook (&) { 
    +  my $package = shift;
    +  my $sub = shift;
    +  bless \$sub, 'Class::MakeMethods::Composite::Inheritable::Hook';
    +}
    +
    +########################################################################
    +
    +=head2 object - Overrideable Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, Must be called on a hash-based instance.
    +
    +=item * 
    +
    +The class value will be a reference to an object (or undef).
    +
    +=item *
    +
    +If called without any arguments returns the current value for the callee. If the callee has not had a value defined for this method, searches up from instance to class, and from class to superclass, until a callee with a value is located.
    +
    +=item *
    +
    +If called with an argument, stores that as the value associated with the callee, whether instance or class, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Composite::Inheritable (
    +    object => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  MyClass->foo( Foozle->new() );
    +  
    +  # Retrieve value
    +  print MyClass->foo;
    +
    +B 
    +
    +=cut
    +
    +sub object { } 
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Composite/Universal.pm b/lib/Class/MakeMethods/Composite/Universal.pm
    new file mode 100644
    index 0000000..e53e76d
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Composite/Universal.pm
    @@ -0,0 +1,150 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Composite::Universal - Composite Method Tricks
    +
    +=head1 SYNOPSIS
    +
    +  Class::MakeMethods::Composite::Universal->make_patch(
    +    -TargetClass => 'SomeClass::OverYonder',
    +    name => 'foo',
    +    pre_rules => [ 
    +      sub { 
    +	my $method = pop; 
    +	warn "Arguments for foo:", @_ 
    +      } 
    +    ]
    +    post_rules => [ 
    +      sub { 
    +	warn "Result of foo:", Class::MakeMethods::Composite->CurrentResults 
    +      } 
    +    ]
    +  );
    +
    +=head1 DESCRIPTION
    +
    +The Composite::Universal suclass of MakeMethods provides some generally-applicable types of methods based on Class::MakeMethods::Composite.
    +
    +=cut
    +
    +package Class::MakeMethods::Composite::Universal;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods::Composite '-isasubclass';
    +use Carp;
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 patch
    +
    +The patch ruleset generates composites whose core behavior is based on an existing subroutine.
    +
    +Here's a sample usage:
    +
    +  sub foo {
    +    my $count = shift;
    +    return 'foo' x $count;
    +  }
    +  
    +  Class::MakeMethods::Composite::Universal->make(
    +    -ForceInstall => 1,
    +    patch => {
    +      name => 'foo',
    +      pre_rules => [
    +	sub { 
    +	  my $method = pop @_;
    +	  if ( ! scalar @_ ) {
    +	    @{ $method->{args} } = ( 2 );
    +	  }
    +	},
    +	sub { 
    +	  my $method = pop @_;
    +	  my $count = shift;
    +	  if ( $count > 99 ) {
    +	    Carp::confess "Won't foo '$count' -- that's too many!"
    +	  }
    +	},
    +      ],
    +      post_rules => [
    +	sub { 
    +	  my $method = pop @_;
    +	  if ( ref $method->{result} eq 'SCALAR' ) {
    +	    ${ $method->{result} } =~ s/oof/oozle-f/g;
    +	  } elsif ( ref $method->{result} eq 'ARRAY' ) {
    +	    map { s/oof/oozle-f/g } @{ $method->{result} };
    +	  }
    +	} 
    +      ],
    +    },
    +  );
    +
    +=cut
    +
    +use vars qw( %PatchFragments );
    +
    +sub patch {
    +  (shift)->_build_composite( \%PatchFragments, @_ );
    +}
    +
    +%PatchFragments = (
    +  '' => [
    +    '+init' => sub {
    +	my $method = pop @_;
    +	my $origin = ( $Class::MethodMaker::CONTEXT{TargetClass} || '' ) . 
    +			'::' . $method->{name};
    +	no strict 'refs';
    +	$method->{patch_original} = *{ $origin }{CODE}
    +	    or croak "No subroutine $origin() to patch";  
    +      },
    +    'do' => sub {
    +	my $method = pop @_;
    +	my $sub = $method->{patch_original};
    +	&$sub( @_ );
    +      },
    +  ],
    +);
    +
    +=head2 make_patch
    +
    +A convenient wrapper for C and the C method generator.
    +
    +Provides the '-ForceInstall' flag, which is required to ensure that the patched subroutine replaces the original.
    +
    +For example, one could add logging to an existing method as follows:
    +
    +  Class::MakeMethods::Composite::Universal->make_patch(
    +    -TargetClass => 'SomeClass::OverYonder',
    +    name => 'foo',
    +    pre_rules => [ 
    +      sub { 
    +	my $method = pop; 
    +	warn "Arguments for foo:", @_ 
    +      } 
    +    ]
    +    post_rules => [ 
    +      sub { 
    +	warn "Result of foo:", Class::MakeMethods::Composite->CurrentResults 
    +      } 
    +    ]
    +  );
    +
    +=cut
    +
    +sub make_patch {
    +  (shift)->make( -ForceInstall => 1, patch => { @_ } );
    +}
    +
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Docs/Catalog.pod b/lib/Class/MakeMethods/Docs/Catalog.pod
    new file mode 100644
    index 0000000..ba17349
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Docs/Catalog.pod
    @@ -0,0 +1,888 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Docs::Catalog - List of Makable Method Types
    +
    +
    +=head1 DESCRIPTION
    +
    +This document lists the various subclasses of Class::MakeMethods included
    +in this distribution, and the method types each one provides. 
    +
    +See the documentation for each implementation for more details
    +about the features it provides.
    +
    +For each class, a parenthetical comment indicates whether the methods it generates are applicable to individual blessed objects (Instances), to class data (Global), or both (Any)
    +=head2 Scoping
    +
    +The final part of the name of a method-generating subclass typically indicates the scope or applicability of the methods it generates
    +
    +=over 4
    +
    +=item Hash
    +
    +For object instances based on blessed hashes with named values.
    +
    +=item Array
    +
    +For object instances based on blessed arrays with positional values.
    +
    +=item Scalar
    +
    +For object instances based on blessed scalars with a single value.
    +
    +=item InsideOut
    +
    +For any object instance regardless of underlying data type.
    +
    +=item Ref
    +
    +For any object instance regardless of underlying data type.
    +
    +=item Inheritable
    +
    +For data which can be set at the class, subclass, or instance level.
    +
    +=item Class
    +
    +For class data shared by all instances but different for each subclass
    +
    +=item ClassVar
    +
    +For class data shared by all instances but different for each subclass
    +
    +=item ClassInherit
    +
    +For class data shared by all instances but different for each subclass
    +
    +=item Global
    +
    +For global data shared by a class and all its instances and subclasses
    +
    +=item PackageVar
    +
    +For global data shared by a class and all its instances and subclasses
    +
    +=item Universal
    +
    +# General method types that are widely applicable
    +
    +=back
    +
    +=head2 Summary Charts
    +
    +This table shows which scopes are available in each generator family:
    +
    +  SCOPING          Basic      Standard   Evaled     Composite  Template
    +  Hash               +          +          +          +          +
    +  Array              +          +                     +          +
    +  Scalar                                                         +
    +  InsideOut                                                      +
    +  Ref                                                            +
    +  Inheritable                   +                     +          +
    +  Class                                                          +
    +  ClassVar                                                       +
    +  ClassInherit                                                   +
    +  Global             +          +                     +          +
    +  PackageVar                                                     +
    +  Universal                                           +          +
    +
    +This table shows which types of methods are typically available in each generator family:
    +
    +  METHOD           Basic      Standard   Evaled     Composite  Template
    +  new                +          +                     +          +          
    +
    +  scalar             +          +                     +          +
    +  string                                                         +
    +  string_index                                                   +
    +  number                                                         +
    +  boolean                                                        +
    +  boolean_index                                                  +
    +  bits                                                           +
    +
    +  array              +          +                     +          +
    +  struct                                                         +
    +
    +  hash               +          +                     +          +
    +  hash_of_arrays                                                 +
    +  tiedhash                                                       +
    +
    +  object             +                                +          +
    +  instance                                                       +
    +  array_of_objects                                               +
    +
    +  code                                                           +
    +  code_or_scalar                                                 +
    +
    +
    +=head1 BASIC CLASSES
    +
    +=head2 Basic::Hash (Instances)
    +
    +Methods for objects based on blessed hashes. See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +new: create and copy instances
    +
    +=item *
    +
    +scalar: get and set scalar values in each instance
    +
    +=item *
    +
    +array: get and set values stored in an array refered to in each
    +instance
    +
    +=item *
    +
    +hash: get and set values in a hash refered to in each instance
    +
    +=back
    +
    +=head2 Basic::Array (Instances)
    +
    +Methods for manipulating positional values in arrays. See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +new: create and copy instances
    +
    +=item *
    +
    +scalar: get and set scalar values in each instance
    +
    +=item *
    +
    +array: get and set values stored in an array refered to in each
    +instance
    +
    +=item *
    +
    +hash: get and set values in a hash refered to in each instance
    +
    +=back
    +
    +=head2 Basic::Global (Global)
    +
    +Global methods are not instance-dependent; calling them by class
    +name or from any instance or subclass will consistently access the
    +same value. See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set a global scalar value
    +
    +=item *
    +
    +array: get and set values in a global array
    +
    +=item *
    +
    +hash: get and set values in a global hash
    +
    +=back
    +
    +
    +=head1 STANDARD CLASSES
    +
    +=head2 Standard::Hash (Instances)
    +
    +Methods for objects based on blessed hashes. See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +new: create and copy instances
    +
    +=item *
    +
    +scalar: get and set scalar values in each instance
    +
    +=item *
    +
    +array: get and set values stored in an array refered to in each
    +instance
    +
    +=item *
    +
    +hash: get and set values in a hash refered to in each instance
    +
    +=item *
    +
    +object: access an object refered to by each instance
    +
    +=back
    +
    +=head2 Standard::Array (Instances)
    +
    +Methods for manipulating positional values in arrays. See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +new: create and copy instances
    +
    +=item *
    +
    +scalar: get and set scalar values in each instance
    +
    +=item *
    +
    +array: get and set values stored in an array refered to in each
    +instance
    +
    +=item *
    +
    +hash: get and set values in a hash refered to in each instance
    +
    +=item *
    +
    +object: access an object refered to by each instance
    +
    +=back
    +
    +=head2 Standard::Global (Global)
    +
    +Methods for manipulating global data. See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set global scalar
    +
    +=item *
    +
    +array: get and set values stored in a global array
    +
    +=item *
    +
    +hash: get and set values in a global hash
    +
    +=item *
    +
    +object: global access to an object ref
    +
    +=back
    +
    +
    +=head2 Standard::Inheritable (Any)
    +
    +Methods for manipulating data which may be overridden per class or instance. Uses external data storage, so it works with objects of any underlying data type.  See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set scalar values for each instance or class
    +
    +=back
    +
    +
    +=head1 COMPOSITE CLASSES
    +
    +=head2 Composite::Hash (Instances)
    +
    +Methods for objects based on blessed hashes. See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +new: create and copy instances
    +
    +=item *
    +
    +scalar: get and set scalar values in each instance
    +
    +=item *
    +
    +array: get and set values stored in an array refered to in each
    +instance
    +
    +=item *
    +
    +hash: get and set values in a hash refered to in each instance
    +
    +=item *
    +
    +object: access an object refered to by each instance
    +
    +=back
    +
    +=head2 Composite::Array (Instances)
    +
    +Methods for manipulating positional values in arrays. See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +new: create and copy instances
    +
    +=item *
    +
    +scalar: get and set scalar values in each instance
    +
    +=item *
    +
    +array: get and set values stored in an array refered to in each
    +instance
    +
    +=item *
    +
    +hash: get and set values in a hash refered to in each instance
    +
    +=item *
    +
    +object: access an object refered to by each instance
    +
    +=back
    +
    +=head2 Composite::Global (Global)
    +
    +Methods for manipulating global data. See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set global scalar
    +
    +=item *
    +
    +array: get and set values stored in a global array
    +
    +=item *
    +
    +hash: get and set values in a global hash
    +
    +=item *
    +
    +object: global access to an object ref
    +
    +=back
    +
    +
    +=head2 Composite::Inheritable (Any)
    +
    +Methods for manipulating data which may be overridden per class or instance. Uses external data storage, so it works with objects of any underlying data type.  See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set scalar values for each instance or class
    +
    +=item *
    +
    +hook: create a subroutine intended to have operations added to it
    +
    +=back
    +
    +
    +=head2 Composite::Universal (Any)
    +
    +Methods for padding pre- and post-conditions to any class. See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +patch: add pre and post operations to an existing subroutine
    +
    +=back
    +
    +
    +=head1 TEMPLATE CLASSES
    +
    +=head2 Template::Universal (Any)
    +
    +Meta-methods for any type of object. See L.
    +
    +=over 4
    +
    +=item *
    +
    +no_op - a method with an empty body
    +
    +=item *
    +
    +croak - a method which will croak if called
    +
    +=item *
    +
    +method_init - calls other methods from a list of method name => argument pairs
    +
    +=item *
    +
    +forward_methods - delegates to an object provided by another method
    +
    +=back
    +
    +=head2 Template::Ref (Any Instance)
    +
    +Methods for deep copies and comparisons. See L.
    +
    +=over 4
    +
    +=item *
    +
    +clone: make a deep copy of an object instance
    +
    +=item *
    +
    +prototype: make new objects by cloning a typical instance
    +
    +=item *
    +
    +compare: compare one object to another
    +
    +=back
    +
    +
    +=head2 Template::Generic (Abstract)
    +
    +The remaining subclasses inherit a similar collection of templates from Template::Generic, and provide a different type of scoping or binding for the functionality defined by the Generic template. See L for details.
    +
    +
    +=head2 Template::Hash (Instances)
    +
    +The most commonly used implementation, for objects based on blessed hashes. See L.
    +
    +=over 4
    +
    +=item *
    +
    +new: create and copy instances
    +
    +=item *
    +
    +scalar: get and set scalar values in each instance
    +
    +=item *
    +
    +string: get and set string values in each instance
    +
    +=item *
    +
    +number: get and set numeric values in each instance
    +
    +=item *
    +
    +boolean: get and set boolean values in each instance
    +
    +=item *
    +
    +bits: get and set boolean values stored in a single value in each
    +instance
    +
    +=item *
    +
    +array: get and set values stored in an array refered to in each
    +instance
    +
    +=item *
    +
    +struct - methods for acccessing values which are stored by
    +position in an array
    +
    +=item *
    +
    +hash: get and set values in a hash refered to in each instance
    +
    +=item *
    +
    +tiedhash: get and set values in a tied hash refered to in each
    +instance
    +
    +=item *
    +
    +hash_of_arrays: for references to hashes of arrays contained in each
    +instance
    +
    +=item *
    +
    +object: set or access a reference to an object contained in each
    +instance
    +
    +=item *
    +
    +array_of_objects: manipulate an array of object references within in
    +each instance
    +
    +=item *
    +
    +code: set or call a function reference contained in each instance
    +
    +=back
    +
    +
    +=head2 Template::Array (Instances)
    +
    +Methods for manipulating positional values in arrays. See L.
    +
    +=over 4
    +
    +=item *
    +
    +new: create and copy array instances
    +
    +=item *
    +
    +scalar: get and set scalar values in a given array position
    +
    +=item *
    +
    +string: get and set string values in a given array position
    +
    +=item *
    +
    +number: get and set numeric values in a given array position
    +
    +=item *
    +
    +boolean: get and set boolean values in a given array position
    +
    +=item *
    +
    +builtin_isa: generates a wrapper around some builtin function,
    +cacheing the results in the object and providing a by-name interface
    +
    +=back
    +
    +
    +
    +=head2 Template::Scalar (Instances)
    +
    +For objects based on blessed scalars.  See L.
    +
    +Note that these objects can generally only have one value accessor method, as all such accessors will refer to the same value.
    +
    +=over 4
    +
    +=item *
    +
    +new: create and copy instances
    +
    +=item *
    +
    +scalar: get and set scalar values in each instance
    +
    +=item *
    +
    +string: get and set a string value in each instance
    +
    +=item *
    +
    +number: get and set a numeric value in each instance
    +
    +=item *
    +
    +boolean: get and set a boolean value in each instance
    +
    +=item *
    +
    +bits: get and set boolean values stored in a single value in each
    +instance
    +
    +=item *
    +
    +code: set or call a function reference contained in each instance
    +
    +=back
    +
    +
    +=head2 Template::InsideOut (Instances)
    +
    +Stores values for objects in an external location hashed by identity. See L.
    +
    +Note that while the below constructor creates and returns scalar
    +references, accessor methods can be created with this implementation
    +for use with any type of object.
    +
    +=over 4
    +
    +=item *
    +
    +new: create and copy instances
    +
    +=item *
    +
    +scalar: get and set scalar values associated with each instance
    +
    +=item *
    +
    +string: get and set string values associated with each instance
    +
    +=item *
    +
    +string_index: get and set string values associated with each
    +instance, and maintain an index of instances by value
    +
    +=item *
    +
    +number: get and set numeric values associated with each instance
    +
    +=item *
    +
    +boolean: get and set boolean values associated with each instance
    +
    +=item *
    +
    +boolean_index: get and set boolean values associated with each instance, and maintain a list of items which have the flag set
    +
    +=item *
    +
    +bits: get and set boolean values stored in a single value associated with each
    +instance
    +
    +=item *
    +
    +array: get and set values stored in an array associated with each
    +instance
    +
    +=item *
    +
    +hash: get and set values in a hash associated with each instance
    +
    +=item *
    +
    +code: set or call a function reference associated with each instance
    +
    +=back
    +
    +
    +=head2 Template::Global (Global)
    +
    +Global methods are not instance-dependent; calling them by class
    +name or from any instance will consistently access the same value.  See L.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set a global scalar value
    +
    +=item *
    +
    +string: get and set a global string value
    +
    +=item *
    +
    +number: get and set a global number value
    +
    +=item *
    +
    +boolean: get and set a global boolean value
    +
    +=item *
    +
    +array: get and set values in a global array
    +
    +=item *
    +
    +hash: get and set values in a global hash
    +
    +=item *
    +
    +tiedhash: get and set values in a global tied hash
    +
    +=item *
    +
    +hash_of_arrays: get and set values in a global hash of arrays
    +
    +=item *
    +
    +object: set and access a global reference to an object
    +
    +=item *
    +
    +instance: set and access a global reference to an object of the declaring class
    +
    +=item *
    +
    +code: set and access a global reference to a subroutine.
    +
    +=back
    +
    +
    +=head2 Template::PackageVar (Global)
    +
    +PackageVar methods access a variable in the declaring package. Thus,
    +they have the same effect as Static methods, while keeping their
    +value accessible via the symbol table.  See L.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set a global scalar value
    +
    +=item *
    +
    +string: get and set a global string value
    +
    +=item *
    +
    +number: get and set a global number value
    +
    +=item *
    +
    +boolean: get and set a global boolean value
    +
    +=item *
    +
    +array: get and set values in a global array
    +
    +=item *
    +
    +hash: get and set values in a global hash
    +
    +=back
    +
    +
    +=head2 Template::Class (Global)
    +
    +Class methods are similar to Static methods, except that each subclass and its instances will access a distinct value. See L.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set a class-specific scalar value
    +
    +=item *
    +
    +string: get and set a class-specific string value
    +
    +=item *
    +
    +number: get and set a class-specific number value
    +
    +=item *
    +
    +boolean: get and set a class-specific boolean value
    +
    +=item *
    +
    +array: get and set values in a class-specific array
    +
    +=item *
    +
    +hash: get and set values in a class-specific hash
    +
    +=back
    +
    +
    +=head2 Template::ClassVar (Global)
    +
    +ClassVar methods access a variable in the package on which they
    +are called.  Thus, they have the same effect as Class methods,
    +while keeping their value accessible via the symbol table, like
    +PackageVar. See L.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set a class-specific scalar value
    +
    +=item *
    +
    +string: get and set a class-specific string value
    +
    +=item *
    +
    +number: get and set a class-specific number value
    +
    +=item *
    +
    +boolean: get and set a class-specific boolean value
    +
    +=item *
    +
    +array: get and set values in a class-specific array
    +
    +=item *
    +
    +hash: get and set values in a class-specific hash
    +
    +=back
    +
    +
    +=head2 Template::ClassInherit (Global)
    +
    +ClassInherit methods are an intermediate point between Static and Class methods; subclasses inherit their superclass's value until they set their own value, after which they become distinct. See L.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set an inheritable class-specific scalar value
    +
    +=item *
    +
    +string: get and set an inheritable class-specific string value
    +
    +=item *
    +
    +number: get and set an inheritable class-specific number value
    +
    +=item *
    +
    +boolean: get and set an inheritable class-specific boolean value
    +
    +=item *
    +
    +array: get and set values in an inheritable class-specific array
    +
    +=item *
    +
    +hash: get and set values in an inheritable class-specific hash
    +
    +=back
    +
    +
    +=head2 Template::Inheritable (Any)
    +
    +Methods for manipulating data which may be overridden per class or instance. Uses external data storage, so it works with objects of any underlying data type.  See L for details.
    +
    +=over 4
    +
    +=item *
    +
    +scalar: get and set scalar values for each instance or class
    +
    +=item *
    +
    +string: get and set string values for each instance or class
    +
    +=item *
    +
    +number: get and set numeric values for each instance or class
    +
    +=item *
    +
    +boolean: get and set boolean values for each instance or class
    +
    +=item *
    +
    +hash: get and set values in a hash refered to in each instance
    +
    +=back
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Docs/Changes.pod b/lib/Class/MakeMethods/Docs/Changes.pod
    new file mode 100644
    index 0000000..8b01f0a
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Docs/Changes.pod
    @@ -0,0 +1,661 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Docs::Changes - History of Class::MakeMethods
    +
    +=head1 SYNOPSIS
    +
    +Revision history for Class::MakeMethods.
    +
    +=head1 CHANGES
    +
    +=head2 Version 1.010
    +
    +=over 4
    +
    +=item 2004/09/06
    +
    +Moved get_declarations() and associated documentation from Standard module to superclass.
    +
    +=item 2004/09/03
    +
    +Developed test.pl test harness with recursive file search to fix Windows "command line too long" errors.
    +
    +=item 2004/09/01
    +
    +Moved Template::TextBuilder and Template::DiskCache into Utility:: namespace.
    +
    +Added support for defaults with -- and -param to Standard get_declarations().
    +
    +=item 2004/08/12
    +
    +Began testing and integrating tied-value patches from Dominique Dumont.
    +
    +=item 2004/04/27
    +
    +Added method types to Evaled::Hash.
    +
    +=item 2004/04/23
    +
    +Added skeleton of a new Evaled::Hash class.
    +
    +=back
    +
    +=head2 Version 1.009
    +
    +=over 4
    +
    +=item 2003/09/25
    +
    +Added Emulator::mcoder and compatibility tests.
    +
    +Released to CPAN as Class-MakeMethods-1.009.tar.gz.
    +
    +=item 2003/09/22
    +
    +Added support for lvalue methods to Template and Template::Generic. Added a few tests to demonstrate they're working. Added an example to Docs::Examples.
    +
    +Added Emulator::accessors and compatibility tests.
    +
    +Minor documentation improvements.
    +
    +=back
    +
    +=head2 Version 1.008
    +
    +=over 4
    +
    +=item 2003/09/05
    +
    +Adjusted layout of test directories in another attempt to solve a MakeMaker/shell-glob issue on Windows that was preventing make test from running correctly. 
    +
    +Removed Template::PseudoHash, since this package never really worked, as pointed out by a question from Mike Castle. Management of array-based objects can be handled by any of the existing ::Array subclasses, and support for pseudo-hashes would not provide any useful new capabilities.
    +
    +Added support for "Template::Universal:forward_methods -delegate" and "Template::Generic:object --soft_delegate" based on a suggestion from Peter Chen. Extended behavior of Template -subs handling to make it easy to add such functionality in the future.
    +
    +Released to CPAN as Class-MakeMethods-1.008.tar.gz.
    +
    +=item 2003/09/02
    +
    +Adjusted DESTROY behavior of Template::InsideOut and cleaned up documentation.
    +
    +=back
    +
    +=head2 Version 1.007
    +
    +=over 4
    +
    +=item 2003/09/01
    +
    +Made Template definitions automatically import their class's generic
    +definitions, if present. This eliminates the need for Generic
    +subclasses to explicitly redeclare every method it inherits, and
    +should obviate the "missing declaration" problems referenced below.
    +
    +Updated the names of several Template subclasses, with stubs at
    +the old names for backwards compatibility: Flyweight becomes
    +InsideOut, Static becomes Global, and Struct becomes Array.
    +
    +Added Template::Inheritable and basic tests for it.
    +
    +Eliminated use of legacy Test.pm from remaining tests, except for
    +MethodMaker emulation.
    +
    +Rearranged test directories in an effort to avoid a reported bug
    +with the test path of t/*/*.t under Windows.
    +
    +Released to CPAN as Class-MakeMethods-1.007.tar.gz.
    +
    +=item 2003/08/27
    +
    +Added section to Class::MakeMethods/EXTENDING documentation based
    +on question from Terrence Brannon.
    +
    +=item 2003/02/07
    +
    +Fixed missing declaration of Template::Hash:instance, reported via RT.
    +
    +=back
    +
    +=head2 Version 1.006
    +
    +=over 4
    +
    +=item 2003/01/26
    +
    +Additional documentation touch-ups. Moved miscellaneous POD files into the Docs directory.
    +
    +Added new test scripts from Class-MethodMaker-1.08, although we
    +don't yet pass them. In particular, I need to add support for the
    +new method types added in 1.04: tie_scalar, tie_list, object_tie_list,
    +object_tie_hash
    +
    +Also need to compare against the changes included in Class-MethodMaker-1.09 and 1.10, which don't seem to include any new test code, but do include functionality changes.
    +
    +=item 2002/12/12
    +
    +Re-integrated Template and Emulator packages; the separate distribution
    +turned out to be a hastle rather than a convenience. However, in
    +order to keep test scripts for each subsystem separate, I'm now
    +using a Makefile.PL attribute to specify a two-level deep directory
    +tree of test scripts; I hope this doesn't break on Windows...
    +
    +Fixed possible "use of undefined as a reference" problem in
    +Standard::*::array method generators, reported by Jared Rhine.
    +
    +Tried to improve documentation, based on feedback from Jared Rhine.
    +Expunged ReadMe.pod. Extracted method catalogs into Catalog.pod.
    +Moved examples to new Example.pod, although that underlines how
    +few examples there are.
    +
    +=back
    +
    +
    +=head2 Version 1.005
    +
    +=over 4
    +
    +=item 2002/06/06
    +
    +Added Autoload interface.
    +
    +Modifed Attribute interface to add "inheritable" default logic for
    +Maker class parameter. (Suggested by Malcolm Cook.)
    +
    +Fixed typo in documentation for Standard::Universal. (Spotted by
    +Malcolm Cook.)
    +
    +=back
    +
    +
    +=head2 Version 1.004
    +
    +=over 4
    +
    +=item 2002/03/23
    +
    +Released to CPAN as Class-MakeMethods-1.004.tar.gz.
    +
    +=item 2002/03/16
    +
    +Allow double-colons between package name and method generator name.
    +
    +=item 2002/02/19
    +
    +Fixed related use of undef in Standard::*:hash methods.
    +
    +=item 2002/02/14
    +
    +Adjusted Standard::*:hash methods to avoid assuming that the hashref
    +already exists.
    +
    +=item 2002/02/07
    +
    +Added missing *_reset => clear to Template number --counter interface.
    +
    +=item 2002/02/02
    +
    +Adjusted error message in Utility::ArraySplicer
    +
    +=item 2002/01/26
    +
    +Applied small documentation corrections suggested by Adam Spiers.
    +
    +Added Standard::Universal:alias.
    +
    +=back
    +
    +=head2 Version 1.003
    +
    +=over 4
    +
    +=item 2002/01/24
    +
    +Folded "Getting Started Guide" POD into main module documentation.
    +
    +Renamed Utility::TakeName to Emulator.
    +
    +Split Template and Emulator packages into their own distributions.
    +
    +B This means that to fully upgrade you must retrieve
    +all three of these files:
    +
    +  Class-MakeMethods-1.003.tar.gz 
    +  Class-MakeMethods-Template-1.003.tar.gz 
    +  Class-MakeMethods-Emulator-1.003.tar.gz 
    +
    +Of course, if you're not using the Template or Emulator classes,
    +there's no need to download them...
    +
    +
    +=item 2002/01/21
    +
    +Started bumping sub-version numbers and not using sub-sub-versions,
    +to shorten distribution names and more closely match standard
    +practice.
    +
    +Added Composite::Inheritable:hook and matching test. Added
    +Composite->CurrentResults method to easily access, update composite
    +method results.
    +
    +=back
    +
    +=head2 Version 1.000.*
    +
    +=over 4
    +
    +=item v1.000.16 - 2002/01/21
    +
    +Released to CPAN as v1.000.016.
    +
    +=item v1.000.16 - 2002/01/20
    +
    +Adjusted the hash and array methods in the Standard::* and Composite::*
    +packages to properly accept a set-contents call with a single
    +reference argument, and to return contents rather than ref in list
    +context.
    +
    +=item v1.000.16 - 2002/01/14
    +
    +Fixed a subtle bug in a test script inherited from Class::MethodMaker:
    +4_Template_hash_hash_array.t and 7_MethodMaker_hash_of_lists.t both
    +relied on "keys %hash" returning the keys in a particular order,
    +which *almost* always worked, but caused failures on one or more
    +Perl version/platform combinations.
    +
    +
    +=item v1.000.15 - 2002/01/14
    +
    +Released to CPAN as v1.000.015.
    +
    +=item v1.000.15 - 2002/01/12
    +
    +Renamed Basic::Static to Basic::Global for consistency with Standard
    +and Composite. Hopefully, there aren't many users of this module
    +yet; please accept my apologies if this breaks your code.
    +
    +Eliminated "local @_ = ...", which appears to cause a scoping
    +problem on Perl 5.6. Thanks to Adam Spiers for a thorough bug
    +report. (See http://www.perlmonks.org/index.pl?node_id=138370 for
    +details.)
    +
    +Extended Template::Generic to support "array --get_set_ref" method
    +style requested by Adam Spiers.
    +
    +Various documentation tweaks, including feedback from Adam Spiers:
    +Adjusted documentation to downplay Basic::* modules as a starting
    +point, in favor of Standard::* ones. Trimmed out some duplicated
    +documentation in favor of more "See LE...E" links. Adjusted
    +documentation of *::Inheritable packages in an attempt to clarify
    +the way in which the inheritance tree is searched for a value.
    +
    +Factored out common code from Standard::Inheritable and
    +Composite::Inheritable to new module, Utility::Inheritable. Factored
    +out common code from Standard::Hash and Standard::Array to new
    +module, Utility::ArraySplicer. Factored out common code from
    +Template::Universal to new module, Utility::Ref. Renamed
    +Emulator::TakeName to Utility::TakeName (this is internal use only,
    +so there should be no public impact).
    +
    +
    +=item v1.000.15 - 2001/12/01
    +
    +Adjusted Template::Universal's code for _CALL_METHODS_FROM_HASH_,
    +to ensure that method/arg pairs are called in order they were passed
    +in.
    +
    +=item v1.000.15 - 2001/07/04, 2001/07/19
    +
    +Minor additions to documentation of various method types.
    +
    +
    +=item v1.000.14 - 2001/07/01
    +
    +Released as v1.000.014.
    +
    +
    +=item v1.000.14 - 2001/06/25, 2001/06/29, 2001/07/01
    +
    +Removed Makefile rule from Makefile.PL to avoid warnings when used
    +with recent versions of ExtUtils::MakeMaker, which also define a
    +similar rule. (Based on bug report from Ron Savage.)
    +
    +Fixed test failure for machines with P5.6 but no Attribute::Handlers.
    +(Reported by Ron Savage, Jay Lawrence.)
    +
    +Added Template::Flyweight:string_index. (But still needs test
    +script.)
    +
    +Added Standard::Universal. (But still needs test scripts.)
    +
    +Minor touch-ups to ReadMe and Guide documentation.
    +
    +
    +=item v1.000.13 - 2001/05/16, 2001/05/18, 2001/05/20, 2001/06/02, 2001/06/22, 2001/06/24
    +
    +To date, this module has been circulated under several provisional
    +names: it was originally floated as a possible version-2 rewrite
    +of Class::MethodMaker, then renamed to Class::Methods when it forked
    +from that project, and then briefly to Class::MethodGenerator.
    +(Note that it can be surprisingly difficult to comply with both of
    +these L guidelines: "To be portable each component of
    +a module name should be limited   to 11 characters. [...] Always
    +try to use two or more whole words.") In the end, I selected
    +Class::MakeMethods, as it is two whole words, and is reminiscent
    +of Class::MethodMaker without being confusing (I hope!), and I
    +believe this issue is now settled.
    +
    +Standardized syntax for global options; renamed -implementation to
    +-MakerClass and -target_class to -TargetClass. Moved $TargetClass
    +and other context information into %CONTEXT with _context accessor.
    +Added ForceInstall.
    +
    +Completed re-simplification of build directories; we're back to a
    +single Makefile, which avoids a warning in P5.6.0.
    +
    +Added Attribute interface for use with P5.6 and later, based on
    +Attribute::Handlers.
    +
    +Renamed "Simple" subclasses to "Basic". Added documentation and
    +initial tests.
    +
    +Added Standard subclasses with parameter parsing and more powerful
    +accessors.
    +
    +Modified Emulator::Struct to use Standard::* methods. Found struct
    +test from P5.7, and added auto_init functionality to match.
    +
    +Added Composite::* subclasses. 
    +
    +Added Emulator::AccessorFast.
    +
    +Added Class::MakeMethods::Guide with introduction and examples.
    +
    +Continued clean-up effort on Template documentation. Renamed Template
    +"attributes" to "method parameters" to avoid confusion with Perl
    +attributes. Retitled Template naming rules from "templates" to
    +"interfaces".
    +
    +Changed initialization code expressions of Template::Class in hopes
    +of P5.6.1 compatibility. (Problem reported by M Schwern.)
    +
    +Added 'Template::Generic:new --and_then_init' based on feedback
    +from Jay Lawrence.
    +
    +=back
    +
    +=head2 Early 1.000 versions
    +
    +=over 4
    +
    +=item v1.000.12 - 2001/05/14
    +
    +Renamed module to Class::MethodGenerator, although naming questions
    +remain.
    +
    +Moved Template subclasses into Template::* namespace. Simplified
    +build directory and makefile structure.
    +
    +Changed initialization code expressions of Template::PackageVar,
    +ClassVar for P5.6.0 compatibility. (Reported by M Schwern.)
    +
    +
    +=item v1.000.11 - 2001/05/07, 2001/05/12
    +
    +Eliminated Bundle file. Moved general documentation to cm_base.
    +
    +Renamed Class::Methods::Base to Class::Methods::Generator.
    +
    +Extracted code for Template declarations to new Class::Methods::Template
    +module. Extracted disk-caching to new Template::DiskCache module.
    +Moved TextBuilder into the Template:: tree.
    +
    +Moved _namespace_capture code to new package
    +Class::Methods::Emulator::TakeName.
    +
    +Added Simple::Hash subclass.
    +
    +
    +=item v1.000.10 - 2001/04/26, 2001/05/02, 2001/05/04
    +
    +Moved _namespace_capture and _namespace_release to Class::Methods::Base.
    +
    +Additional doc tweakage. Moved ReadMe documentation to
    +Bundle::ClassMethods. Merged Extending documentation into Base.
    +
    +Removed spurious uses of -default => 'default' in templates.
    +
    +Added new ClassInherit subclass and Emulator::Inheritable.
    +
    +Expunged Index subclass in favor of boolean_index and string_index
    +types on Generic.
    +
    +Moved Struct:builtin_isa type to new package, StructBuiltin.
    +
    +Refactored code templating function as Class::Methods::Base::TextBuilder.
    +
    +
    +=item v1.000.9 - 2001/03/24
    +
    +Reversed sense of - and --, as it was in 1.000.1.
    +
    +Separated source files into separate directories with distinct
    +Makefiles and test hierarchies. This should clarify the boundaries
    +between the core method-generation code, the common constructor/accessor
    +methods, and the various emulator and experimental packages.
    +
    +
    +=item v1.000.8 - 2001/01/19
    +
    +Following receipt of a suggestion to fork from the maintainer of
    +Class::MethodMaker, renamed packge from Class::MethodMaker v2.0 to
    +Class::Methods v1.000.
    +
    +Adjusted documentation to reflect fork, although additional cleanup
    +is still needed.
    +
    +Moved backward compatibility to Emulator::MethodMaker subclass.
    +
    +Added Generic -compatibility array index_* and hash_of_arrays *_last
    +and *_set methods to match changes in Class::MethodMaker v1.02.
    +Added Emulator::MethodMaker support for the '-static' flag. The
    +emulator now completely satisfies the enclosed test suites, from
    +Class::MethodMaker v0.92 and v1.02.
    +
    +
    +=item v1.000.7 - 2001/01/05, 2001/01/06, 2001/01/07
    +
    +Moved core code and internal code to Internals.pm. MethodMaker.pm
    +now contains only some require statements and the general user
    +guide documentation.
    +
    +Moved ReadMe.pod, Changes.pod, and ToDo.pod into MethodMaker
    +directory. Separated Catalog.pod, Extending.pod, RelatedModules.pod.
    +
    +Included version 1 docs as Class::Methods::OriginalDocs; minor
    +revisions for clarity.
    +
    +Renamed Package subclass to PackageVar, Class to ClassVar.
    +
    +Added Emulation::Struct subclass.
    +
    +Added support for shifting targets with make( -target_class =>
    +Package, ... ).
    +
    +Extended ClassName subclass to handle requiring, rather than creating
    +subclases.
    +
    +
    +=item v1.000.6 - 2000/12/29, 2001/01/02, 2001/01/04
    +
    +Restored -sugar import option for compatibility with earlier
    +versions.
    +
    +Added plural names to "Generic:hash -compatibility" to support
    +v0.92 usage.
    +
    +Replaced use of substr(..., 0, 1) with ... =~ s/^-// for P5.004
    +compatibility; problem found by Scott Godin.
    +
    +Copy @_ before splicing and pushing on to it for P5.004 compatibility.
    +
    +Expunged duplicate lines from Generic.pm's array_of_objects; found
    +by Ron Savage.
    +
    +Renamed Hash.pm's delete and exists behaviors to avoid possible
    +run-time import conflict with Generic.pm's behaviors; failure
    +reported by Ron Savage.
    +
    +Added _STATIC_ATTR_{return_value_undefined} attributes to Generic
    +string and number to allow overrides of this functionality.
    +
    +Minor doc touchups and expanded examples section.
    +
    +
    +=item v1.000.5 - 2000/11/28, 2000/12/16, 2000/12/28
    +
    +Added Universal -warn_calls modifier.
    +
    +Folded various pod files together into main module's inline
    +documentation.  Updated catalog of existing implementations in
    +documentation.  Added pointers to some tutorials and books which
    +discuss Class::Methods.
    +
    +Standardized naming of test scripts.
    +
    +Can now specify default template name, via -default=>"foo".
    +
    +
    +=item v1.000.4 - 2000/11/22
    +
    +Separated string, number, and boolean from the Generic scalar
    +methods.
    +
    +Provide _disk_cache to shortcut the lengthy _interpret_text_builder
    +process.
    +
    +Fixes to ClassName implementation.
    +
    +Change to forward methods to provide better error messages when
    +object is empty.
    +
    +
    +=item v1.000.3 - 2000/11/03
    +
    +Rearranged documentation into separate files in the pod/ directory.
    +
    +Collapsed find_target_class and make functionality into import;
    +moved support for the old functions to the Compatibility module.
    +
    +Adjusted tests to generally use standard syntax, and not Compatibility
    +hooks.
    +
    +
    +=item v1.000.2.1 - 2000/10/23
    +
    +Moved commonly-accessible information to Universal.
    +
    +Added block{...} replacement for enhanced behavior templating.
    +
    +Added modifier mechanism to support -private and -protected.
    +
    +May need to be able to specify import ordering so that modifiers
    +are applied in the right order. This hasn't bit me yet, but it's
    +there. Darn.
    +
    +
    +=item v1.000.2 - 2000/10/22
    +
    +Completed generalization of Generic methods from Static and Hash.
    +Rewrote ClassVar and PackageVar to use Generic framework.
    +
    +Attribute expansion can now substitute values besides name, using
    +*{attr}.
    +
    +Added _diagnostics function and documentation of all failure
    +messages.
    +
    +Added SEE ALSO section to documentation, brief review of Class::*
    +on CPAN.  Stumbled across Damian Conway's very nice Class::Contract
    +module.
    +
    +Added Scalar and Flyweight implementations.
    +
    +
    +=item v1.000.1.1 - 2000/10/21
    +
    +Rolled back change from yesterday; can still pick templates like
    +'-java'.  Allow attributes to be specified as '--foo'=>'bar' or
    +'--'=>{foo=>'bar'}
    +
    +Automated caching for meta-method definition hashes.
    +
    +Generalized several Static and Hash interfaces into Generic templates.
    +Added Static:array and Static:code support.
    +
    +Allow global -import to set default sources for templates, exprs,
    +behaviors.
    +
    +
    +=item v1.000.1 - 2000/10/19
    +
    +Support inheritance of templates between meta-methods with -import.
    +
    +Made "template" an attribute, rather than a special state variable.
    +
    +Allow any attribute to be specified as -foo=>'bar'.  Changed
    +selection of standard templates from '-java' to '--java'.
    +
    +Initial support for string-eval behaviors and code_exprs, and
    +Generic.pm
    +
    +
    +=item v1.000.0 - 2000/10/14, 2000/10/15
    +
    +Completed initial pass of full rewrite.
    +
    +Assorted cleanup of syntax and documentation.
    +
    +Moved Hash, Static, and Index implementations into separate packages.
    +
    +
    +=item v0.9.3 - 2000/09/30
    +
    +Refactored subclass_name and class_registry.
    +
    +Folded in some misc improvements from Class::MethodMaker 1.0.
    +
    +
    +=item v0.97x - 2000/08/04 to 2000/08/13
    +
    +Forked from Class::MethodMaker 0.96. Substantial rewrite started
    +
    +Created build_meta_method and refactored many methods to use it.
    +
    +Added new_hash, hash_init, new_from_prototype.
    +
    +Extended arg format. Added -template=>behavior_name. Added support
    +for array-of-names arguments.
    +
    +Performance tuning. Additional refactoring to support AutoSplit
    +functionality.
    +
    +Also folded in some older changes and additions from Evolution's
    +internal collection of MethodMaker subclasses:
    +
    +=back
    +
    +=head2 Class::MethodMaker::Extensions
    +
    +Change notes from unreleased collection of extensions to Class::MethodMaker that were later folded into Class::MakeMethods:
    +
    +  2000/01/12 Added set_foo, clear_foo to class_var hashes.
    +  1999/07/27 Added subclass_name.
    +  1999/04/15 Changed class_var to use symbol table lookups, not eval "".
    +  1999/04/05 Changed determine_once to check again if undefined.
    +  1999/03/25 Added singleton method.
    +  1998/09/18 Finished integration of class_registry handlers.
    +  1998/07/31 Added class_var and classnames handlers.
    +  1998/06/12 Added lookup handlers.
    +  1998/05/09 Created no_op and determine_once method groups.
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Docs/Examples.pod b/lib/Class/MakeMethods/Docs/Examples.pod
    new file mode 100644
    index 0000000..787ace7
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Docs/Examples.pod
    @@ -0,0 +1,554 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Docs::Examples - Sample Declarations and Usage
    +
    +=head1 EXAMPLES
    +
    +The following examples indicate some of the capabilities of
    +Class::MakeMethods. 
    +
    +=head2 A Contrived Example
    +
    +Object-oriented Perl code is widespread -- you've probably seen code like the below a million times:
    +
    +  my $obj = MyStruct->new( foo=>"Foozle", bar=>"Bozzle" );
    +  if ( $obj->foo() =~ /foo/i ) {
    +    $obj->bar("Barbados!");
    +  }
    +
    +Here's a possible implementation for the class whose interface is
    +shown above:
    +
    +  package MyStruct;
    +  
    +  sub new {
    +    my $callee = shift;
    +    my $self = bless { @_ }, (ref $callee || $callee);
    +    return $self;
    +  }
    +
    +  sub foo {
    +    my $self = shift;
    +    if ( scalar @_ ) {
    +      $self->{'foo'} = shift();
    +    } else {
    +      $self->{'foo'}
    +    }
    +  }
    +
    +  sub bar {
    +    my $self = shift;
    +    if ( scalar @_ ) {
    +      $self->{'bar'} = shift();
    +    } else {
    +      $self->{'bar'}
    +    }
    +  }
    +
    +Class::MakeMethods allows you to simply declare those methods to
    +be of a predefined type, and it generates and installs the necessary
    +methods in your package at compile-time.
    +
    +Here's the equivalent declaration for that same basic class:
    +
    +  package MyStruct;
    +  use Class::MakeMethods::Standard::Hash (
    +    'new'       => 'new',
    +    'scalar'    => 'foo',
    +    'scalar'    => 'bar',
    +  );
    +
    +=head2 A Typical Example
    +
    +The following example shows a common case of constructing a class with several types of accessor methods
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Hash (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +
    +This class now has a constructor named new, two scalar accessors named foo and bar, and a pair of reference accessors named my_list and my_index. Typical usage of the class might include calls like the following:
    +
    +  my $obj = MyObject->new( foo => 'Foozle' );
    +  print $obj->foo();
    +  
    +  $obj->bar('Barbados'); 
    +  print $obj->bar();
    +  
    +  $obj->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print $obj->my_list(1);
    +  
    +  $obj->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print $obj->my_index('foo');
    +
    +=head2 Lvalue Accessors
    +
    +The Template subclasses support an optional "--lvalue" modifer that causes your accessors method to be marked as returning an lvalue which can be assigned to. (This feature is only available on Perl 5.6 or later.)
    +
    +  package MyStruct;
    +  use Class::MakeMethods::Template::Hash (
    +    'new'                   => 'new',
    +    'scalar --get --lvalue' => 'foo',
    +    'array --get --lvalue'  => 'bar',
    +  );
    +
    +  $obj->foo = "Foozle";
    +  print $obj->foo;
    +
    +  $obj->bar = ( 'baz', 'beep', 'boop' );
    +  print $obj->bar->[1]; # beep
    +
    +=head2 String and Numeric Accessors
    +
    +In addition to the C accessor supported by the C classes, the Template subclasses also provide specialized accessors that can facilitate the use of specific types of data.
    +
    +For example, we could declare the following class to hold information
    +about available Perl packages:
    +
    +  package MyVersionInfo;
    +  use Class::MakeMethods::Template::Hash (
    +    'new'     => 'new',
    +    'string'  => 'package',
    +    'number'  => 'version',
    +  );
    +
    +  sub summary {
    +    my $self = shift;
    +    return $self->package() . " is at version " . $self->version()
    +  }
    +
    +You could use this class as follows:
    +
    +  package main;
    +  use MyVersionInfo;
    +  
    +  my $obj = MyVersionInfo->new( package=>"Class::MakeMethods");
    +  $obj->version( 2.0 );
    +  print $obj->summary();
    +
    +These accessors will provide a bit of diagnostic type checking;
    +an attempt to call C<$obj-Eversion("foo")> will cause your
    +program to croak.
    +
    +
    +=head2 String Concatenation Interface
    +
    +The following defines a get_concat method C, and specifies
    +a string to use when joining additional values when this method is
    +called.
    +
    +  use Class::MakeMethods::Template::Hash
    +    'string' => [ '--get_concat', 'i', { join => ' - ' } ];
    +
    +(See L for information about the C C interface.)
    +
    +
    +=head2 Access Control Example
    +
    +The following defines a secret_password method, which will croak
    +if it is called from outside of the declaring package.
    +
    +  use Class::MakeMethods::Composite::Hash
    +    'scalar' => [ 'secret_password' => { permit => 'pp' } ];
    +
    +(See L for information
    +about the C modifier.)
    +
    +For template classes, the same thing is accomplished with '--private':
    +
    +  use Class::MakeMethods::Template::Hash
    +    'scalar' => [ '--private', 'secret_password' ];
    +
    +(See L for information
    +about the C modifier.)
    +
    +
    +=head2 Lazy-Init Interface
    +
    +Templapte scalar accessors declared with the "init_and_get" interface
    +can be used for "memoization" or lazy-evaluation for object
    +attributes. If the current accessor value is undefined, they will
    +first call a user-provided init_* method and save its value.
    +
    +  package MyWidget;
    +  use Class::MakeMethods::Template::Hash (
    +    'new --with_values' => [ 'new' ],
    +    'scalar --init_and_get' => [ 'foo', 'count', 'result' ],
    +  );
    +  
    +  sub init_foo { 
    +    return 'foofle';
    +  }
    +  
    +  sub init_count {
    +    return '3';
    +  }
    +  
    +  sub init_result {
    +    my $self = shift;
    +    return $self->foo x $self->count;
    +  }
    +  ...
    +  
    +  my $widget = MyWidget->new();
    +  print $widget->result; # output: fooflefooflefoofle
    +  
    +  # if values are predefined, the init methods are not used
    +  my $other_widget = MyWidget->new( foo => 'bar', count => 2 );
    +  print $widget->result; # output: barbar  
    +
    +(See L for more information about
    +C. This interface is also supported by all of Generic's
    +subclasses, so you can add lazy-init methods for global data, class
    +data, array objects, etc. Unfortunately, to date it is only supported
    +for scalar-value accessors...)
    +
    +
    +=head2 Helper Methods
    +
    +Template methods often include similarly-named "helper" methods. For example, specifying the "--with_clear" interface for Template::*:scalar methods creates an extra method for each accessor x named clear_x.
    +
    +  package MyClass;
    +  use Class::MakeMethods::Template::Hash('scalar --with_clear' => 'foo');
    +
    +  my $obj = MyClass->new;
    +  $obj->foo(23);
    +  $obj->clear_foo;
    +  print $obj->foo();
    +
    +
    +=head2 Reference Accessor and Helper Methods
    +
    +For references to arrays and hashes, the Template subclasses provide
    +accessors with extra "helper methods" to facilitate method-based
    +interaction.
    +
    +Here's a class whose instances each store a string and an array
    +reference, along with a method to search the directories:
    +
    +  package MySearchPath;
    +  use Class::MakeMethods::Template::Hash (
    +    'new'     => 'new',
    +    'string'  => 'name',
    +    'array'   => 'directories',
    +  );
    +  
    +  sub search {
    +    my $self = shift; 
    +    my $target = shift;
    +    foreach my $dir ( $self->directories ) {
    +      my $candidate = $dir . '/' . $target;
    +      return $candidate if ( -e $candidate );
    +    }
    +    return;
    +  }
    +
    +Note that the directories accessor returns the contents of the
    +array when called in a list context, making it easier to loop over.
    +
    +And here's a sample usage:
    +
    +  package main;
    +  use MySearchPath;
    +  
    +  my $libs = MySearchPath->new( name=>"libs", directories=>['/usr/lib'] );
    +  $libs->push_directories( '/usr/local/lib' );
    +  
    +  print "Searching in " . $libs->count_directories() . "directories.\n";
    +  foreach ( 'libtiff', 'libjpeg' ) {
    +    my $file = $libs->search("$_.so"); 
    +    print "Checking $_: " . ( $file || 'not found' ) . "\n";
    +  }
    +
    +Note the use of the push_* and count_* "helper" accessor methods,
    +which are defined by default for all 'Template::*:array' declarations.
    +
    +Consult L for more information about
    +the available types of reference accessors, and the various methods
    +they define.
    +
    +
    +=head2 Object Accessors
    +
    +There's also a specialized accessor for object references:
    +
    +  package MyStruct;
    +  use Class::MakeMethods::Template::Hash (
    +    'new'    => 'new',
    +    'object' => [ 'widget' => {class=>'MyWidgetClass', delegate=>"twiddle"} ],
    +  );
    +
    +(Note that the C and C values specified above are
    +method parameters, which provide additional information about the
    +C declaration; see L<"Standard Declaration Syntax"> for more information.)
    +
    +The above declaration creates methods equivalent to the following:
    +
    +  package MyStruct;
    +
    +  sub widget {
    +    my $self = shift;
    +    if ( scalar @_ ) { 
    +      if (ref $_[0] and UNIVERSAL::isa($_[0], 'MyWidgetClass')) { 
    +	$self->{widget} = shift;
    +      } else {
    +	$self->{widget} = MyWidgetClass->new(@_);
    +      }
    +    } else {
    +      return $self->{widget};
    +    }
    +  }
    +  
    +  sub clear_widget {
    +    my $self = shift;
    +    $self->{widget} = undef;
    +  }
    +  
    +  sub twiddle { 
    +    my $self = shift;
    +    my $obj = $self->widget() 
    +      or Carp::croak("Can't forward twiddle because widget is empty");
    +    $obj->twiddle(@_) 
    +  } 
    +
    +
    +=head2 Mixing Object and Global Methods
    +
    +Here's a package declaration using two of the included subclasses, C, for creating and accessing hash-based objects, and C, for simple global-value accessors:
    +
    +  package MyQueueItem;
    +  
    +  use Class::MakeMethods::Standard::Hash (
    +    new => { name => 'new', defaults=>{ foo => 'Foozle' } },
    +    scalar => [ 'foo', 'bar' ],
    +    hash => 'history'
    +  );
    +  
    +  use Class::MakeMethods::Basic::Global (
    +    scalar => 'Debug',
    +    array  => 'InQueue',
    +  );
    +  
    +  sub AddQueueItem {
    +    my $class = shift;
    +    my $instance = shift;
    +    $instance->history('AddQueueItem' => time());
    +    $class->InQueue([0, 0], $instance);    
    +  }
    +  
    +  sub GetQueueItem {
    +    my $class = shift;
    +    $class->InQueue([0, 1], []) or $class->new
    +  }
    +
    +=head2 Adding Custom Initialization to Constructors
    +
    +Frequently you'll want to provide some custom code to initialize new objects of your class. Most of the C<*:new> constructor methods provides a way to ensure that this code is consistently called every time a new instance is created.
    +
    +=over 4
    +
    +=item Composite::Hash:new { post_rules => [] }
    +
    +The Composite classes allow you to add pre- and post-operations to any method, so you can pass in a code-ref to be executed after the new() method.
    +
    +  package MyClass;
    +  
    +  sub new_post_init {
    +    my $self = ${(pop)->{result}}; # get result of original new()
    +    length($self->foo) or $self->foo('FooBar');   # default value
    +    warn "Initialized new object '$self'";       
    +  }
    +  
    +  use Class::MakeMethods (
    +    'Composite::Hash:new' => [
    +	'new' => { post_rules=>[ \&new_post_init ] } 
    +    ],
    +    'Composite::Hash:scalar' => 'foo;,
    +  );
    +  ... 
    +  package main;
    +  my $self = MyClass->new( foo => 'Foozle' )
    +
    +=item Template::Hash:new --and_then_init
    +
    +Use 'Template::Hash:new --and_then_init', which will first create the object and initialize it with the provided values, and then call an init() method on the new object before returning it.
    +
    +  package MyClass;
    +  use Class::MakeMethods::Template::Hash (
    +    'new --and_then_init' => 'new'
    +    'string'  => 'foo'
    +  );
    +  sub init {
    +    my $self = shift;
    +    length($self->foo) or $self->foo('FooBar');   # default value
    +    warn "Initialized new object '$self'";       
    +  }
    +  ... 
    +  package main;
    +  my $self = MyClass->new( foo => 'Foozle' )
    +
    +=item Template::Hash:new --with_init
    +
    +If you don't want your constructor to use the default hash-of-method-names style of initialization, use 'Template::Hash:new --with_init', which will create an empty object, pass its arguments to the init() method on the new object, and then return it.
    +
    +  package MyClass;
    +  use Class::MakeMethods::Template::Hash (
    +    'new --with_init' => 'new'
    +    'string'  => 'foo'
    +  );
    +  sub init {
    +    my $self = shift;
    +    $self->foo( shift || 'FooBar' ); # init with arg or default
    +    warn "Initialized new object '$self'";       
    +  }
    +  ... 
    +  package main;
    +  my $self = MyClass->new( 'Foozle' )
    +
    +=back
    +
    +Some additional notes about these constructors:
    +
    +=over 4
    +
    +=item * 
    +
    +The C methods allow you to specify a name for your method other than C by passing the C parameter:
    +
    +  use Class::MakeMethods::Template::Hash (
    +    'new --and_then_init' => [ 
    +	'new' => { init_method =>  'my_init' } 
    +    ],
    +  );
    +
    +=item * 
    +
    +If you know that you're not going to have a complex class hierarchy, you can reduce resource consumption a bit by changing the above declarations from "*::Hash" to "*::Array" so your objects end up as blessed arrays rather than blessed hashes.
    +
    +=back
    +
    +
    +=head2 Changing Method Names
    +
    +The Template subclasses allow you to control the names assigned to
    +the methods you generate by selecting from several naming interfaces.
    +
    +For example, the accessors declared above use a default, Perl-ish
    +style interface, in which a single method can be called without an
    +argument to retrieve the value, or with an argument to set it.
    +However, you can also select a more Java-like syntax, with separate
    +get* and set* methods, by including the '--java' template specification:
    +
    +  package MyStruct;
    +  use Class::MakeMethods::Template::Hash (
    +    'new'     => 'new',
    +    'scalar'  => '--java Foo',
    +  );
    +
    +(Note that the declaration of Foo could also have been written as
    +C<'scalar --java' =E 'Foo'> or C<'scalar' =E ['--java',
    +'Foo']>, or C<'scalar' =E [ 'foo' => { 'interface'=>'java' }
    +], all of which are interpreted identically; see the
    +L section on "Argument Normalization" for
    +details.)
    +
    +Usage of this accessor would then be as follows:
    +
    +  package main;
    +  use MyStruct;
    +  
    +  my $obj = MyStruct->new( setFoo => "Foozle" );
    +  print $obj->getFoo();
    +  $obj->setFoo("Bozzle");
    +
    +
    +=head2 Selecting Specific Helper Methods
    +
    +You can use the ability to specify interfaces to select specific helper methods rather than getting the default collection. 
    +
    +For example, let's say you wanted to use a Template::Hash:array, but you only wanted two methods to be installed in your class, a foo() accessor and a shift_foo() mutator. Any of the below combinations of syntax should do the trick:
    +
    +  use Class::MakeMethods::Template::Hash
    +    'array' => [
    +      'foo' => { interface=>{'foo'=>'get_set', 'shift_foo'=>'shift'} },
    +    ];
    +
    +If you're going to have a lot of methods with the same interface, you could pre-declare a named interface once and use it repeatedly:
    +
    +  BEGIN {
    +    require Class::MakeMethods::Template::Hash;
    +    Class::MakeMethods::Template::Hash->named_method('array')->
    +        {'interface'}->{'my_get_set_shift'} =
    +            { '*'=>'get_set', 'shift_*'=>'shift' };
    +  }
    +
    +  use Class::MakeMethods::Template::Hash
    +    'array --my_get_set_shift' => [ 'foo', 'bar' ];
    +
    +
    +=head2 Tree Structure Example
    +
    +In this example we will create a pair of classes with references
    +to other objects.
    +
    +The first class is a single-value data object implemented as a
    +reference to a scalar.
    +
    +  package MyTreeData;
    +  use Class::MakeMethods::Template::Scalar (
    +    'new'     => 'new',
    +    'string'  => 'value',
    +  );
    +
    +The second class defines a node in a tree, with a constructor, an
    +accessor for a data object from the class above, and accessors for
    +a list of child nodes.
    +
    +  package MyTreeNode;
    +  use Class::MakeMethods::Template::Hash (
    +    'new'     => 'new',
    +    'object -class MyTreeData'  => 'data',
    +    'array_of_objects -class MyTreeNode' => 'children',
    +  );
    +  
    +  sub depth_first_data {
    +    my $self = shift;
    +    return $self->data, map { $_->depth_first_data() } $self->children;
    +  }
    +
    +Here's a sample of how the above classes could be used in a program.
    +
    +  package main;
    +  use MyTreeData;
    +  use MyTreeNode;
    +
    +  my $node = MyTreeNode->new( 
    +      data => { value=>'data1' }, 
    +      children => [ { value=>'data3' } ] 
    +  );
    +  $node->push_children( MyTreeNode->new( data => { value=>'data2' } ) );
    +  
    +  foreach my $data ( $node->depth_first_data ) {
    +    print $data->value();
    +  }
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +=head2 Annotated Tutorials
    +
    +Ron Savage has posted a pair of annotated examples, linked to below.
    +Each demonstrates building a class with MakeMethods, and each
    +includes scads of comments that walk you through the logic and
    +demonstrate how the various methods work together.
    +
    +  http://savage.net.au/Perl-tutorials.html
    +  http://savage.net.au/Perl-tutorials/tut-33.tgz
    +  http://savage.net.au/Perl-tutorials/tut-34.tgz
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Docs/ReadMe.pod b/lib/Class/MakeMethods/Docs/ReadMe.pod
    new file mode 100644
    index 0000000..6fd7890
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Docs/ReadMe.pod
    @@ -0,0 +1,279 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Docs::ReadMe - About Class::MakeMethods 
    +
    +
    +=head1 DESCRIPTION
    +
    +This is an updated release of Class::MakeMethods, for distribution through
    +CPAN.
    +
    +This distribution includes the Class::MakeMethods::Template and
    +Class::MakeMethods::Emulator modules which were packaged sepearately in some
    +previous releases.
    +
    +
    +=head1 MOTIVATION
    +
    +By passing arguments to "use Class::MakeMethods ..." statements, you can
    +select from a library of hundreds of common types of methods, which are
    +dynamically installed as subroutines in your module, simplifying the code
    +for your class.
    +
    +
    +=head1 DISTRIBUTION AND INSTALLATION
    +
    +=head2 Version
    +
    +This is Class::MakeMethods v1.010, intended for general use.
    +
    +This module's CPAN registration should read:
    +
    +  Name            DSLIP  Description
    +  --------------  -----  ---------------------------------------------
    +  Class::
    +  ::MakeMethods   RdpOp  Generate common types of methods
    +
    +=head2 Prerequisites
    +
    +In general, this module should work with Perl 5.003 or later,
    +without requring any modules beyond the core Perl distribution.
    +
    +The following optional feature may not be available on some platforms:
    +
    +=over 4
    +
    +=item *
    +
    +Class::MakeMethods::Attribute: The C<:MakeMethod> subroutine
    +attribute requires Perl version 5.6 and the Attribute::Handlers
    +module (from CPAN).
    +
    +=item *
    +
    +Class::MakeMethods::Template C<--lvalue>: The lvalue modifier
    +provided by the Template generator subclasses will only work on
    +Perl version 5.6 or later.
    +
    +=item *
    +
    +Some third-party tests used to check the compliance of Emulator modules
    +require Test::More and will be automatically skipped on machines which do
    +not have this installed.
    +
    +=back
    +
    +=head2 Installation
    +
    +You should be able to install this module using the CPAN shell interface:
    +
    +  perl -MCPAN -e 'install Class::MakeMethods'
    +
    +Alternately, you may retrieve this package from CPAN or from the author's site:
    +
    +=over 2
    +
    +=item *
    +
    +http://search.cpan.org/~evo/
    +
    +=item *
    +
    +http://www.cpan.org/modules/by-authors/id/E/EV/EVO
    +
    +=item *
    +
    +http://www.evoscript.org/Class-MakeMethods/dist/
    +
    +=back
    +
    +After downloading the distribution, follow the normal procedure to unpack and install it, using the commands shown below or their local equivalents on your system:
    +
    +  tar xzf Class-MakeMethods-*.tar.gz
    +  cd Class-MakeMethods-*
    +  perl Makefile.PL
    +  make test && sudo make install
    +
    +Thanks to the kind generosity of other members of the Perl community,
    +this distribution is also available repackaged in the FreeBSD
    +"ports" and Linux RPM formats. This may simplify installation for
    +some users, but be aware that these alternate distributions may
    +lag a few versions behind the latest release on CPAN.
    +
    +=over 2
    +
    +=item *
    +
    +http://www.freebsd.org/cgi/ports.cgi?query=Class-MakeMethods
    +
    +=item *
    +
    +http://www.rpmfind.net/linux/rpm2html/search.php?query=perl-Class-MakeMethods
    +
    +=back
    +
    +=head2 Tested Platforms
    +
    +This release has been tested succesfully on the following platforms:
    +
    +  5.6.1 on darwin
    +
    +Earlier releases have also tested OK on the following platforms:
    +
    +  IP30-R12000-irix
    +  OpenBSD.i386-openbsd
    +  i386-freebsd / i386-freebsd-thread-multi
    +  i386-linux
    +  i386-netbsd / i386-netbsd-thread-multi
    +  i586-linux / i586-linux-thread-multi-ld
    +  i686-linux / i686-pld-linux-thread-multi
    +  ia64-linux
    +  ppc-linux
    +  sparc-linux
    +  sparc-netbsd
    +  sun4-solaris
    +
    +Some earlier versions failed to "make test" on MSWin32, although
    +a forced installation would still work; that problem should be
    +fixed in the most recent releases.
    +
    +You may also review the current test results from CPAN-Testers:
    +
    +=over 2
    +
    +=item *
    +
    +http://testers.cpan.org/show/Class-MakeMethods.html
    +
    +=back
    +
    +=head1 SUPPORT
    +
    +=head2 Release Status
    +
    +This module has been used in a variety of production systems and
    +has been available on CPAN for over two years, with several other
    +distributions dependant on it, so it would be fair to say that it
    +is fully released. 
    +
    +However, while the commonly-used portions are well tested, some of
    +the more obscure combinations of options are less so, and new bug
    +reports do trickle in occasionally. If you do encounter any problems,
    +please inform the author and I'll endeavor to patch them promptly.
    +
    +Additional features have been outlined for future development, but
    +the intent is support these by adding more options to the declaration
    +interface, while maintaining backward compatibility.
    +
    +See L for other outstanding issues
    +and development plans.
    +
    +=head2 Support
    +
    +If you have questions or feedback about this module, please feel
    +free to contact the author at the below address. Although there is
    +no formal support program, I do attempt to answer email promptly. 
    +
    +I would be particularly interested in any suggestions towards
    +improving the documentation and correcting any Perl-version or platform
    +dependencies, as well as general feedback and suggested additions.
    +
    +Bug reports that contain a failing test case are greatly appreciated,
    +and suggested patches will be promptly considered for inclusion in
    +future releases.
    +
    +To report bugs via the CPAN web tracking system, go to 
    +C or send mail 
    +to C, replacing C<#> with C<@>.
    +
    +=head2 Community
    +
    +If you've found this module useful or have feedback about your
    +experience with it, consider sharing your opinion with other Perl
    +users by posting your comment to CPAN's ratings system:
    +
    +=over 2
    +
    +=item *
    +
    +http://cpanratings.perl.org/rate/?distribution=Class-MakeMethods
    +
    +=back
    +
    +For more general discussion, you may wish to post a message on PerlMonks or the comp.lang.perl.misc newsgroup:
    +
    +=over 2
    +
    +=item *
    +
    +http://www.perlmonks.org/index.pl?node=Seekers%20of%20Perl%20Wisdom
    +
    +=item *
    +
    +http://groups.google.com/groups?group=comp.lang.perl.misc
    +
    +=back
    +
    +
    +=head1 CREDITS AND COPYRIGHT
    +
    +=head2 Author
    +
    +Developed by Matthew Simon Cavalletto at Evolution Softworks. 
    +More free Perl software is available at C.
    +
    +You may contact the author directly at C or C. 
    +
    +=head2 Feedback and Suggestions 
    +
    +Thanks to the following people for bug reports, suggestions, and other feedback:
    +
    +  Martyn J. Pearce
    +  Scott R. Godin
    +  Ron Savage
    +  Jay Lawrence
    +  Adam Spiers
    +  Malcolm Cook
    +  Terrence Brannon
    +  Jared Rhine
    +  Peter Chen
    +  Mike Castle
    +
    +=head2 Source Material
    +
    +This package was inspired by the ground-breaking original closure-generating method maker module:
    +
    +  Class::MethodMaker, by Peter Seibel.
    +
    +Additional inspiration, cool tricks, and blocks of useful code for
    +this module were extracted from the following CPAN modules:
    +
    +  Class::Accessor, by Michael G Schwern 
    +  Class::Contract, by Damian Conway
    +  Class::SelfMethods, by Toby Everett
    +
    +=head2 Copyright
    +
    +Copyright 2002, 2003 Matthew Simon Cavalletto. 
    +
    +Portions copyright 1998, 1999, 2000, 2001 Evolution Online Systems, Inc.
    +
    +Based on Class::MethodMaker, originally developed by Peter Seibel. Portions Copyright 1996 Organic Online. Portions Copyright 2000 Martyn J. Pearce. 
    +
    +Class::MakeMethods::Emulator::accessors is based on accessors. Portions by Steve Purkis.
    +
    +Class::MakeMethods::Emulator::AccessorFast is based on Class::Accessor::Fast. Portions Copyright 2000 Michael G Schwern.
    +
    +Class::MakeMethods::Emulator::Inheritable is based on Class::Data::Inheritable. Portions Copyright 2000 Damian Conway and Michael G Schwern.
    +
    +Class::MakeMethods::Emulator::mcoder is based on mcoder. Portions Copyright 2003 by Salvador Fandiño.
    +
    +Class::MakeMethods::Emulator::Singleton is based on Class::Singleton, by Andy Wardley. Portions Copyright 1998 Canon Research Centre Europe Ltd. 
    +
    +Class::MakeMethods::Utility::Ref is based on Ref.pm. Portions Copyright 1994 David Muir Sharnoff.
    +
    +=head2 License
    +
    +You may use, modify, and distribute this software under the same terms as Perl.
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Docs/RelatedModules.pod b/lib/Class/MakeMethods/Docs/RelatedModules.pod
    new file mode 100644
    index 0000000..93ef930
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Docs/RelatedModules.pod
    @@ -0,0 +1,962 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Docs::RelatedModules - Survey of Class Builders
    +
    +
    +=head1 SYNOPSIS
    +
    +  http://search.cpan.org/search?mode=module&query=Class
    +
    +
    +=head1 DESCRIPTION
    +
    +There are a variety of modules on CPAN dedicated to the purpose of
    +generating common constructor and accessor methods. Below, I survey
    +several of these, summarizing some basic features and technical
    +approaches, and comparing them to Class::MakeMethods and other
    +modules.
    +
    +
    +=head2 Caution
    +
    +B Please consult the
    +documentation from a current version of each module for more specific
    +details.  Corrections and clarifications would by welcomed by the author at the email address below.
    +
    +
    +=head2 Points of Comparison
    +
    +In general, I compared the following characteristics:
    +
    +=over 4
    +
    +=item Distribution
    +
    +Is it included with Perl, or on CPAN? Is it being actively maintained?
    +
    +=item Usage
    +
    +How do you go about declaring your class's methods?
    +
    +=item Mechanism
    +
    +How are they generated and delivered?
    +
    +=item Instance type
    +
    +Are the objects of your class blessed hashes, or something else?
    +
    +=item Core Methods
    +
    +Does the module provide a constructor and basic accessors? Are there specialized methods for hash-ref, array-ref, and object-ref accessors?
    +
    +=item Extensible
    +
    +Can you subclass the package to create new types of methods, or is there some other way to extend it?
    +
    +=item Other Methods
    +
    +Other types of methods provided.
    +
    +=item Emulator
    +
    +Does Class::MakeMethods provide a drop-in replacement for this module?
    +
    +=item Comments
    +
    +Other characteristics or features of note.
    +
    +=back
    +
    +
    +=head1 RELATED MODULES 
    +
    +=head2 accessors
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Uploaded Sep 2003.
    +
    +=item Comments
    +
    +I have not yet reviewed this module in detail.
    +
    +=item Example
    +
    +  package MyObject;
    +  use accessors qw( foo bar baz );
    +
    +=back
    +
    +=head2 Attribute::Property
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN.
    +
    +=item Comments
    +
    +I have not yet reviewed this module in detail.
    +
    +=back
    +
    +
    +=head2 Class::Accessor
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 4/01.
    +
    +=item Usage
    +
    +Inherit and call function with declaration arguments 
    +
    +=item Mechanism
    +
    +Generates and installs closures
    +
    +=item Instance Type
    +
    +Hash.
    +
    +=item Subclasses Cleanly
    +
    +Cleanly.
    +
    +=item Standard Methods
    +
    +Scalar accessors.
    +
    +=item Extensible
    +
    +Yes.
    +
    +=item Comments
    +
    +Accessor methods call overwritable Cget(I)> and
    +Cset(I, I)> methods.
    +
    +Also includes Class::Accessor::Fast, which creates direct hash keys accessors without calling get and set methods.
    +
    +=item Emulator
    +
    +Yes, but only for the Fast variation; see Class::MakeMethods::Emulator::AccessorFast.
    +
    +=item Example
    +
    +  package MyObject;
    +  @ISA = qw(Class::Accessor);
    +  MyObject->mk_accessors(qw( simple ordered mapping obj_ref ));
    +
    +=back
    +
    +
    +=head2 Class::Class
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 1/00.
    +
    +=item Usage
    +
    +Inherit and fill %MEMBERS hash; methods created when first object is created
    +
    +=item Mechanism
    +
    +Generates and installs closures
    +
    +=item Instance Type
    +
    +Hash.
    +
    +=item Subclasses Cleanly
    +
    +Yes.
    +
    +=item Standard Methods
    +
    +Constructor and various accessors.
    +
    +=item Extensible
    +
    +No.
    +
    +=item Example
    +
    +Usage is similar to Class::Struct:
    +
    +  package MyObject;
    +  use Class::Class; 
    +  @ISA = qw(Class::Class);
    +  %MEMBERS = ( 
    +    simple  => '$',
    +    ordered => '@',
    +    mapping => '%',
    +    obj_ref => 'FooObject' 
    +  ); 
    +
    +=item Other Method Types
    +
    +Provides a polymorph() method that is similar to Class::Method's "ClassName:class_name -require".
    +
    +=back
    +
    +
    +=head2 Class::Constructor
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 11/01.
    +
    +=item Usage
    +
    +Inherit and call function with declaration arguments 
    +
    +=item Mechanism
    +
    +Generates and installs closures
    +
    +=item Instance Type
    +
    +Hash.
    +
    +=item Subclasses Cleanly
    +
    +Cleanly.
    +
    +=item Standard Methods
    +
    +Hash constructor, with bells.
    +
    +=item Extensible
    +
    +No.
    +
    +=item Emulator
    +
    +No, but possible.
    +
    +=item Example
    +
    +  package MyObject;
    +  @ISA = qw(Class::Constructor);
    +  MyObject->mk_constructor( Name => 'new' );
    +
    +=back
    +
    +
    +=head2 Class::Classgen
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 12/00.
    +
    +=item Usage
    +
    +Pre-processor run against declaration files. 
    +
    +=item Mechanism
    +
    +Assembles and saves code file
    +
    +=item Instance Type
    +
    +Hash.
    +
    +=item Subclasses Cleanly
    +
    +Yes. (I think.)
    +
    +=item Standard Methods
    +
    +Constructor and various accessors.
    +
    +=item Extensible
    +
    +No. (I think.)
    +
    +=item Example
    +
    +  header:
    +      package MyObject;
    +  variables:
    +      $simple
    +      @ordered
    +      %mapping
    +      $obj_ref
    +
    +=back
    +
    +
    +=head2 Class::Contract
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 5/01.
    +
    +=item Usage
    +
    +Call function with declaration arguments 
    +
    +=item Mechanism
    +
    +Generates and installs closures
    +
    +=item Instance Type
    +
    +Scalar reference with external data storage.
    +
    +=item Subclasses Cleanly
    +
    +Yes.
    +
    +=item Standard Methods
    +
    +Constructor and various accessors.
    +
    +=item Extensible
    +
    +Yes. (I think.)
    +
    +=item Comments
    +
    +Supports pre- and post-conditions, class invariants, and other
    +software engineering goodies.
    +
    +=item Example
    +
    +  package MyObject;
    +  use Class::Contract;
    +  contract {
    +    ctor 'new';
    +    attr 'simple'  => SCALAR;
    +    attr 'ordered' => ARRAY;  
    +    attr 'mapping' => HASH;   
    +    attr 'obj_ref' => 'FooObject';   
    +  }
    +
    +=back
    +
    +
    +=head2 Class::Data::Inheritable
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 4/00.
    +
    +=item Usage
    +
    +Inherit and call function with declaration arguments 
    +
    +=item Mechanism
    +
    +Generates and installs closures
    +
    +=item Instance Type
    +
    +Class data, with inheritance.
    +
    +=item Subclasses Cleanly
    +
    +Yes, specifically.
    +
    +=item Standard Methods
    +
    +Scalar accessors.
    +
    +=item Extensible
    +
    +No.
    +
    +=item Example
    +
    +Usage is similar to Class::Accessor:
    +
    +  package MyObject;
    +  @ISA = qw(Class::Data::Inheritable);
    +  MyObject->mk_classdata(qw( simple ordered mapping obj_ref ));
    +
    +=item Emulator
    +
    +Yes, Class::MakeMethods::Emulator::Inheritable, passes original test suite.
    +
    +=back
    +
    +
    +=head2 Class::Delegate
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Uploaded 12/0.
    +
    +=item Comments
    +
    +I have not yet reviewed this module in detail.
    +
    +=back
    +
    +=head2 Class::Delegation
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Uploaded 12/01.
    +
    +=item Comments
    +
    +I have not yet reviewed this module in detail.
    +
    +=back
    +
    +=head2 Class::Generate
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 11/00. 
    +
    +=item Usage
    +
    +Call function with declaration arguments 
    +
    +=item Mechanism
    +
    +Assembles and evals code string, or saves code file.
    +
    +=item Instance Type
    +
    +Hash.
    +
    +=item Subclasses Cleanly
    +
    +Yes.
    +
    +=item Standard Methods
    +
    +Constructor and accessors (scalar, array, hash, object, object array, etc).
    +
    +=item Extensible
    +
    +Unknown.
    +
    +=item Comments
    +
    +Handles private/protected limitations, pre and post conditions,
    +assertions, and more.
    +
    +=item Example
    +
    +Usage is similar to Class::Struct:
    +
    +  package MyObject;
    +  use Class::Generate;
    +  class MyObject => [ 
    +    simple  => '$',
    +    ordered => '@',
    +    mapping => '%',
    +    obj_ref => 'FooObject' 
    +  ]; 
    +
    +=back
    +
    +=head2 Class::Hook
    +
    +=item Distribution
    +
    +CPAN. Uploaded 12/01.
    +
    +=item Comments
    +
    +I have not yet reviewed this module in detail.
    +
    +
    +=head2 Class::Holon
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Experimental/Alpha release 07/2001. 
    +
    +=item Instance Type
    +
    +Hash, array, or flyweight-index.
    +
    +=item Subclasses Cleanly
    +
    +No. (I think.)
    +
    +=item Standard Methods
    +
    +Constructor and scalar accessors; flywieght objects also get scalar mutator methods.
    +
    +=item Extensible
    +
    +No. (I think.)
    +
    +=item Comments
    +
    +I'm not sure I understand the intent of this module; perhaps future versions will make this clearer....
    +
    +=back
    +
    +
    +=head2 Class::MethodMaker
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 1/01. 
    +
    +=item Usage
    +
    +Import, or call function, with declaration arguments 
    +
    +=item Mechanism
    +
    +Generates and installs closures
    +
    +=item Instance Type
    +
    +Hash, Static.
    +
    +=item Subclasses Cleanly
    +
    +Yes.
    +
    +=item Standard Methods
    +
    +Constructor and various accessors.
    +
    +=item Extensible
    +
    +Yes.
    +
    +=item Example
    +
    +Usage is similar to Class::MakeMethods:
    +
    +  package MyObject;
    +  use Class::MethodMaker (
    +    new     =>   'new',
    +    get_set =>   'simple',
    +    list    =>   'ordered',
    +    hash    =>   'mapping',
    +    object  => [ 'FooObject' => 'obj_ref' ],
    +  );
    +
    +=item Emulator
    +
    +Yes, Class::MakeMethods::Emulator::MethodMaker, passes original test suite.
    +
    +=back
    +
    +
    +=head2 Class::MakeMethods
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN.
    +
    +=item Usage
    +
    +Import, or call function, with declaration arguments; or if desired, make methods on-demand with Autoload, or declare subroutines with a special Attribute.
    +
    +=item Mechanism
    +
    +Generates and installs closures
    +
    +=item Instance Type
    +
    +Hash, Array, Scalar, Static, Class data, others.
    +
    +=item Subclasses Cleanly
    +
    +Yes.
    +
    +=item Standard Methods
    +
    +Constructor and various accessors.
    +
    +=item Extensible
    +
    +Yes.
    +
    +=item Example
    +
    +Usage is similar to Class::MethodMaker:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Hash (
    +    new    =>   'new',
    +    scalar =>   'simple',
    +    array  =>   'ordered',
    +    hash   =>   'mapping',
    +    object => [ 'obj_ref', { class=>'FooObject' } ],
    +  );
    +
    +=back
    +
    +
    +=head2 Class::Maker
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 7/02.
    +
    +=item Usage
    +
    +Call function with declaration arguments.
    +
    +=item Mechanism
    +
    +Generates and installs closures (I think).
    +
    +=item Instance Type
    +
    +Hash (I think).
    +
    +=item Subclasses Cleanly
    +
    +Unknown.
    +
    +=item Standard Methods
    +
    +Constructor and various scalar and reference accessors.
    +
    +=item Extensible
    +
    +Unknown.
    +
    +=item Comments
    +
    +I haven't yet reviewed this module closely.
    +
    +=back
    +
    +
    +=head2 Class::SelfMethods
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 2/00.
    +
    +=item Usage
    +
    +Inherit; methods created via AUTOLOAD
    +
    +=item Mechanism
    +
    +Generates and installs closures (I think)
    +
    +=item Instance Type
    +
    +Hash.
    +
    +=item Subclasses Cleanly
    +
    +Yes.
    +
    +=item Standard Methods
    +
    +Constructor and scalar/code accessors (see Comments).
    +
    +=item Extensible
    +
    +No.
    +
    +=item Comments
    +
    +Individual objects may be assigned a subroutine that will be called as a method on subsequent accesses. If an instance does not have a value for a given accessor, looks for a method defined with a leading underscore.
    +
    +=back
    +
    +
    +=head2 Class::Struct
    +
    +=over 4
    +
    +=item Distribution
    +
    +Included in the standard Perl distribution. Replaces Class::Template.
    +
    +=item Usage
    +
    +Call function with declaration arguments 
    +
    +=item Mechanism
    +
    +Assembles and evals code string
    +
    +=item Instance Type
    +
    +Hash or Array
    +
    +=item Subclasses Cleanly
    +
    +No.
    +
    +=item Standard Methods
    +
    +Constructor and various accessors.
    +
    +=item Extensible
    +
    +No.
    +
    +  package MyObject;
    +  use Class::Struct;
    +  struct( 
    +    simple  => '$',
    +    ordered => '@',
    +    mapping => '%',
    +    obj_ref => 'FooObject' 
    +  );
    +
    +=item Emulator
    +
    +Yes, Class::MakeMethods::Emulator::Struct.
    +
    +=back
    +
    +
    +=head2 Class::StructTemplate
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 12/00. 
    +
    +No documentation available.
    +
    +=item Usage
    +
    +Unknown.
    +
    +=item Mechanism
    +
    +Unknown.
    +
    +=back
    +
    +
    +=head2 Class::Template
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Out of date.
    +
    +=item Usage
    +
    +Call function with declaration arguments (I think)
    +
    +=item Mechanism
    +
    +Assembles and evals code string (I think)
    +
    +=item Instance Type
    +
    +Hash.
    +
    +=item Subclasses Cleanly
    +
    +Yes. (I think.)
    +
    +=item Standard Methods
    +
    +Constructor and various accessors.
    +
    +=item Extensible
    +
    +No. (I think.)
    +
    +=item Example
    +
    +Usage is similar to Class::Struct:
    +
    +  package MyObject;
    +  use Class::Template;
    +  members MyObject { 
    +    simple  => '$',
    +    ordered => '@',
    +    mapping => '%',
    +    obj_ref => 'FooObject' 
    +  };
    +
    +=back
    +
    +
    +=head2 Class::Virtual
    +
    +Generates methods that fail with a message indicating that they were not implemented by the subclass. (Cf. 'Template::Universal:croak -abstract'.)
    +
    +Also provides a list of abstract methods that have not been implemented by a subclass.
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. Last update 3/01.
    +
    +=item Extensible
    +
    +Unknown.
    +
    +=item Mechanism
    +
    +Uses Class::Data::Inheritable and installs additional closures.
    +
    +=back
    +
    +
    +=head2 CodeGen::PerlBean
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. 
    +
    +=item Usage
    +
    +Call function with declaration arguments.
    +
    +=item Mechanism
    +
    +Generates and writes source code to a file.
    +
    +=item Instance Type
    +
    +Hash (I think).
    +
    +=item Subclasses Cleanly
    +
    +Unknown.
    +
    +=item Standard Methods
    +
    +Constructor and various scalar and reference accessors.
    +
    +=item Extensible
    +
    +Unknown.
    +
    +=item Comments
    +
    +I haven't yet reviewed this module closely.
    +
    +=back
    +
    +
    +=head2 HTML::Mason::MethodMaker
    +
    +=over 4
    +
    +=item Distribution
    +
    +CPAN. 
    +
    +=item Usage
    +
    +Package import with declaration arguments
    +
    +=item Mechanism
    +
    +Generates and installs closures
    +
    +=item Instance Type
    +
    +Hash.
    +
    +=item Standard Methods
    +
    +Scalar accessors.
    +
    +=item Extensible
    +
    +No.
    +
    +=item Example
    +
    +  use HTML::Mason::MethodMaker ( 
    +    read_write => [ qw( simple ordered mapping obj_ref ) ] 
    +  );
    +
    +=back
    +
    +
    +=head1 TO DO
    +
    +The following modules are relevant but have not yet been cataloged above.
    +
    +=head2 Attribute::Property
    +
    +=head2 Class::Accessor::Chained
    +
    +=head2 Class::Accessor::Lvalue
    +
    +=head2 Class::Accessor::Ref
    +
    +=head2 Class::AutoClass
    +
    +=head2 Class::Builder
    +
    +=head2 Class::Member
    +
    +=head2 Class::Trigger
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +
    +=head1 CREDITS AND COPYRIGHT
    +
    +=head2 Developed By
    +
    +  M. Simon Cavalletto, simonm@cavalletto.org
    +  Evolution Softworks, www.evoscript.org
    +
    +=head2 Copyright
    +
    +Copyright 2002 Matthew Simon Cavalletto. 
    +
    +Portions copyright 2000, 2001 Evolution Online Systems, Inc.
    +
    +=head2 License
    +
    +You may use, modify, and distribute this document under the same terms as Perl.
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Docs/ToDo.pod b/lib/Class/MakeMethods/Docs/ToDo.pod
    new file mode 100644
    index 0000000..312bdc0
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Docs/ToDo.pod
    @@ -0,0 +1,296 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Docs::ToDo - Ideas, problems, and suggestions
    +
    +
    +=head1 SYNOPSIS
    +
    +There are lots of things that could be done to improve this module.
    +
    +
    +=head1 DISTRIBUTION ISSUES
    +
    +Issues about the distribution and supporting files, rather than the code:
    +
    +=head2 Documentation
    +
    +=over 4
    +
    +=item *
    +
    +Make sure that the documentation is broken up into appropriately-sized
    +chunks, and that people will know which section to look at.
    +
    +=item *
    +
    +As user questions arrive, add the answers as documentation points or examples.
    +
    +=item *
    +
    +Assemble annotated examples and tutorials, and either link to or distribute them.
    +
    +=item *
    +
    +Finish overhauling Template documentation.
    +
    +=item * 
    +
    +Include Global and InsideOut uses in the EXAMPLES section
    +
    +=item *
    +
    +Template Internals: Finish documenting disk-based meta-method code-caching. 
    +
    +=back
    +
    +=head2 Tests
    +
    +=over 4
    +
    +=item *
    +
    +Use Devel::Coverage to measure test coverage, and fill in missing
    +cases.
    +
    +=item *
    +
    +Finish tests for Standard and Composite modules.
    +
    +=back
    +
    +
    +=head1 GENERAL ISSUES
    +
    +=over 4
    +
    +=item *
    +
    +It does not appear to be possible to assign subroutine names to
    +closures within Perl. As a result, debugging output from Carp and
    +similar sources will show all generated methods as "ANON()" rather
    +than "YourClass::methodname()".
    +
    +UPDATE: There now seem to be fixes for this which should be integrated: See the new Sub::Name module and http://perlmonks.org/index.pl?node_id=304883
    +
    +=item *
    +
    +For scalar methods (and others) it would be nice to have a simple
    +bounds-checking interface to approve or reject (with an exception)
    +new values that were passed in.
    +
    +As pointed out by Terrence Brannon, the right interface to
    +adopt is probably that of Attribute::Types:
    +
    +  use Class::MakeMethods::Standard::Hash (
    +    'scalar' => [ 'count' => { TYPE => 'INTEGER' } ],
    +    'scalar' => [ 'name' => { TYPE => qr/^[A-Z]\w*$/ } ],
    +    'scalar' => [ 'account' => { TYPE => &checksum_account_number } ]
    +  );
    +
    +=item *
    +
    +Improve use of _diagnostic hooks for debugging. Add various "(Q)"
    +debug diagnostics.
    +
    +=item *
    +
    +Finish building Inheritable array and object accessors.
    +
    +=item *
    +
    +Finish building Composite::* packages.
    +
    +=item *
    +
    +Resolve DESTROY-time issues with Standard::Inheritable, Composite::Inheritable, and Template::InsideOut.
    +
    +=item *
    +
    +Add slice and splice functionality to Standard::*:hash and Composite::*:hash.
    +
    +=back
    +
    +
    +=head1 TEMPLATE CLASSES
    +
    +=head2 Template::Generic 
    +
    +=over 4
    +
    +=item *
    +
    +Allow untyped object accesors if C attribute is not set.
    +(Suggested in Jan-01 NY Perl Seminar discussion.)
    +
    +=item *
    +
    +Standardize naming templates for array, hash, other method types. 
    +
    +Deprecate verb_x methods? Or at last make them consistently available both ways.
    +
    +Make list methods consistent with hash_of_lists methods, in action, and
    +in name (x_verb).  Also for others (e.g., set_ clear_ boolean)
    +
    +=item *
    +
    +Should default object template provide auto-create behavior on ->get()?
    +
    +=item *
    +
    +Generalize the "Generic:scalar -init_and_get" interface to support 
    +memoizing values for other accessor types.
    +
    +=item *
    +
    +Consider adding hash each and array iterator methods, using a closure 
    +to provide iteration.
    +
    +=item *
    +
    +Add support for tied arrays & scalars, a la tiedhash
    +
    +=item *
    +
    +Add string_multiple_index.
    +
    +=item *
    +
    +Extend index methods to support weak indexes with WeakRef. Perhaps
    +just have it accept a hash ref to use as the index, and then allow
    +people to pass in tied hashes?
    +
    +=item *
    +
    +Maybe make private or protected method croak if they were called by a
    +method_init method which was called by an outside package.
    +
    +Not entirely clear what the right semantics or security precautions are here... 
    +
    +=back
    +
    +
    +=head2 Template::Generic Subclasses
    +
    +=over 4
    +
    +=item *
    +
    +Finish building code_or_scalar meta-method.
    +
    +=item * 
    +
    +Finish building Class::MakeMethods::ClassInherit subclass.
    +
    +Need to work out how to capture changes for non-scalar values. For
    +example, if a subclass inherits an array accessor and then pops
    +it, is there some way to provide them with copy-on-write?
    +
    +=item *
    +
    +Add enumerated string/number type.
    +
    +Provide helper methods with map of associated values (ex $o->port
    += 80 ... $o->port_readable eq 'HTTP' ). Cf. code for earlier
    +unpublished 'lookup' method type.
    +
    +=item *
    +
    +For StructBuiltin:
    +
    +Add -fatal flag to die if core func returns false / undef
    +Add call method to recall method with alternative arguments.
    +Add -nocall flag to not call core func on new.
    +
    +=item *
    +
    +Replace ClassName:static_hash_classname with Class:indexed_string.
    +
    +=back
    +
    +
    +=head2 Template Internals
    +
    +=over 4
    +
    +=item *
    +
    +Figure out which modules, if any, should actually be using AutoLoader.
    +Probably just Template::Generic?
    +
    +=item *
    +
    +Give users a way to do meta-method code-caching in Perl library
    +hierarchy, rather than in /tmp/auto or other user-specified
    +directory..
    +
    +Provide mechanism for pre-generating these at install time.
    +
    +Perhaps load these via do, rather than open/read/eval?
    +
    +Perhaps pre-generate expanded libs with all of the -imports resolved?
    +
    +=item *
    +
    +Support generating code files and loading them as needed.
    +
    +This would be similar to Class::Classgen, except that we'd do the
    +generation at run-time the first time it was required, rather than
    +in a separate pass.
    +
    +For example, given the following declaration:
    +
    +  package Foo::Bar;
    +  Class::MakeMethods::Template::Hash->import(-codecache=>'auto', scalar=>'foo');
    +
    +We should be able to write out the following file:
    +
    +  cat 'auto/Foo/Bar/methods-line-2.pl'
    +  # NOTE: Generated for Foo::Bar by the Class::MakeMethods module.
    +  # Changes made here will be lost when Foo::Bar is modified.
    +  package Foo::Bar;
    +  sub foo {
    +    my $self = shift;
    +    if ( scalar @_ ) {
    +      $self->{'foo'} = shift();
    +    }
    +    $self->{'foo'}
    +  }
    +
    +Then on subsequent uses, we can just re-load the generated code:
    +
    +  require "auto/Foo/Bar/methods-line-2.pl";
    +
    +To do this, we need to:
    +
    +=over 4
    +
    +=item *
    +
    +Provide an option to select this if desired; maybe ... 
    +import('-cache' => 'auto/', ...)?
    +
    +=item *
    +
    +Figure out which directory we can/should write into.
    +
    +=item *
    +
    +Re-evaluate the textual code templates, without generating the
    +closures. Substitute in any _STATIC_ATTR_ values. Make other _ATTR_
    +values point to some public lookup table or package scalar.
    +
    +=item *
    +
    +Notice if the source file (or Class::MakeMethods modules) has
    +been updated more recently than the generated file.
    +
    +=back
    +
    +=back
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Emulator.pm b/lib/Class/MakeMethods/Emulator.pm
    new file mode 100644
    index 0000000..96786da
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Emulator.pm
    @@ -0,0 +1,165 @@
    +package Class::MakeMethods::Emulator;
    +
    +$VERSION = 1.009;
    +
    +########################################################################
    +### IMPORT BEHAVIOR: import(), _handle_namespace()
    +########################################################################
    +
    +@EXPORT_OK = qw( namespace_capture namespace_release );
    +sub import { 
    +  
    +  if ( scalar @_ == 2 and $_[1] eq '-isasubclass' ) {
    +    splice @_, 1, 1;
    +    my $target_class = ( caller )[0];
    +    no strict;
    +    push @{"$target_class\::ISA"}, $_[0];
    +  }
    +  
    +  if ( $_[0] eq __PACKAGE__ ) {
    +    require Exporter and goto &Exporter::import  # lazy Exporter
    +  }
    +}
    +
    +sub _handle_namespace {
    +  my $class = shift;
    +  my $emulation_target = shift;
    +  my $firstarg = shift or return;
    +  my $take = shift || '-take_namespace';
    +  my $release = shift || '-release_namespace';
    +  
    +  if ( $firstarg eq $take) {
    +    Class::MakeMethods::Emulator::namespace_capture($class, $emulation_target);
    +    return 1;
    +  } elsif ( $firstarg eq $release) {
    +    Class::MakeMethods::Emulator::namespace_release($class, $emulation_target);
    +    return 1;
    +  }
    +}
    +
    +########################################################################
    +### NAMESPACE MUNGING: _namespace_capture(), _namespace_release()
    +########################################################################
    +
    +sub namespace_capture {
    +  my $source_package = shift;
    +  my $target_package = shift;
    +
    +  # warn "Mapping $source_package over $target_package \n";
    +
    +  my $source_file = "$source_package.pm";
    +  $source_file =~ s{::}{/}g;
    +  
    +  my $target_file = "$target_package.pm";
    +  $target_file =~ s{::}{/}g;
    +  
    +  my $temp_package = $source_package . '::Target::' . $target_package;
    +  my $temp_file = "$temp_package.pm";
    +  $temp_file =~ s{::}{/}g;
    +  
    +  no strict;
    +  unless ( ${$temp_package . "::TargetCaptured"} ++ ) {
    +    *{$temp_package . "::"} = *{$target_package . "::"};
    +    $::INC{$temp_file} = $::INC{$target_file};
    +  }
    +  *{$target_package . "::"} = *{$source_package . "::"};
    +  $::INC{$target_file} = $::INC{$source_file}
    +}
    +
    +sub namespace_release {
    +  my $source_package = shift;
    +  my $target_package = shift;
    +  
    +  my $target_file = "$target_package.pm";
    +  $target_file =~ s{::}{/}g;
    +  
    +  my $temp_package = $source_package . '::Target::' . $target_package;
    +  my $temp_file = "$temp_package.pm";
    +  $temp_file =~ s{::}{/}g;
    +  
    +  no strict;
    +  unless ( ${"${temp_package}::TargetCaptured"} ) {
    +    Carp::croak("Can't _namespace_release: -take_namespace not called yet.");
    +  }
    +  *{$target_package . "::"} = *{$temp_package. "::"};
    +  $::INC{$target_file} = $::INC{$temp_file};
    +}
    +
    +########################################################################
    +
    +1;
    +
    +__END__
    +
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Emulator - Demonstrate class-generator equivalency
    +
    +
    +=head1 SYNOPSIS
    +
    +  # Equivalent to use Class::Singleton;
    +  use Class::MakeMethods::Emulator::Singleton; 
    +  
    +  # Equivalent to use Class::Struct;
    +  use Class::MakeMethods::Emulator::Struct; 
    +  struct ( ... );
    +  
    +  # Equivalent to use Class::MethodMaker( ... );
    +  use Class::MakeMethods::Emulator::MethodMaker( ... );
    +  
    +  # Equivalent to use base 'Class::Inheritable';
    +  use base 'Class::MakeMethods::Emulator::Inheritable';
    +  MyClass->mk_classdata( ... );
    +  
    +  # Equivalent to use base 'Class::AccessorFast';
    +  use base 'Class::MakeMethods::Emulator::AccessorFast';
    +  MyClass->mk_accessors(qw(this that whatever));
    +  
    +  # Equivalent to use accessors( ... );
    +  use Class::MakeMethods::Emulator::accessors( ... );
    +  
    +  # Equivalent to use mcoder( ... );
    +  use Class::MakeMethods::Emulator::mcoder( ... );
    +
    +
    +=head1 DESCRIPTION
    +
    +In several cases, Class::MakeMethods provides functionality closely
    +equivalent to that of an existing module, and it is simple to map
    +the existing module's interface to that of Class::MakeMethods.
    +
    +Class::MakeMethods::Emulator provides emulators for Class::MethodMaker,
    +Class::Accessor::Fast, Class::Data::Inheritable, Class::Singleton,
    +Class::Struct, accessors, and mcoder, each of which passes the
    +original module's test suite, usually requiring only the addition
    +of a a single line to each test, activating the emulation module.
    +
    +Beyond demonstrating compatibility, these emulators also generally
    +indicate the changes needed to switch to direct use of Class::MakeMethods
    +functionality, illustrate commonalities between the various modules,
    +and serve as a source for new ideas that can be integrated into
    +Class::MakeMethods.
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L, and L from CPAN.
    +
    +See L, and L from CPAN.
    +
    +See L, and L from CPAN.
    +
    +See L, and L from CPAN.
    +
    +See L, and L from CPAN.
    +
    +See L, and L from CPAN.
    +
    +See L, and L from CPAN.
    +
    +=cut
    +
    diff --git a/lib/Class/MakeMethods/Emulator/AccessorFast.pm b/lib/Class/MakeMethods/Emulator/AccessorFast.pm
    new file mode 100644
    index 0000000..0f47e04
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Emulator/AccessorFast.pm
    @@ -0,0 +1,102 @@
    +package Class::MakeMethods::Emulator::AccessorFast;
    +
    +use strict;
    +use Class::MakeMethods::Composite::Hash;
    +use Class::MakeMethods::Emulator '-isasubclass';
    +
    +sub _emulator_target { 'Class::Accessor::Fast' }
    +
    +sub import {
    +  my $class = shift;  
    +  $class->_handle_namespace( $class->_emulator_target, $_[0] ) and shift;
    +}
    +
    +########################################################################
    +
    +sub mk_accessors {
    +  Class::MakeMethods::Composite::Hash->make(
    +    -TargetClass => (shift),
    +    'new' => { name => 'new', modifier => 'with_values' },
    +    'scalar' => [ map { 
    +	$_, 
    +	"_${_}_accessor", { 'hash_key' => $_ } 
    +    } @_ ],
    +  );
    +}
    +
    +sub mk_ro_accessors {
    +  Class::MakeMethods::Composite::Hash->make(
    +    -TargetClass => (shift),
    +    'new' => { name => 'new', modifier => 'with_values' },
    +    'scalar' => [ map { 
    +	$_, { permit => 'ro' }, 
    +	"_${_}_accessor", { 'hash_key' => $_, permit => 'ro' }
    +    } @_ ],
    +  );
    +}
    +
    +sub mk_wo_accessors {
    +  Class::MakeMethods::Composite::Hash->make(
    +    -TargetClass => (shift),
    +    'new' => { name => 'new', modifier => 'with_values' },
    +    'scalar' => [ map { 
    +	$_, { permit => 'wo' }, 
    +	"_${_}_accessor", { 'hash_key' => $_, permit => 'wo' } 
    +    } @_ ],
    +  );
    +}
    +
    +########################################################################
    +
    +1;
    +
    +__END__
    +
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Emulator::AccessorFast - Emulate Class::Accessor::Fast
    +
    +
    +=head1 SYNOPSIS
    +
    +    package Foo;
    +    
    +    use base qw(Class::MakeMethods::Emulator::AccessorFast);
    +    Foo->mk_accessors(qw(this that whatever));
    +    
    +    # Meanwhile, in a nearby piece of code!
    +    # Emulator::AccessorFast provides new().
    +    my $foo = Foo->new;
    +    
    +    my $whatever = $foo->whatever;    # gets $foo->{whatever}
    +    $foo->this('likmi');              # sets $foo->{this} = 'likmi'
    +
    +
    +=head1 DESCRIPTION
    +
    +This module emulates the functionality of Class::Accessor::Fast, using Class::MakeMethods to generate similar methods.
    +
    +You may use it directly, as shown in the SYNOPSIS above, 
    +
    +Furthermore, you may call  C to alias the Class::Accessor::Fast namespace
    +to this package, and subsequent calls to the original package will
    +be transparently handled by this emulator. To remove the emulation
    +aliasing, call C.
    +
    +B This affects B subsequent uses of Class::Accessor::Fast
    +in your program, including those in other modules, and might cause
    +unexpected effects.
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +See L for documentation of the original module.
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Emulator/Inheritable.pm b/lib/Class/MakeMethods/Emulator/Inheritable.pm
    new file mode 100644
    index 0000000..90b0a91
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Emulator/Inheritable.pm
    @@ -0,0 +1,162 @@
    +package Class::MakeMethods::Emulator::Inheritable;
    +
    +use strict;
    +
    +use Class::MakeMethods::Template::ClassInherit;
    +use Class::MakeMethods::Emulator qw( namespace_capture namespace_release );
    +
    +my $emulation_target = 'Class::Data::Inheritable';
    +
    +sub import {
    +  my $mm_class = shift;
    +  if ( scalar @_ and $_[0] =~ /^-take_namespace/ and shift) {
    +    namespace_capture(__PACKAGE__, $emulation_target);
    +  } elsif ( scalar @_ and $_[0] =~ /^-release_namespace/ and shift) {
    +    namespace_release(__PACKAGE__, $emulation_target);
    +  }
    +  # The fallback should really be to NEXT::import.
    +  $mm_class->SUPER::import( @_ );
    +}
    +
    +########################################################################
    +
    +sub mk_classdata {
    +  my $declaredclass = shift;
    +  my $attribute = shift;
    +  Class::MakeMethods::Template::ClassInherit->make( 
    +    -TargetClass => $declaredclass, 
    +    'scalar' => [ -interface => { '*'=>'get_set', '_*_accessor'=>'get_set' },
    +		  $attribute ],
    +  );
    +  if ( scalar @_ ) {
    +    $declaredclass->$attribute( @_ );
    +  }
    +}
    +
    +########################################################################
    +
    +1;
    +
    +__END__
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Emulator::Inheritable - Emulate Class::Inheritable
    +
    +
    +=head1 SYNOPSIS
    +
    +  package Stuff;
    +  use base qw(Class::MakeMethods::Emulator::Inheritable);
    +
    +  # Set up DataFile as inheritable class data.
    +  Stuff->mk_classdata('DataFile');
    +
    +  # Declare the location of the data file for this class.
    +  Stuff->DataFile('/etc/stuff/data');
    +
    +
    +=head1 DESCRIPTION
    +
    +This module is an adaptor that provides emulatation of Class::Data::Inheritable by invoking similiar functionality provided by Class::MakeMethods::ClassInherit.
    +
    +The public interface provided by Class::MakeMethods::Emulator::Inheritable is identical to that of Class::Data::Inheritable. 
    +
    +Class::Data::Inheritable is for creating accessor/mutators to class
    +data.  That is, if you want to store something about your class as a
    +whole (instead of about a single object).  This data is then inherited
    +by your subclasses and can be overriden.
    +
    +=head1 USAGE
    +
    +As specified by L, clients should inherit from this module and then invoke the mk_classdata() method for each class method desired:
    +
    +  Class->mk_classdata($data_accessor_name);
    +
    +This is a class method used to declare new class data accessors.  A
    +new accessor will be created in the Class using the name from
    +$data_accessor_name.  
    +
    +  Class->mk_classdata($data_accessor_name, $initial_value);
    +
    +You may also pass a second argument to initialize the value.
    +
    +To facilitate overriding, mk_classdata creates an alias to the
    +accessor, _field_accessor().  So Suitcase() would have an alias
    +_Suitcase_accessor() that does the exact same thing as Suitcase().
    +This is useful if you want to alter the behavior of a single accessor
    +yet still get the benefits of inheritable class data.  For example.
    +
    +  sub Suitcase {
    +      my($self) = shift;
    +      warn "Fashion tragedy" if @_ and $_[0] eq 'Plaid';
    +
    +      $self->_Suitcase_accessor(@_);
    +  }
    +
    +
    +=head1 COMPATIBILITY
    +
    +Note that the internal implementation of Class::MakeMethods::ClassInherit does not match that of Class::Data::Inheritable. In particular, Class::Data::Inheritable installs new methods in subclasses when they first initialize their value, while 
    +
    +=head1 EXAMPLE
    +
    +The example provided by L is equally applicable to this emulator.
    +
    +  package Pere::Ubu;
    +  use base qw(Class::MakeMethods::Emulator::Inheritable);
    +  Pere::Ubu->mk_classdata('Suitcase');
    +
    +will generate the method Suitcase() in the class Pere::Ubu.
    +
    +This new method can be used to get and set a piece of class data.
    +
    +  Pere::Ubu->Suitcase('Red');
    +  $suitcase = Pere::Ubu->Suitcase;
    +
    +The interesting part happens when a class inherits from Pere::Ubu:
    +
    +  package Raygun;
    +  use base qw(Pere::Ubu);
    +  
    +  # Raygun's suitcase is Red.
    +  $suitcase = Raygun->Suitcase;
    +
    +Raygun inherits its Suitcase class data from Pere::Ubu.
    +
    +Inheritance of class data works analgous to method inheritance.  As
    +long as Raygun does not "override" its inherited class data (by using
    +Suitcase() to set a new value) it will continue to use whatever is set
    +in Pere::Ubu and inherit further changes:
    +
    +  # Both Raygun's and Pere::Ubu's suitcases are now Blue
    +  Pere::Ubu->Suitcase('Blue');
    +
    +However, should Raygun decide to set its own Suitcase() it has now
    +"overridden" Pere::Ubu and is on its own, just like if it had
    +overriden a method:
    +
    +  # Raygun has an orange suitcase, Pere::Ubu's is still Blue.
    +  Raygun->Suitcase('Orange');
    +
    +Now that Raygun has overridden Pere::Ubu futher changes by Pere::Ubu
    +no longer effect Raygun.
    +
    +  # Raygun still has an orange suitcase, but Pere::Ubu is using Samsonite.
    +  Pere::Ubu->Suitcase('Samsonite');
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +See L for documentation of the original module.
    +
    +See L for a discussion of class data in Perl.
    +
    +See L and L for inheritable data methods. 
    +
    +=cut
    +
    diff --git a/lib/Class/MakeMethods/Emulator/MethodMaker.pm b/lib/Class/MakeMethods/Emulator/MethodMaker.pm
    new file mode 100644
    index 0000000..4956ba3
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Emulator/MethodMaker.pm
    @@ -0,0 +1,676 @@
    +package Class::MakeMethods::Emulator::MethodMaker;
    +
    +use Class::MakeMethods '-isasubclass';
    +require Class::MakeMethods::Emulator;
    +
    +$VERSION = 1.03;
    +
    +use strict;
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Emulator::MethodMaker - Emulate Class::MethodMaker 
    +
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Emulator::MethodMaker( 
    +    new_with_init => 'new',
    +    get_set       => [ qw / foo bar baz / ];
    +  );
    +
    +  ... OR ...
    +
    +  package MyObject;
    +  use Class::MakeMethods::Emulator::MethodMaker '-take_namespace';
    +  use Class::MethodMaker ( 
    +    new_with_init => 'new',
    +    get_set       => [ qw / foo bar baz / ];
    +  );
    +
    +
    +=head1 DESCRIPTION
    +
    +This module provides emulation of Class::MethodMaker, using the Class::MakeMethods framework.
    +
    +Although originally based on Class::MethodMaker, the calling convention
    +for Class::MakeMethods differs in a variety of ways; most notably, the names
    +given to various types of methods have been changed, and the format for
    +specifying method attributes has been standardized. This package uses
    +the aliasing capability provided by Class::MakeMethods, defining methods
    +that modify the declaration arguments as necessary and pass them off to
    +various subclasses of Class::MakeMethods.
    +
    +
    +=head1 COMPATIBILITY
    +
    +Full compatibility is maintained with version 1.03; some of the
    +changes in versions 1.04 through 1.10 are not yet included.
    +
    +The test suite from Class::MethodMaker version 1.10 is included
    +with this package, in the t/emulator_class_methodmaker/ directory. 
    +The unsupported tests have names ending in ".todo".
    +
    +The tests are unchanged from those in the Class::MethodMaker
    +distribution, except for the substitution of
    +C in the place of
    +C.
    +
    +In cases where earlier distributions of Class::MethodMaker contained
    +a different version of a test, it is also included. (Note that
    +version 0.92's get_concat returned '' for empty values, but in
    +version 0.96 this was changed to undef; this emulator follows the
    +later behavior. To avoid "use of undefined value" warnings from
    +the 0.92 version of get_concat.t, that test has been modified by
    +appending a new flag after the name, C<'get_concat --noundef'>,
    +which restores the earlier behavior.)
    +
    +
    +=head1 USAGE
    +
    +There are several ways to call this emulation module:
    +
    +=over 4
    +
    +=item *
    +
    +Direct Access
    +
    +Replace occurances in your code of C with C.
    +
    +=item *
    +
    +Install Emulation
    +
    +If you C, the Class::MethodMaker namespace will be aliased to this package, and calls to the original package will be transparently handled by this emulator.
    +
    +To remove the emulation aliasing, call C.
    +
    +B This affects B subsequent uses of Class::MethodMaker in your program, including those in other modules, and might cause unexpected effects.
    +
    +=item *
    +
    +The -sugar Option
    +
    +Passing '-sugar' as the first argument in a use or import call will cause the 'methods' package to be declared as an alias to this one.
    +
    +This allows you to write declarations in the following manner.
    +
    +  use Class::MakeMethods::Emulator::MethodMaker '-sugar';
    +
    +  make methods
    +    get_set => [ qw / foo bar baz / ],
    +    list    => [ qw / a b c / ];
    +
    +B This feature is deprecated in Class::MethodMaker version 0.96 and later. 
    +
    +=back
    +
    +=cut
    +
    +my $emulation_target = 'Class::MethodMaker';
    +
    +sub import {
    +  my $mm_class = shift;
    +  
    +  if ( scalar @_ and $_[0] =~ /^-take_namespace/ and shift ) {
    +    Class::MakeMethods::Emulator::namespace_capture(__PACKAGE__, $emulation_target);
    +  } elsif ( scalar @_ and $_[0] =~ /^-release_namespace/ and shift ) {
    +    Class::MakeMethods::Emulator::namespace_release(__PACKAGE__, $emulation_target);
    +  }
    +  
    +  if ( scalar @_ and $_[0] eq '-sugar' and shift ) {
    +    Class::MakeMethods::Emulator::namespace_capture(__PACKAGE__, "methods");
    +  }
    +  
    +  $mm_class->make( @_ ) if ( scalar @_ );
    +}
    +
    +
    +=head1 METHOD CATALOG
    +
    +B The documentation below is derived from version 1.02 of
    +Class::MethodMaker. Class::MakeMethods::Emulator::MethodMaker
    +provides support for all of the features and examples shown below,
    +with no changes required.
    +
    +
    +=head1 CONSTRUCTOR METHODS
    +
    +=head2 new
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:new --with_values'.
    +
    +=cut
    +
    +sub new 	  { return 'Template::Hash:new --with_values' }
    +
    +
    +=head2 new_with_init
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:new --with_init'.
    +
    +=cut
    +
    +sub new_with_init { return 'Template::Hash:new --with_init' }
    +
    +
    +=head2 new_hash_init
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:new --instance_with_methods'.
    +
    +=cut
    +
    +sub new_hash_init { return 'Template::Hash:new --instance_with_methods' }
    +
    +
    +=head2 new_with_args
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:new --with_values'.
    +
    +=cut
    +
    +sub new_with_args { return 'Template::Hash:new --with_values' }
    +
    +
    +=head2 copy
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:new --copy_with_values'.
    +
    +=cut
    +
    +sub copy 	  { return 'Template::Hash:new --copy_with_values' }
    +
    +
    +=head1 SCALAR ACCESSORS
    +
    +=head2 get_set
    +
    +Basically equivalent to Class::MakeMethods 'Template::Hash:scalar', except that various arguments are intercepted and converted into the parallel Class::MakeMethods::Template interface declarations.
    +
    +=cut
    +
    +my $scalar_interface = { '*'=>'get_set', 'clear_*'=>'clear' };
    +
    +sub get_set 	  { 
    +  shift and return [ 
    +    ( ( $_[0] and $_[0] eq '-static' and shift ) ? 'Template::Static:scalar' 
    +						 : 'Template::Hash:scalar' ), 
    +    '-interface' => $scalar_interface, 
    +    map { 
    +      ( ref($_) eq 'ARRAY' ) 
    +	? ( '-interface'=>{ 
    +	  ( $_->[0] ? ( $_->[0] => 'get_set' ) : () ),
    +	  ( $_->[1] ? ( $_->[1] => 'clear' ) : () ),
    +	  ( $_->[2] ? ( $_->[2] => 'get' ) : () ),
    +	  ( $_->[3] ? ( $_->[3] => 'set_return' ) : () ),
    +	} ) 
    +	: ($_ eq '-compatibility') 
    +	    ? ( '-interface', $scalar_interface ) 
    +	    : ($_ eq '-noclear') 
    +		? ( '-interface', 'default' ) 
    +		: ( /^-/ ? "-$_" : $_ ) 
    +    } @_ 
    +  ]
    +}
    +
    +
    +=head2 get_concat
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:string' with a special interface declaration that provides the get_concat and clear behaviors.
    +
    +=cut
    +
    +my $get_concat_interface = { 
    +  '*'=>'get_concat', 'clear_*'=>'clear', 
    +  '-params'=>{ 'join' => '', 'return_value_undefined' => undef() } 
    +};
    +
    +my $old_get_concat_interface = { 
    +  '*'=>'get_concat', 'clear_*'=>'clear', 
    +  '-params'=>{ 'join' => '', 'return_value_undefined' => '' } 
    +};
    +
    +sub get_concat 	  { 
    +  shift and return [ 'Template::Hash:string', '-interface', 
    +	( $_[0] eq '--noundef' ? ( shift and $old_get_concat_interface ) 
    +			       : $get_concat_interface ), @_ ]
    +}
    +
    +=head2  counter
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:number --counter'.
    +
    +=cut
    +
    +sub counter 	  { return 'Template::Hash:number --counter' }
    +
    +
    +=head1 OBJECT ACCESSORS
    +
    +Basically equivalent to Class::MakeMethods 'Template::Hash:object' with an declaration that provides the "delete_x" interface. Due to a difference in expected argument syntax, the incoming arguments are revised before being delegated to Template::Hash:object.
    +
    +=cut
    +
    +my $object_interface = { '*'=>'get_set_init', 'delete_*'=>'clear' };
    +
    +sub object 	  { 
    +  shift and return [ 
    +    'Template::Hash:object', 
    +    '-interface' => $object_interface, 
    +    _object_args(@_) 
    +  ] 
    +}
    +
    +sub _object_args {
    +  my @meta_methods;
    +  ! (@_ % 2) or Carp::croak("Odd number of arguments for object declaration");
    +  while ( scalar @_ ) {
    +    my ($class, $list) = (shift(), shift());
    +    push @meta_methods, map {
    +      (! ref $_) ? { name=> $_, class=>$class } 	
    + 	 	 : { name=> $_->{'slot'}, class=>$class, 
    +		    delegate=>( $_->{'forward'} || $_->{'comp_mthds'} ) }
    +    } ( ( ref($list) eq 'ARRAY' ) ? @$list : ($list) );
    +  }
    +  return @meta_methods;
    +}
    +
    +
    +=head2 object_list
    +
    +Basically equivalent to Class::MakeMethods 'Template::Hash:object_list' with an declaration that provides the relevant helper methods. Due to a difference in expected argument syntax, the incoming arguments are revised before being delegated to Template::Hash:object_list.
    +
    +=cut
    +
    +my $array_interface = { 
    +  '*'=>'get_push', 
    +  '*_set'=>'set_items', 'set_*'=>'set_items', 
    +  map( ('*_'.$_ => $_, $_.'_*' => $_ ), 
    +	qw( pop push unshift shift splice clear count ref index )),
    +};
    +
    +sub object_list { 
    +  shift and return [ 
    +    'Template::Hash:array_of_objects', 
    +    '-interface' => $array_interface, 
    +    _object_args(@_) 
    +  ];
    +}
    +
    +=head2 forward
    +
    +Basically equivalent to Class::MakeMethods 'Template::Universal:forward_methods'. Due to a difference in expected argument syntax, the incoming arguments are revised before being delegated to Template::Universal:forward_methods.
    +
    +  forward => [ comp => 'method1', comp2 => 'method2' ]
    +
    +Define pass-through methods for certain fields.  The above defines that
    +method C will be handled by component C, whilst method
    +C will be handled by component C.
    +
    +=cut
    +
    +sub forward {
    +  my $class = shift;
    +  my @results;
    +  while ( scalar @_ ) { 
    +    my ($comp, $method) = ( shift, shift );
    +    push @results, { name=> $method, target=> $comp };
    +  }
    +  [ 'forward_methods', @results ]
    +}
    +
    +
    +
    +=head1 REFERENCE ACCESSORS
    +
    +=head2 list
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:array' with a custom method naming interface.
    +
    +=cut
    +
    +sub list { 
    +  shift and return [ 'Template::Hash:array', '-interface' => $array_interface, @_ ];
    +}
    +
    +
    +=head2 hash
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:hash' with a custom method naming interface.
    +
    +=cut
    +
    +my $hash_interface = { 
    +  '*'=>'get_push', 
    +  '*s'=>'get_push', 
    +  'add_*'=>'get_set_items', 
    +  'add_*s'=>'get_set_items', 
    +  'clear_*'=>'delete', 
    +  'clear_*s'=>'delete', 
    +  map {'*_'.$_ => $_} qw(push set keys values exists delete tally clear),
    +};
    +
    +sub hash { 
    +  shift and return [ 'Template::Hash:hash', '-interface' => $hash_interface, @_ ];
    +}
    +
    +
    +=head2 tie_hash
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:tiedhash' with a custom method naming interface.
    +
    +=cut
    +
    +sub tie_hash { 
    +  shift and return [ 'Template::Hash:tiedhash', '-interface' => $hash_interface, @_ ];
    +}
    +
    +=head2 hash_of_lists
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:hash_of_arrays', or if the -static flag is present, to 'Template::Static:hash_of_arrays'.
    +
    +=cut
    +
    +sub hash_of_lists { 
    +  shift and return ( $_[0] and $_[0] eq '-static' and shift ) 
    +	? [ 'Template::Static:hash_of_arrays', @_ ]
    +	: [ 'Template::Hash:hash_of_arrays', @_ ]
    +}
    +
    +
    +=head1 STATIC ACCESSORS
    +
    +=head2 static_get_set
    +
    +Equivalent to Class::MakeMethods 'Template::Static:scalar' with a custom method naming interface.
    +
    +=cut
    +
    +sub static_get_set { 
    +  shift and return [ 'Template::Static:scalar', '-interface', $scalar_interface, @_ ] 
    +}
    +
    +=head2 static_list
    +
    +Equivalent to Class::MakeMethods 'Template::Static:array' with a custom method naming interface.
    +
    +=cut
    +
    +sub static_list { 
    +  shift and return [ 'Template::Static:array', '-interface' => $array_interface, @_ ];
    +}
    +
    +=head2 static_hash
    +
    +Equivalent to Class::MakeMethods 'Template::Static:hash' with a custom method naming interface.
    +
    +=cut
    +
    +sub static_hash { 
    +  shift and return [ 'Template::Static:hash', '-interface' => $hash_interface, @_ ];
    +}
    +
    +
    +=head1 GROUPED ACCESSORS
    +
    +=head2 boolean
    +
    +Equivalent to Class::MakeMethods 'Template::Static:bits' with a custom method naming interface.
    +
    +=cut
    +
    +my $bits_interface = { 
    +  '*'=>'get_set', 'set_*'=>'set_true', 'clear_*'=>'set_false',
    +  'bit_fields'=>'bit_names', 'bits'=>'bit_string', 'bit_dump'=>'bit_hash' 
    +};
    +
    +sub boolean 	  { 
    +  shift and return [ 'Template::Hash:bits', '-interface' => $bits_interface, @_ ];
    +}
    +
    +
    +=head2 grouped_fields
    +
    +Creates get/set methods like get_set but also defines a method which
    +returns a list of the slots in the group.
    +
    +  use Class::MakeMethods::Emulator::MethodMaker
    +    grouped_fields => [
    +      some_group => [ qw / field1 field2 field3 / ],
    +    ];
    +
    +Its argument list is parsed as a hash of group-name => field-list
    +pairs. Get-set methods are defined for all the fields and a method with
    +the name of the group is defined which returns the list of fields in the
    +group.
    +
    +=cut
    +
    +sub grouped_fields {
    +  my ($class, %args) = @_;
    +  my @methods;
    +  foreach (keys %args) {
    +    my @slots = @{ $args{$_} };
    +    push @methods, 
    +	$_, sub { @slots },
    +	$class->make( 'get_set', \@slots );
    +  }
    +  return @methods;
    +}
    +
    +=head2 struct
    +
    +Equivalent to Class::MakeMethods 'Template::Hash::struct'.
    +
    +B This feature is included but not documented in Class::MethodMaker version 1. 
    +
    +
    +=cut
    +
    +sub struct	  { return 'Template::Hash:struct' }
    +
    +
    +=head1 INDEXED ACCESSORS
    +
    +=head2 listed_attrib
    +
    +Equivalent to Class::MakeMethods 'Template::Flyweight:boolean_index' with a custom method naming interface.
    +
    +=cut
    +
    +sub listed_attrib   { 
    +  shift and return [ 'Template::Flyweight:boolean_index', '-interface' => { 
    +	  '*'=>'get_set', 'set_*'=>'set_true', 'clear_*'=>'set_false',
    +	  '*_objects'=>'find_true', }, @_ ]
    +}
    +
    +
    +=head2 key_attrib
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:string_index'.
    +
    +=cut
    +
    +sub key_attrib      { return 'Template::Hash:string_index' }
    +
    +=head2 key_with_create
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:string_index --find_or_new'.
    +
    +=cut
    +
    +sub key_with_create { return 'Template::Hash:string_index --find_or_new'}
    +
    +
    +=head1 CODE ACCESSORS
    +
    +=head2 code
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:code'.
    +
    +=cut
    +
    +sub code 	  { return 'Template::Hash:code' }
    +
    +
    +=head2 method
    +
    +Equivalent to Class::MakeMethods 'Template::Hash:code --method'.
    +
    +=cut
    +
    +sub method 	  { return 'Template::Hash:code --method' }
    +
    +
    +=head2 abstract
    +
    +Equivalent to Class::MakeMethods 'Template::Universal:croak --abstract'.
    +
    +=cut
    +
    +sub abstract { return 'Template::Universal:croak --abstract' }
    +
    +
    +=head1 ARRAY CONSTRUCTOR AND ACCESSORS
    +
    +=head2 builtin_class (EXPERIMENTAL)
    +
    +Equivalent to Class::MakeMethods 'Template::StructBuiltin:builtin_isa' with a modified argument order.
    +
    +=cut
    +
    +sub builtin_class { 
    +  shift and return [ 'Template::StructBuiltin:builtin_isa', 
    +			'-new_function'=>(shift), @{(shift)} ]
    +}
    +
    +=head1 CONVERSION
    +
    +If you wish to convert your code from use of the Class::MethodMaker emulator to direct use of Class::MakeMethods, you will need to adjust the arguments specified in your C or C calls.
    +
    +Often this is simply a matter of replacing the names of aliased method-types listed below with the new equivalents.
    +
    +For example, suppose that you code contained the following declaration:
    +
    +  use Class::MethodMaker ( 
    +    counter => [ 'foo' ]
    +  );
    +
    +Consulting the listings below you can find that C is an alias for C and you could thus revise your declaration to read:
    +
    +  use Class::MakeMethods ( 
    +    'Hash:number --counter' => [ 'foo' ] 
    +  );
    +
    +However, note that those methods marked "(with custom interface)" below have a different default naming convention for helper methods in Class::MakeMethods, and you will need to either supply a similar interface or alter your module's calling interface. 
    +
    +Also note that the C, C, and C method types, marked "(with modified arguments)" below, require their arguments to be specified differently. 
    +
    +See L for more information about the default interfaces of these method types.
    +
    +
    +=head2 Hash methods
    +
    +The following equivalencies are declared for old meta-method names that are now handled by the Hash implementation:
    +
    +  new 		   'Template::Hash:new --with_values'
    +  new_with_init    'Template::Hash:new --with_init'
    +  new_hash_init    'Template::Hash:new --instance_with_methods'
    +  copy	 	   'Template::Hash:copy'
    +  get_set 	   'Template::Hash:scalar' (with custom interfaces)
    +  counter 	   'Template::Hash:number --counter'
    +  get_concat 	   'Template::Hash:string --get_concat' (with custom interface)
    +  boolean 	   'Template::Hash:bits' (with custom interface)
    +  list 		   'Template::Hash:array' (with custom interface)
    +  struct           'Template::Hash:struct'
    +  hash	 	   'Template::Hash:hash' (with custom interface)
    +  tie_hash 	   'Template::Hash:tiedhash' (with custom interface)
    +  hash_of_lists    'Template::Hash:hash_of_arrays'
    +  code 		   'Template::Hash:code'
    +  method 	   'Template::Hash:code --method'
    +  object 	   'Template::Hash:object' (with custom interface and modified arguments)
    +  object_list 	   'Template::Hash:array_of_objects' (with custom interface and modified arguments)
    +  key_attrib       'Template::Hash:string_index'
    +  key_with_create  'Template::Hash:string_index --find_or_new'
    +
    +=head2 Static methods
    +
    +The following equivalencies are declared for old meta-method names
    +that are now handled by the Static implementation:
    +
    +  static_get_set   'Template::Static:scalar' (with custom interface)
    +  static_hash      'Template::Static:hash' (with custom interface)
    +
    +=head2 Flyweight method
    +
    +The following equivalency is declared for the one old meta-method name
    +that us now handled by the Flyweight implementation:
    +
    +  listed_attrib   'Template::Flyweight:boolean_index'
    +
    +=head2 Struct methods
    +
    +The following equivalencies are declared for old meta-method names
    +that are now handled by the Struct implementation:
    +
    +  builtin_class   'Template::Struct:builtin_isa'
    +
    +=head2 Universal methods
    +
    +The following equivalencies are declared for old meta-method names
    +that are now handled by the Universal implementation:
    +
    +  abstract         'Template::Universal:croak --abstract'
    +  forward          'Template::Universal:forward_methods' (with modified arguments)
    +
    +
    +=head1 EXTENDING
    +
    +In order to enable third-party subclasses of MethodMaker to run under this emulator, several aliases or stub replacements are provided for internal Class::MethodMaker methods which have been eliminated or renamed.
    +
    +=over 4
    +
    +=item *
    +
    +install_methods - now simply return the desired methods
    +
    +=item *
    +
    +find_target_class - now passed in as the target_class attribute
    +
    +=item *
    +
    +ima_method_maker - no longer supported; use target_class instead
    +
    +=back
    +
    +=cut
    +
    +sub find_target_class { (shift)->_context('TargetClass') }
    +sub get_target_class { (shift)->_context('TargetClass') }
    +sub install_methods { (shift)->_install_methods(@_) }
    +sub ima_method_maker { 1 }
    +
    +
    +=head1 BUGS
    +
    +This module aims to provide a 100% compatible drop-in replacement for Class::MethodMaker; if you detect a difference when using this emulation, please inform the author. 
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +See L for more information about the original module.
    +
    +A good introduction to Class::MethodMaker is provided by pages 222-234 of I, by Damian Conway (Manning, 1999).
    +
    +  http://www.browsebooks.com/Conway/ 
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Emulator/Singleton.pm b/lib/Class/MakeMethods/Emulator/Singleton.pm
    new file mode 100644
    index 0000000..c47ad9e
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Emulator/Singleton.pm
    @@ -0,0 +1,85 @@
    +package Class::MakeMethods::Emulator::Singleton;
    +
    +use strict;
    +require Class::MakeMethods::Emulator;
    +
    +my $emulation_target = 'Class::Singleton';
    +
    +sub import {
    +  my $mm_class = shift;
    +  if ( scalar @_ and $_[0] =~ /^-take_namespace/ and shift) {
    +    Class::MakeMethods::Emulator::namespace_capture(__PACKAGE__, $emulation_target);
    +  } elsif ( scalar @_ and $_[0] =~ /^-release_namespace/ and shift) {
    +    Class::MakeMethods::Emulator::namespace_release(__PACKAGE__, $emulation_target);
    +  }
    +  # The fallback should really be to NEXT::import.
    +  $mm_class->SUPER::import( @_ );
    +}
    +
    +########################################################################
    +
    +use Class::MakeMethods (
    +  'Template::Hash:new --with_values' => '_new_instance',
    +  'Template::ClassVar:instance --get_init' => [ 'instance', 
    +			{new_method=>'_new_instance', variable=>'_instance'} ]
    +);
    +
    +########################################################################
    +
    +1;
    +
    +__END__
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Emulator::Singleton - Emulate Class::Singleton
    +
    +
    +=head1 SYNOPSIS
    +
    +  use Class::MakeMethods::Emulator::Singleton; 
    +  
    +  # returns a new instance
    +  my $one = Class::MakeMethods::Emulator::Singleton->instance();
    +
    +  # returns same instance
    +  my $two = Class::MakeMethods::Emulator::Singleton->instance();   
    +
    +
    +=head1 COMPATIBILITY
    +
    +This module emulates the functionality of Class::Singleton, using Class::MakeMethods to generate similar methods.
    +
    +You may use it directly, as shown in the SYNOPSIS above, 
    +
    +Furthermore, you may call  C to alias the Class::Singleton namespace to this package, and subsequent calls to the original package will be transparently handled by this emulator. To remove the emulation aliasing, call C.
    +
    +B This affects B subsequent uses of Class::Singleton in your program, including those in other modules, and might cause unexpected effects.
    +
    +
    +=head1 DESCRIPTION
    +
    +A Singleton describes an object class that can have only one instance
    +in any system.  An example of a Singleton might be a print spooler
    +or system registry.  This module implements a Singleton class from
    +which other classes can be derived.  By itself, the Class::Singleton
    +module does very little other than manage the instantiation of a
    +single object.  In deriving a class from Class::Singleton, your
    +module will inherit the Singleton instantiation method and can
    +implement whatever specific functionality is required.
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +See L for documentation of the original module.
    +
    +For a description and discussion of the Singleton class, see 
    +"Design Patterns", Gamma et al, Addison-Wesley, 1995, ISBN 0-201-63361-2.
    +
    +See L and L for documentation of the created methods.
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Emulator/Struct.pm b/lib/Class/MakeMethods/Emulator/Struct.pm
    new file mode 100644
    index 0000000..4dad355
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Emulator/Struct.pm
    @@ -0,0 +1,154 @@
    +package Class::MakeMethods::Emulator::Struct;
    +
    +use strict;
    +
    +use Class::MakeMethods;
    +
    +use vars qw(@ISA @EXPORT);
    +require Exporter;
    +push @ISA, qw(Exporter);
    +@EXPORT = qw(struct);
    +
    +sub import {
    +  my $self = shift;
    +  
    +  if ( @_ == 0 ) {
    +    $self->export_to_level( 1, $self, @EXPORT );
    +  } elsif ( @_ == 1 ) {
    +    $self->export_to_level( 1, $self, @_ );
    +  } else {
    +    &struct;
    +  }
    +}
    +
    +########################################################################
    +
    +my %type_map = ( 
    +  '$' => 'scalar', 
    +  '@' => 'array', 
    +  '%' => 'hash',
    +  '_' => 'object',
    +);
    +
    +sub struct {
    +  my ($class, @decls);
    +  my $base_type = ref $_[1] ;
    +  if ( $base_type eq 'HASH' ) {
    +      $base_type = 'Standard::Hash';
    +      $class = shift;
    +      @decls = %{shift()};
    +      _usage_error() if @_;
    +  }
    +  elsif ( $base_type eq 'ARRAY' ) {
    +      $base_type = 'Standard::Array';
    +      $class = shift;
    +      @decls = @{shift()};
    +      _usage_error() if @_;
    +  }
    +  else {
    +      $base_type = 'Standard::Array';
    +      $class = (caller())[0];
    +      @decls = @_;
    +  }
    +  _usage_error() if @decls % 2 == 1;
    +  
    +  my @rewrite;
    +  while ( scalar @decls ) {
    +    my ($name, $type) = splice(@decls, 0, 2);
    +    push @rewrite, $type_map{$type} 
    +      ? ( $type_map{$type} => { 'name'=>$name, auto_init=>1 } )
    +      : ( $type_map{'_'}   => { 'name'=>$name, 'class'=>$type, auto_init=>1 } );
    +  }
    +  Class::MakeMethods->make( 
    +    -TargetClass => $class,
    +    -MakerClass => $base_type,
    +    "new" => 'new', 
    +     @rewrite
    +  );
    +}
    +
    +sub _usage_error {
    +  require Carp;
    +  Carp::confess "struct usage error";
    +}
    +
    +########################################################################
    +
    +1;
    +
    +__END__
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Emulator::Struct - Emulate Class::Struct
    +
    +
    +=head1 SYNOPSIS
    +
    +  use Class::MakeMethods::Emulator::Struct; 
    +  
    +  struct ( 
    +      simple  => '$',
    +      ordered => '@', 
    +      mapping => '%',
    +      obj_ref => 'FooObject' 
    +  );
    +
    +
    +=head1 DESCRIPTION
    +
    +This module emulates the functionality of Class::Struct by munging the provided field-declaration arguments to match those expected by Class::MakeMethods.
    +
    +It supports the same four types of accessors, the choice of array-based or hash-based objects, and the choice of installing methods in the current package or a specified target. 
    +
    +
    +=head1 EXAMPLE
    +
    +The below three declarations create equivalent methods for a simple hash-based class with a constructor and four accessors.
    +
    +  use Class::Struct;
    +  struct ( 
    +      simple  => '$',
    +      ordered => '@', 
    +      mapping => '%',
    +      obj_ref => 'FooObject' 
    +  );
    +  
    +  use Class::MakeMethods::Emulator::Struct; 
    +  struct ( 
    +      simple  => '$',
    +      ordered => '@', 
    +      mapping => '%',
    +      obj_ref => 'FooObject' 
    +    );
    +  
    +  use Class::MakeMethods ( 
    +      -MakerClass		=> 'Standard::Array',
    +      'new'			=> 'new',
    +      'scalar'			=> 'simple',
    +      'array -auto_init 1'	=> 'ordered', 
    +      'hash -auto_init 1'	=> 'mapping',
    +      'object -auto_init 1'	=> '-class FooObject obj_ref' 
    +    );
    +
    +=head1 COMPATIBILITY
    +
    +This module aims to offer a "95% compatible" drop-in replacement for the core Class::Struct module for purposes of comparison and code migration. 
    +
    +The C test for the core Class::Struct module is included with this package. The test is unchanged except for the a direct substitution of this emulator's name in the place of the core module.
    +
    +However, there are numerous internal differences between the methods generated by the original Class::Struct and this emulator, and some existing code may not work correctly without modification. 
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +See L for documentation of the original module.
    +
    +See L and L for documentation of the created methods.
    +
    +=cut
    +
    diff --git a/lib/Class/MakeMethods/Emulator/accessors.pm b/lib/Class/MakeMethods/Emulator/accessors.pm
    new file mode 100644
    index 0000000..69c3bb8
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Emulator/accessors.pm
    @@ -0,0 +1,122 @@
    +package Class::MakeMethods::Emulator::accessors;
    +
    +$VERSION = '0.02';
    +
    +use Class::MakeMethods::Emulator '-isasubclass';
    +use Class::MakeMethods::Template::Hash '-isasubclass';
    +
    +sub _emulator_target { 'accessors' }
    +sub _accessor_type { 'scalar --get_set_chain' }
    +
    +sub import {
    +  my $class = shift;
    +  
    +  $class->_handle_namespace( $class->_emulator_target, $_[0] ) and shift;
    +  
    +  foreach ( @_ ) { 
    +    die "invalid accessor - $_" unless ( /\A[a-z]\w+\z/i and 
    +					 $_ ne 'DESTROY' and $_ ne 'AUTOLOAD' )
    +  }
    +  
    +  $class->make($class->_accessor_type => [@_]);
    +}
    +
    +########################################################################
    +
    +package Class::MakeMethods::Emulator::accessors::chained;
    +@ISA = 'Class::MakeMethods::Emulator::accessors';
    +$INC{'Class/MakeMethods/Emulator/accessors/chained.pm'} = 
    +			$INC{'Class/MakeMethods/Emulator/accessors.pm'};
    +
    +sub _emulator_target { 'accessors::chained' }
    +sub _accessor_type { 'scalar --get_set_chain' }
    +
    +########################################################################
    +
    +package Class::MakeMethods::Emulator::accessors::classic;
    +@ISA = 'Class::MakeMethods::Emulator::accessors';
    +$INC{'Class/MakeMethods/Emulator/accessors/classic.pm'} = 
    +			$INC{'Class/MakeMethods/Emulator/accessors.pm'};
    +
    +sub _emulator_target { 'accessors::classic' }
    +sub _accessor_type { 'scalar' }
    +
    +########################################################################
    +
    +1;
    +
    +__END__
    +
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Emulator::accessors - Emulate the accessors module
    +
    +
    +=head1 SYNOPSIS
    +
    +  package Foo;
    +  use Class::MakeMethods::Emulator::accessors qw( foo bar baz );
    +  
    +  my $obj = bless {}, 'Foo';
    +  
    +  # generates chaining accessors:
    +  $obj->foo( 'hello ' )
    +      ->bar( 'world' )
    +      ->baz( "!\n" );
    +  
    +  print $obj->foo, $obj->bar, $obj->baz;
    +
    +This module also defines subpackages for the classic and chaining subclasses:
    +
    +  package Bar;
    +  use Class::MakeMethods::Emulator::accessors;
    +  use Class::MakeMethods::Emulator::accessors::classic qw( foo bar baz );
    +
    +  my $obj = bless {}, 'Bar';
    +
    +  # always return the current value, even on set:
    +  $obj->foo( 'hello ' ) if $obj->bar( 'world' );
    +
    +  print $obj->foo, $obj->bar, $obj->baz( "!\n" );
    +
    +
    +=head1 DESCRIPTION
    +
    +This module emulates the functionality of the accessors module, using
    +Class::MakeMethods to generate similar methods. 
    +
    +In particular, the following lines are equivalent:
    +
    +  use accessors 'foo';
    +  use Class::MakeMethods::Template::Hash 'scalar --get_set_chain' => 'foo';
    +
    +  use accessors::chained 'foo';
    +  use Class::MakeMethods::Template::Hash 'scalar --get_set_chain' => 'foo';
    +
    +  use accessors::classic 'foo';
    +  use Class::MakeMethods::Template::Hash 'scalar' => 'foo';
    +
    +You may use this module directly, as shown in the SYNOPSIS above,
    +
    +Furthermore, you may call C to alias the accessors namespace to this package,
    +and subsequent calls to the original package will be transparently
    +handled by this emulator. To remove the emulation aliasing, call
    +C. 
    +The same mechanism is also available for the classic and chained subclasses.
    +
    +B This affects B subsequent uses of the accessors module in
    +your program, including those in other modules, and might cause
    +unexpected effects.
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +See L for documentation of the original module.
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Emulator/mcoder.pm b/lib/Class/MakeMethods/Emulator/mcoder.pm
    new file mode 100644
    index 0000000..84ef034
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Emulator/mcoder.pm
    @@ -0,0 +1,116 @@
    +package Class::MakeMethods::Emulator::mcoder;
    +
    +$VERSION = '0.05';
    +
    +use Class::MakeMethods::Emulator '-isasubclass';
    +use Class::MakeMethods::Template '-isasubclass';
    +
    +########################################################################
    +
    +sub import {
    +  my $class = shift;
    +  ( my $target = $class ) =~ s/^Class::MakeMethods::Emulator:://;
    +  $class->_handle_namespace( $target, $_[0] ) and shift;
    +  $class->make( @_ ) if ( scalar @_ );
    +}
    +
    +
    +sub new        { 'Template::Hash::new --with_values' }
    +sub proxy      { 'Template::Universal:forward_methods -target' }
    +sub generic    { { '-import' => { 'Template::Hash:scalar' => '*' } } }
    +sub get        { { interface => { default => { '*'       =>'get' } } } }
    +sub set        { { interface => { default => { 'set_*'   =>'set' } } } }
    +sub undef      { { interface => { default => { 'undef_*' =>'clear' } } } }
    +sub delete     { { interface => { default => { 'delete_*'=>'hash_delete' } } } }
    +sub bool_set   { { interface => { default => { 'set_*'   =>'set_value' } },
    +		   '-import' => { 'Template::Hash:boolean' => '*' } } }
    +sub bool_unset { { interface => { default => { 'unset_*' =>'clear' } } } }
    +sub calculated { { interface => { default => { '*'       =>'get_init' } },
    +		   params    => { init_method=>'_calculate_*' } } }
    +
    +########################################################################
    +
    +foreach my $type ( qw( new get set proxy calculated ) ) {
    +  $INC{"Class/MakeMethods/Emulator/mcoder/$type.pm"} = 
    +			     $INC{"mcoder/$type.pm"} = __FILE__;
    +  *{__PACKAGE__ . "::${type}::import"} = sub {
    +    (shift) and (__PACKAGE__)->make( $type => [ @_ ] )
    +  };
    +}
    +
    +########################################################################
    +
    +1;
    +
    +__END__
    +
    +package Class::MakeMethods::Emulator::mcoder::get;
    +@ISA = 'Class::MakeMethods::Emulator::mcoder';
    +$INC{"Class/MakeMethods/Emulator/mcoder/get.pm"} = __FILE__;
    +sub import { goto &Class::MakeMethods::Emulator::mcoder::sub_import }
    +
    +package Class::MakeMethods::Emulator::mcoder::set;
    +@ISA = 'Class::MakeMethods::Emulator::mcoder';
    +$INC{"Class/MakeMethods/Emulator/mcoder/set.pm"} = __FILE__;
    +sub import { goto &Class::MakeMethods::Emulator::mcoder::sub_import }
    +
    +package Class::MakeMethods::Emulator::mcoder::proxy;
    +@ISA = 'Class::MakeMethods::Emulator::mcoder';
    +$INC{"Class/MakeMethods/Emulator/mcoder/proxy.pm"} = __FILE__;
    +sub import { goto &Class::MakeMethods::Emulator::mcoder::sub_import }
    +
    +
    +1;
    +
    +__END__
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Emulator::mcoder - Emulate the mcoder module
    +
    +
    +=head1 SYNOPSIS
    +
    +  package MyClass;
    +
    +  use Class::MakeMethods::Emulator::mcoder 
    +           [qw(get set)] => [qw(color sound height)], 
    +           proxy => [qw(runner run walk stop)], 
    +           calculated => weight;
    +
    +  sub _calculate_weight { shift->ask_weight }
    +
    +
    +=head1 DESCRIPTION
    +
    +This module emulates the functionality of the mcoder module, using
    +Class::MakeMethods to generate similar methods. 
    +
    +For example, the following lines are equivalent:
    +
    +  use mcoder 'get' => 'foo';
    +  use mcoder::get 'foo';
    +  use Class::MakeMethods::Template::Hash 'scalar --get' => 'foo';
    +
    +You may use this module directly, as shown in the SYNOPSIS above,
    +or you may call C to alias the mcoder namespace to this package,
    +and subsequent calls to the original package will be transparently
    +handled by this emulator. To remove the emulation aliasing, call
    +C.
    +The same mechanism is also available for the "sugar" subclasses.
    +
    +B This affects B subsequent uses of the mcoder module in
    +your program, including those in other modules, and might cause
    +unexpected effects.
    +
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +See L< mcoder> for documentation of the original module.
    +
    +=cut
    diff --git a/lib/Class/MakeMethods/Evaled.pm b/lib/Class/MakeMethods/Evaled.pm
    new file mode 100644
    index 0000000..233c9c6
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Evaled.pm
    @@ -0,0 +1,97 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Evaled - Make methods with simple string evals
    +
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Evaled::Hash (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +
    +
    +=head1 DESCRIPTION
    +
    +This document describes the various subclasses of Class::MakeMethods
    +included under the Evaled::* namespace, and the method types each
    +one provides.
    +
    +The Evaled subclasses generate methods using a simple string templating mechanism and basic string evals.
    +
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for more information.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. 
    +
    +Valid method-type names for this package are listed in L<"METHOD
    +GENERATOR TYPES">.
    +
    +See L and L for more information.
    +
    +=cut
    +
    +package Class::MakeMethods::Evaled;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Carp;
    +
    +use Class::MakeMethods::Standard '-isasubclass';
    +use Class::MakeMethods::Utility::TextBuilder 'text_builder';
    +
    +########################################################################
    +
    +=head2 About Evaled Methods
    +
    +
    +=cut
    +
    +sub evaled_methods {
    +  my $class = shift;
    +  my $template = shift;
    +  my $package = $Class::MakeMethods::CONTEXT{TargetClass};
    +  my @declarations = $class->_get_declarations( @_ );
    +  my @code_chunks;
    +  foreach my $method ( @declarations ) {
    +    my $code = $template;
    +    $code =~ s/__(\w+?)__/$method->{lc $1}/eg;
    +
    +    # my $code = text_builder( $template, { 
    +    #   '__NAME__' => $method->{name}, 
    +    #   '__METHOD__{}' => $method, 
    +    #   '__CONTEXT__{}' => $Class::MakeMethods::CONTEXT,
    +    # } );
    +
    +    push @code_chunks, $code;
    +  }
    +  my $code = join( "\n", "package $package;", @code_chunks, "1;" );
    +  eval $code; 
    +  $@ and Class::MakeMethods::_diagnostic('inst_eval_syntax', 'from eval', $@, $code);
    +  return;
    +}
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +For distribution, installation, support, copyright and license 
    +information, see L.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Evaled/Hash.pm b/lib/Class/MakeMethods/Evaled/Hash.pm
    new file mode 100644
    index 0000000..e306c76
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Evaled/Hash.pm
    @@ -0,0 +1,349 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Evaled::Hash - Typical hash methods
    +
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Evaled::Hash (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +  ...
    +  
    +  # Constructor
    +  my $obj = MyObject->new( foo => 'Foozle' );
    +  
    +  # Scalar Accessor
    +  print $obj->foo();
    +  
    +  $obj->bar('Barbados'); 
    +  print $obj->bar();
    +  
    +  # Array accessor
    +  $obj->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print $obj->my_list(1);
    +  
    +  # Hash accessor
    +  $obj->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print $obj->my_index('foo');
    +
    +
    +=head1 DESCRIPTION
    +
    +The Evaled::Hash subclass of MakeMethods provides a simple constructor and accessors for blessed-hash object instances.
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for a summary, or L for full details.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. Valid method-type names for this
    +package are listed in L<"METHOD GENERATOR TYPES">.
    +
    +See L for more
    +syntax information.
    +
    +
    +=cut
    +
    +package Class::MakeMethods::Evaled::Hash;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods::Evaled '-isasubclass';
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 new - Constructor
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +If called as a class method, makes a new hash and blesses it into that class.
    +
    +=item *
    +
    +If called on a hash-based instance, makes a copy of it and blesses the copy into the same class as the original instance.
    +
    +=item *
    +
    +If passed a list of key-value pairs, appends them to the new hash. These arguments override any copied values, and later arguments with the same name will override earlier ones.
    +
    +=item *
    +
    +Returns the new instance.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Evaled::Hash (
    +    new => 'new',
    +  );
    +  ...
    +  
    +  # Bare constructor
    +  my $empty = MyObject->new();
    +  
    +  # Constructor with initial values
    +  my $obj = MyObject->new( foo => 'Foozle', bar => 'Barbados' );
    +  
    +  # Copy with overriding value
    +  my $copy = $obj->new( bar => 'Bob' );
    +
    +=cut
    +
    +sub new {
    +  (shift)->evaled_methods( q{
    +    sub __NAME__ {
    +      my $callee = shift;
    +      if ( ref $callee ) {
    +	bless { %$callee, @_ }, ref $callee;
    +      } else {
    +	bless { @_ }, $callee;
    +      }
    +    }
    +  }, @_ )
    +}
    +
    +########################################################################
    +
    +=head2 scalar - Instance Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Uses the method name as a hash key to access the related value for each instance.
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Evaled::Hash (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo('Foozle');
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +sub scalar {
    +  (shift)->evaled_methods( q{
    +    sub __NAME__ {
    +      my $self = shift;
    +      if ( scalar @_ ) {
    +	$self->{'__NAME__'} = shift;
    +      } else {
    +	$self->{'__NAME__'};
    +      }
    +    }
    +  }, @_ )
    +}
    +
    +########################################################################
    +
    +=head2 array - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Uses the method name as a hash key to access the related value for each instance.
    +
    +=item * 
    +
    +The value for each instance will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current array-ref value (or undef).
    +
    +=item *
    +
    +If called with one argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef). 
    +
    +=item *
    +
    +If called with a list of index-value pairs, stores the value at the given index in the referenced array. If the instance's value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyObject;
    +  use Class::MakeMethods::Evaled::Hash (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Set values by position
    +  $obj->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  $obj->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print $obj->bar(1);
    +    
    +  # Direct access to referenced array
    +  print scalar @{ $obj->bar() };
    +  
    +  # Reset the array contents to empty
    +  @{ $obj->bar() } = ();
    +
    +=cut
    +
    +sub array {
    +  (shift)->evaled_methods( q{
    +    sub __NAME__ {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	return $self->{'__NAME__'};
    +      } elsif ( scalar(@_) == 1 ) {
    +	$self->{'__NAME__'}->[ shift() ];
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to __NAME__";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  my $key = shift();
    +	  $self->{'__NAME__'}->[ $key ] = shift();
    +	}
    +	return $self->{'__NAME__'};
    +      }
    +    }
    +  }, @_ )
    +}
    +
    +########################################################################
    +
    +=head2 hash - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Uses the method name as a hash key to access the related value for each instance.
    +
    +=item * 
    +
    +The value for each instance will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current hash-ref value (or undef).
    +
    +=item *
    +
    +If called with one argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef). 
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the instance's value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the current hash-ref value.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyObject;
    +  use Class::MakeMethods::Evaled::Hash (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  $obj->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  $obj->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print $obj->baz('foo');
    +  
    +  # Direct access to referenced hash
    +  print keys %{ $obj->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ $obj->baz() } = ();
    +
    +=cut
    +
    +sub hash {
    +  (shift)->evaled_methods( q{
    +    sub __NAME__ {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	return $self->{'__NAME__'};
    +      } elsif ( scalar(@_) == 1 ) {
    +	$self->{'__NAME__'}->{ shift() };
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to '__NAME__'";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  $self->{'__NAME__'}->{ shift() } = shift();
    +	}
    +	return $self->{'__NAME__'};
    +      }
    +    }
    +  }, @_ )
    +}
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Standard.pm b/lib/Class/MakeMethods/Standard.pm
    new file mode 100644
    index 0000000..024049e
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Standard.pm
    @@ -0,0 +1,68 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Standard - Make common object accessors
    +
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Hash (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +
    +
    +=head1 DESCRIPTION
    +
    +This document describes the various subclasses of Class::MakeMethods
    +included under the Standard::* namespace, and the method types each
    +one provides.
    +
    +The Standard subclasses provide a parameterized set of method-generation
    +implementations.
    +
    +Subroutines are generated as closures bound to a hash containing
    +the method name and (optionally) additional parameters.
    +
    +
    +=head1 USAGE AND SYNTAX
    +
    +When you C a subclass of this package, the method declarations
    +you provide as arguments cause subroutines to be generated and
    +installed in your module. You can also omit the arguments to C
    +and instead make methods at runtime by passing the declarations to
    +a subsequent call to C.
    +
    +You may include any number of declarations in each call to C
    +or C. If methods with the same name already exist, earlier
    +calls to C or C win over later ones, but within each
    +call, later declarations superceed earlier ones.
    +
    +You can install methods in a different package by passing
    +C<-target_class =E I> as your first arguments to C
    +or C.
    +
    +See L for more details.
    +
    +=cut
    +
    +package Class::MakeMethods::Standard;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods '-isasubclass';
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +For distribution, installation, support, copyright and license 
    +information, see L.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Standard/Array.pm b/lib/Class/MakeMethods/Standard/Array.pm
    new file mode 100644
    index 0000000..52c1b0b
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Standard/Array.pm
    @@ -0,0 +1,555 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Standard::Array - Methods for Array objects 
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Array (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +  ...
    +  
    +  my $obj = MyObject->new( foo => 'Foozle' );
    +  print $obj->foo();
    +  
    +  $obj->bar('Barbados');
    +  print $obj->bar();
    +  
    +  $obj->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print $obj->my_list(1);
    +  
    +  $obj->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print $obj->my_index('foo');
    +
    +=head1 DESCRIPTION
    +
    +The Standard::Array suclass of MakeMethods provides a basic
    +constructor and accessors for blessed-array object instances.
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for more information.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. 
    +
    +Valid method-type names for this package are listed in L<"METHOD
    +GENERATOR TYPES">.
    +
    +See L and L for more information.
    +
    +=cut
    +
    +package Class::MakeMethods::Standard::Array;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods::Standard '-isasubclass';
    +use Class::MakeMethods::Utility::ArraySplicer 'array_splicer';
    +
    +########################################################################
    +
    +=head2 Positional Accessors and %FIELDS
    +
    +Each accessor method is assigned the next available array index at
    +which to store its value.
    +
    +The mapping between method names and array positions is stored in
    +a hash named %FIELDS in the declaring package. When a package
    +declares its first positional accessor, its %FIELDS are initialized
    +by searching its inheritance tree.
    +
    +B: Subclassing packages that use positional accessors is
    +somewhat fragile, since you may end up with two distinct methods assigned to the same position. Specific cases to avoid are:
    +
    +=over 4
    +
    +=item *
    +
    +If you inherit from more than one class with positional accessors,
    +the positions used by the two sets of methods will overlap.
    +
    +=item *
    +
    +If your superclass adds additional positional accessors after you
    +declare your first, they will overlap yours.
    +
    +=back
    +
    +=cut
    +
    +sub _array_index {
    +  my $class = shift;
    +  my $name = shift;
    +  no strict;
    +  local $^W = 0;
    +  if ( ! scalar %{$class . "::FIELDS"} ) {
    +    my @classes = @{$class . "::ISA"};
    +    my @fields;
    +    while ( @classes ) {
    +      my $superclass = shift @classes;
    +      if ( scalar %{$superclass . "::FIELDS"} ) {
    +	push @fields, %{$superclass . "::FIELDS"};
    +      } else {
    +	unshift @classes, @{$superclass . "::ISA"}
    +      }
    +    }
    +    %{$class . "::FIELDS"} = @fields
    +  }
    +  my $field_hash = \%{$class . "::FIELDS"};
    +  $field_hash->{$name} or $field_hash->{$name} = scalar keys %$field_hash
    +}
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 new - Constructor
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Has a reference to a sample item to copy. This defaults to a reference to an empty array, but you may override this with the C<'defaults' => I> method parameter. 
    +
    +=item *
    +
    +If called as a class method, makes a new array containing values from the sample item, and blesses it into that class.
    +
    +=item *
    +
    +If called on an array-based instance, makes a copy of it and blesses the copy into the same class as the original instance.
    +
    +=item *
    +
    +If passed a list of method-value pairs, calls each named method with the associated value as an argument. 
    +
    +=item *
    +
    +Returns the new instance.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Array (
    +    new => 'new',
    +  );
    +  ...
    +  
    +  # Bare constructor
    +  my $empty = MyObject->new();
    +  
    +  # Constructor with initial sequence of method calls
    +  my $obj = MyObject->new( foo => 'Foozle', bar => 'Barbados' );
    +  
    +  # Copy with overriding sequence of method calls
    +  my $copy = $obj->new( bar => 'Bob' );
    +
    +=cut
    +
    +sub new {
    +  my $class = shift;
    +  map { 
    +    my $name = $_->{name};
    +    my $defaults = $_->{defaults} || [];
    +    $name => sub {
    +      my $callee = shift;
    +      my $self = ref($callee) ? bless( [@$callee], ref($callee) ) 
    +			      : bless( [@$defaults],   $callee );
    +      while ( scalar @_ ) {
    +	my $method = shift;
    +	$self->$method( shift );
    +      }
    +      return $self;
    +    }
    +  } $class->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 scalar - Instance Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I> method parameter, or by pre-filling the contents of %FIELDS. 
    +
    +=item *
    +
    +If called without any arguments returns the current value (or undef).
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Array (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo('Foozle');
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +sub scalar {
    +  my $class = shift;
    +  map { 
    +    my $name = $_->{name};
    +    my $index = $_->{array_index} || 
    +		_array_index( $class->_context('TargetClass'), $name );
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar @_ ) {
    +	$self->[$index] = shift;
    +      } else {
    +	$self->[$index];
    +      }
    +    }
    +  } $class->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 array - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I> method parameter, or by pre-filling the contents of %FIELDS. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current array-ref value (or undef).
    +
    +=item *
    +
    +If called with a single non-ref argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef).
    +
    +=item *
    +
    +If called with a single array ref argument, uses that list to return a slice of the referenced array.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with a non-ref index and an associated value, stores the value at the given index in the referenced array. If the instance's value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with the first item being a reference to an array of up to two numbers, loops over each pair and uses those numbers to splice the value array. 
    +
    +The first controlling number is the position at which the splice will begin. Zero will start before the first item in the list. Negative numbers count backwards from the end of the array. 
    +
    +The second number is the number of items to be removed from the list. If it is omitted, or undefined, or zero, no items are removed. If it is a positive integer, that many items will be returned.
    +
    +If both numbers are omitted, or are both undefined, they default to containing the entire value array.
    +
    +If the second argument is undef, no values will be inserted; if it is a non-reference value, that one value will be inserted; if it is an array-ref, its values will be copied.
    +
    +The method returns the items that removed from the array, if any.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Array (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Clear and set contents of list
    +  print $obj->bar([ 'Spume', 'Frost' ] );  
    +  
    +  # Set values by position
    +  $obj->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  $obj->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print $obj->bar(1);
    +  
    +  # Direct access to referenced array
    +  print scalar @{ $obj->bar() };
    +
    +There are also calling conventions for slice and splice operations:
    +
    +  # Retrieve slice of values by position
    +  print join(', ', $obj->bar( undef, [0, 2] ) );
    +  
    +  # Insert an item at position in the array
    +  $obj->bar([3], 'Potatoes' );  
    +  
    +  # Remove 1 item from position 3 in the array
    +  $obj->bar([3, 1], undef );  
    +  
    +  # Set a new value at position 2, and return the old value 
    +  print $obj->bar([2, 1], 'Froth' );
    +
    +=cut
    +
    +sub array {
    +  my $class = shift;
    +  map { 
    +    my $name = $_->{name};
    +    my $index = $_->{array_index} || 
    +		_array_index( $class->_context('TargetClass'), $name );
    +    my $init = $_->{auto_init};
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	if ( $init and ! defined $self->[$index] ) {
    +	  $self->[$index] = [];
    +	}
    +	( ! $self->[$index] ) ? () : 
    +	( wantarray            ) ? @{ $self->[$index] } :
    +				   $self->[$index]
    +      } elsif ( scalar(@_) == 1 and ref $_[0] eq 'ARRAY' ) {
    +	$self->[$index] = [ @{ $_[0] } ];
    +	( ! $self->[$index] ) ? () : 
    +	( wantarray            ) ? @{ $self->[$index] } :
    +				   $self->[$index]
    +      } else {
    +	$self->[$index] ||= [];
    +	array_splicer( $self->[$index], @_ );
    +      }
    +    }
    +  } $class->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 hash - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I> method parameter, or by pre-filling the contents of %FIELDS. 
    +
    +
    +=item * 
    +
    +The value for each instance will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the contents of the hash in list context, or a hash reference in scalar context (or undef).
    +
    +=item *
    +
    +If called with one argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef). If the single argument is an array ref, then a slice of the referenced hash is returned.
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the instance's value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the contents of the hash in list context, or a hash reference in scalar context.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Array (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  $obj->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  $obj->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print $obj->baz('foo');
    +  
    +  # Retrive slice of values by position
    +  print join(', ', $obj->baz( ['foo', 'bar'] ) );
    +  
    +  # Direct access to referenced hash
    +  print keys %{ $obj->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ $obj->baz() } = ();
    +
    +=cut
    +
    +sub hash {
    +  my $class = shift;
    +  map { 
    +    my $name = $_->{name};
    +    my $index = $_->{array_index} || 
    +		_array_index( $class->_context('TargetClass'), $name );
    +    my $init = $_->{auto_init};
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	if ( $init and ! defined $self->[$index] ) {
    +	  $self->[$index] = {};
    +	}
    +	( ! $self->[$index] ) ? () : 
    +	( wantarray            ) ? %{ $self->[$index] } :
    +				   $self->[$index]
    +      } elsif ( scalar(@_) == 1 ) {
    +	if ( ref($_[0]) eq 'HASH' ) {
    +	  my $hash = shift;
    +	  $self->[$index] = { %$hash };
    +	} elsif ( ref($_[0]) eq 'ARRAY' ) {
    +	  return @{$self->[$index]}{ @{$_[0]} }
    +	} else {
    +	  return $self->[$index]->{ $_[0] }
    +	}
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to $name";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  my $key = shift();
    +	  $self->[$index]->{ $key } = shift();
    +	}
    +	( wantarray            ) ? %{ $self->[$index] } :
    +				   $self->[$index]
    +      }
    +    }
    +  } $class->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 object - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on an array-based instance.
    +
    +=item *
    +
    +Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I> method parameter, or by pre-filling the contents of %FIELDS. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to an object (or undef).
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Hash (
    +    object => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo( Foozle->new() );
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +sub object {
    +  my $class = shift;
    +  map { 
    +    my $name = $_->{name};
    +    my $index = $_->{array_index} || 
    +		_array_index( $class->_context('TargetClass'), $name );
    +    my $class = $_->{class};
    +    my $init = $_->{auto_init};
    +    if ( $init and ! $class ) { 
    +      Carp::croak("Use of auto_init requires value for class parameter") 
    +    }
    +    my $new_method = $_->{new_method} || 'new';
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar @_ ) {
    +	my $value = shift;
    +	if ( $class and ! UNIVERSAL::isa( $value, $class ) ) {
    +	  Carp::croak "Wrong argument type ('$value') in assigment to $name";
    +	}
    +	$self->[$index] = $value;
    +      } else {
    +	if ( $init and ! defined $self->[$index] ) {
    +	  $self->[$index] = $class->$new_method();
    +	} else {
    +	  $self->[$index];
    +	}
    +      }
    +    }
    +  } $class->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +See L for equivalent functionality
    +based on blessed hashes. If your module will be extensively
    +subclassed, consider switching to Standard::Hash to avoid the
    +subclassing concerns described above.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Standard/Global.pm b/lib/Class/MakeMethods/Standard/Global.pm
    new file mode 100644
    index 0000000..9c1e48d
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Standard/Global.pm
    @@ -0,0 +1,405 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Standard::Global - Global data
    +
    +=head1 SYNOPSIS
    +
    +  package MyClass;
    +  use Class::MakeMethods::Standard::Global (
    +    scalar => [ 'foo' ],
    +    array  => [ 'my_list' ],
    +    hash   => [ 'my_index' ],
    +  );
    +  ...
    +  
    +  MyClass->foo( 'Foozle' );
    +  print MyClass->foo();
    +
    +  print MyClass->new(...)->foo(); # same value for any instance
    +  print MySubclass->foo();        # ... and for any subclass
    +  
    +  MyClass->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print MyClass->my_list(1);
    +  
    +  MyClass->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print MyClass->my_index('foo');
    +
    +
    +=head1 DESCRIPTION
    +
    +The Standard::Global suclass of MakeMethods provides basic accessors for shared data.
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for more information.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. 
    +
    +Valid method-type names for this package are listed in L<"METHOD
    +GENERATOR TYPES">.
    +
    +See L and L for more information.
    +
    +=cut
    +
    +package Class::MakeMethods::Standard::Global;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods::Standard '-isasubclass';
    +use Class::MakeMethods::Utility::ArraySplicer 'array_splicer';
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 scalar - Global Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, and behaves identically regardless of what it was called on.
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Standard::Global (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  MyClass->foo('Foozle');
    +  
    +  # Retrieve value
    +  print MyClass->foo;
    +
    +=cut
    +
    +sub scalar {
    +  map { 
    +    my $name = $_->{name};
    +    my $data;
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	$data;
    +      } else {
    +	$data = shift;
    +      }
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 array - Global Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, and behaves identically regardless of what it was called on.
    +
    +=item * 
    +
    +The global value will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the current array-ref value (or undef).
    +
    +
    +=item *
    +
    +If called with a single non-ref argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef).
    +
    +=item *
    +
    +If called with a single array ref argument, uses that list to return a slice of the referenced array.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with a non-ref index and an associated value, stores the value at the given index in the referenced array. If the global value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with the first item being a reference to an array of up to two numbers, loops over each pair and uses those numbers to splice the value array. 
    +
    +The first controlling number is the position at which the splice will begin. Zero will start before the first item in the list. Negative numbers count backwards from the end of the array. 
    +
    +The second number is the number of items to be removed from the list. If it is omitted, or undefined, or zero, no items are removed. If it is a positive integer, that many items will be returned.
    +
    +If both numbers are omitted, or are both undefined, they default to containing the entire value array.
    +
    +If the second argument is undef, no values will be inserted; if it is a non-reference value, that one value will be inserted; if it is an array-ref, its values will be copied.
    +
    +The method returns the items that removed from the array, if any.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyClass;
    +  use Class::MakeMethods::Standard::Global (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Clear and set contents of list
    +  print MyClass->bar([ 'Spume', 'Frost' ] );  
    +  
    +  # Set values by position
    +  MyClass->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  MyClass->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print MyClass->bar(1);
    +  
    +  # Direct access to referenced array
    +  print scalar @{ MyClass->bar() };
    +
    +There are also calling conventions for slice and splice operations:
    +
    +  # Retrieve slice of values by position
    +  print join(', ', MyClass->bar( undef, [0, 2] ) );
    +  
    +  # Insert an item at position in the array
    +  MyClass->bar([3], 'Potatoes' );  
    +  
    +  # Remove 1 item from position 3 in the array
    +  MyClass->bar([3, 1], undef );  
    +  
    +  # Set a new value at position 2, and return the old value 
    +  print MyClass->bar([2, 1], 'Froth' );
    +
    +=cut
    +
    +sub array {
    +  map { 
    +    my $name = $_->{name};
    +    my $data;
    +    my $init = $_->{auto_init};
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	if ( $init and ! defined $data ) {
    +	  $data = [];
    +	}
    +	! $data ? () : wantarray ? @$data : $data;
    +      } elsif ( scalar(@_) == 1 and ref $_[0] eq 'ARRAY' ) {
    +	$data = [ @{ $_[0] } ];
    +	wantarray ? @$data : $data;
    +      } else {
    +	$data ||= [];
    +	return array_splicer( $data, @_ );
    +      }
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 hash - Global Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, and behaves identically regardless of what it was called on.
    +
    +=item * 
    +
    +The global value will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the contents of the hash in list context, or a hash reference in scalar context (or undef).
    +
    +=item *
    +
    +If called with one non-ref argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef).
    +
    +=item *
    +
    +If called with one array-ref argument, uses the contents of that array to retrieve a slice of the referenced hash.
    +
    +=item *
    +
    +If called with one hash-ref argument, sets the contents of the referenced hash to match that provided.
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the global value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the contents of the hash in list context, or a hash reference in scalar context.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Standard::Global (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  MyClass->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  MyClass->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print MyClass->baz('foo');
    +  
    +  # Retrive slice of values by position
    +  print join(', ', MyClass->baz( ['foo', 'bar'] ) );
    +  
    +  # Direct access to referenced hash
    +  print keys %{ MyClass->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ MyClass->baz() } = ();
    +
    +=cut
    +
    +sub hash {
    +  map { 
    +    my $name = $_->{name};
    +    my $data;
    +    my $init = $_->{auto_init};
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	if ( $init and ! defined $data ) {
    +	  $data = {};
    +	}
    +	! $data ? () : wantarray  ? %$data : $data
    +      } elsif ( scalar(@_) == 1 ) {
    +	if ( ref($_[0]) eq 'HASH' ) {
    +	  my $hash = shift;
    +	  $data = { %$hash };
    +	} elsif ( ref($_[0]) eq 'ARRAY' ) {
    +	  return @{$data}{ @{$_[0]} }
    +	} else {
    +	  return $data->{ $_[0] }
    +	}
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to $name";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  my $key = shift();
    +	  $data->{ $key } = shift();
    +	}
    +	wantarray ? %$data : $data;
    +      }
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 object - Global Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, and behaves identically regardless of what it was called on.
    +
    +=item * 
    +
    +The global value will be a reference to an object (or undef).
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Standard::Global (
    +    object => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  MyClass->foo( Foozle->new() );
    +  
    +  # Retrieve value
    +  print MyClass->foo;
    +
    +=cut
    +
    +sub object {
    +  map { 
    +    my $name = $_->{name};
    +    my $data;
    +    my $class = $_->{class};
    +    my $init = $_->{auto_init};
    +    if ( $init and ! $class ) { 
    +      Carp::croak("Use of auto_init requires value for class parameter") 
    +    }
    +    my $new_method = $_->{new_method} || 'new';
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar @_ ) {
    +	my $value = shift;
    +	if ( $class and ! UNIVERSAL::isa( $value, $class ) ) {
    +	  Carp::croak "Wrong argument type ('$value') in assigment to $name";
    +	}
    +	$data = $value;
    +      } else {
    +	if ( $init and ! defined $data ) {
    +	  $data = $class->$new_method();
    +	}
    +	$data;
    +      }
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Standard/Hash.pm b/lib/Class/MakeMethods/Standard/Hash.pm
    new file mode 100644
    index 0000000..ba4f65b
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Standard/Hash.pm
    @@ -0,0 +1,501 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Standard::Hash - Standard hash methods
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Hash (
    +    new => 'new',
    +    scalar => [ 'foo', 'bar' ],
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +  ...
    +  
    +  my $obj = MyObject->new( foo => 'Foozle' );
    +  print $obj->foo();
    +  
    +  $obj->bar('Barbados'); 
    +  print $obj->bar();
    +  
    +  $obj->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print $obj->my_list(1);
    +  
    +  $obj->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print $obj->my_index('foo');
    +
    +=head1 DESCRIPTION
    +
    +The Standard::Hash suclass of MakeMethods provides a basic constructor and accessors for blessed-hash object instances.
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for more information.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. 
    +
    +Valid method-type names for this package are listed in L<"METHOD
    +GENERATOR TYPES">.
    +
    +See L and L for more information.
    +
    +=cut
    +
    +package Class::MakeMethods::Standard::Hash;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Class::MakeMethods::Standard '-isasubclass';
    +use Class::MakeMethods::Utility::ArraySplicer 'array_splicer';
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 new - Constructor
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Has a reference to a sample item to copy. This defaults to a reference to an empty hash, but you may override this with the C<'defaults' => I>  method parameter. 
    +
    +=item *
    +
    +If called as a class method, makes a new hash and blesses it into that class.
    +
    +=item *
    +
    +If called on a hash-based instance, makes a copy of it and blesses the copy into the same class as the original instance.
    +
    +=item *
    +
    +If passed a list of key-value pairs, appends them to the new hash. These arguments override any copied values, and later arguments with the same name will override earlier ones.
    +
    +=item *
    +
    +Returns the new instance.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Hash (
    +    new => 'new',
    +  );
    +  ...
    +  
    +  # Bare constructor
    +  my $empty = MyObject->new();
    +  
    +  # Constructor with initial values
    +  my $obj = MyObject->new( foo => 'Foozle', bar => 'Barbados' );
    +  
    +  # Copy with overriding value
    +  my $copy = $obj->new( bar => 'Bob' );
    +
    +=cut
    +
    +sub new {
    +  map { 
    +    my $name = $_->{name};
    +    my $defaults = $_->{defaults} || {};
    +    $name => sub {
    +      my $callee = shift;
    +      my $self = ref($callee) ? bless( { %$callee }, ref $callee ) 
    +			      : bless( { %$defaults },   $callee );
    +      while ( scalar @_ ) {
    +	my $method = shift;
    +	UNIVERSAL::can( $self, $method ) 
    +	  or Carp::croak("Can't call method '$method' in constructor for " . ( ref($callee) || $callee ));
    +	$self->$method( shift );
    +      }
    +      return $self;
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 scalar - Instance Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Has a specific hash key to use to access the related value for each instance.
    +This defaults to the method name, but you may override this with the C<'hash_key' => I> method parameter. 
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Hash (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo('Foozle');
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +sub scalar {
    +  map { 
    +    my $name = $_->{name};
    +    my $hash_key = $_->{hash_key} || $_->{name};
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	$self->{$hash_key};
    +      } else {
    +	$self->{$hash_key} = shift;
    +      }
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 array - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Has a specific hash key to use to access the related value for each instance.
    +This defaults to the method name, but you may override this with the C<'hash_key' => I> method parameter. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the contents of the array in list context, or an array reference in scalar context (or undef).
    +
    +=item *
    +
    +If called with a single array ref argument, sets the contents of the array to match the contents of the provided one.
    +
    +=item *
    +
    +If called with a single numeric argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef).
    +
    +=item *
    +
    +If called with a two arguments, the first undefined and the second an array ref argument, uses that array's contents as a list of indexes to return a slice of the referenced array.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with a numeric index and an associated value, stores the value at the given index in the referenced array. If the instance's value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with the first item being a reference to an array of up to two numbers, loops over each pair and uses those numbers to splice the value array. 
    +
    +The first controlling number is the position at which the splice will begin. Zero will start before the first item in the list. Negative numbers count backwards from the end of the array. 
    +
    +The second number is the number of items to be removed from the list. If it is omitted, or undefined, or zero, no items are removed. If it is a positive integer, that many items will be returned.
    +
    +If both numbers are omitted, or are both undefined, they default to containing the entire value array.
    +
    +If the second argument is undef, no values will be inserted; if it is a non-reference value, that one value will be inserted; if it is an array-ref, its values will be copied.
    +
    +The method returns the items that removed from the array, if any.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Hash (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Clear and set contents of list
    +  print $obj->bar([ 'Spume', 'Frost' ] );  
    +  
    +  # Set values by position
    +  $obj->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  $obj->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print $obj->bar(1);
    +  
    +  # Direct access to referenced array
    +  print scalar @{ $obj->bar() };
    +
    +There are also calling conventions for slice and splice operations:
    +
    +  # Retrieve slice of values by position
    +  print join(', ', $obj->bar( undef, [0, 2] ) );
    +  
    +  # Insert an item at position in the array
    +  $obj->bar([3], 'Potatoes' );  
    +  
    +  # Remove 1 item from position 3 in the array
    +  $obj->bar([3, 1], undef );  
    +  
    +  # Set a new value at position 2, and return the old value 
    +  print $obj->bar([2, 1], 'Froth' );
    +
    +=cut
    +
    +sub array {
    +  map { 
    +    my $name = $_->{name};
    +    my $hash_key = $_->{hash_key} || $_->{name};
    +    my $init = $_->{auto_init};
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	if ( $init and ! defined $self->{$hash_key} ) {
    +	  $self->{$hash_key} = [];
    +	}
    +	( ! $self->{$hash_key} ) ? () : 
    +	( wantarray            ) ? @{ $self->{$hash_key} } :
    +				   $self->{$hash_key}
    +      } elsif ( scalar(@_) == 1 and ref $_[0] eq 'ARRAY' ) {
    +	$self->{$hash_key} = [ @{ $_[0] } ];
    +	( ! $self->{$hash_key} ) ? () : 
    +	( wantarray            ) ? @{ $self->{$hash_key} } :
    +				   $self->{$hash_key}
    +      } else {
    +	$self->{$hash_key} ||= [];
    +	return array_splicer( $self->{$hash_key}, @_ );
    +      }
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 hash - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Has a specific hash key to use to access the related value for each instance.
    +This defaults to the method name, but you may override this with the C<'hash_key' => I> method parameter. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the contents of the hash in list context, or a hash reference in scalar context (or undef).
    +
    +=item *
    +
    +If called with one non-ref argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef).
    +
    +=item *
    +
    +If called with one array-ref argument, uses the contents of that array to retrieve a slice of the referenced hash.
    +
    +=item *
    +
    +If called with one hash-ref argument, sets the contents of the referenced hash to match that provided.
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the instance's value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the contents of the hash in list context, or a hash reference in scalar context.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Hash (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  $obj->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  $obj->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print $obj->baz('foo');
    +  
    +  # Retrive slice of values by position
    +  print join(', ', $obj->baz( ['foo', 'bar'] ) );
    +  
    +  # Direct access to referenced hash
    +  print keys %{ $obj->baz() };
    +  
    +  # Reset the hash contents to empty
    +  %{ $obj->baz() } = ();
    +
    +=cut
    +
    +sub hash {
    +  map { 
    +    my $name = $_->{name};
    +    my $hash_key = $_->{hash_key} || $_->{name};
    +    my $init = $_->{auto_init};
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	if ( $init and ! defined $self->{$hash_key} ) {
    +	  $self->{$hash_key} = {};
    +	}
    +	( ! $self->{$hash_key} ) ? () : 
    +	( wantarray            ) ? %{ $self->{$hash_key} } :
    +				   $self->{$hash_key}
    +      } elsif ( scalar(@_) == 1 ) {
    +	if ( ref($_[0]) eq 'HASH' ) {
    +	  $self->{$hash_key} = { %{$_[0]} };
    +	} elsif ( ref($_[0]) eq 'ARRAY' ) {
    +	  return @{$self->{$hash_key}}{ @{$_[0]} }
    +	} else {
    +	  return $self->{$hash_key}->{ $_[0] }
    +	}
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to $name";
    +      } else {
    +	while ( scalar(@_) ) {
    +	  my $key = shift();
    +	  $self->{$hash_key}->{ $key } = shift();
    +	}
    +	return $self->{$hash_key};
    +      }
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 object - Instance Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Must be called on a hash-based instance.
    +
    +=item *
    +
    +Has a specific hash key to use to access the related value for each instance.
    +This defaults to the method name, but you may override this with the C<'hash_key' => I> method parameter. 
    +
    +=item * 
    +
    +The value for each instance will be a reference to an object (or undef).
    +
    +=item *
    +
    +If called without any arguments returns the current value.
    +
    +=item *
    +
    +If called with an argument, stores that as the value, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Hash (
    +    object => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  $obj->foo( Foozle->new() );
    +  
    +  # Retrieve value
    +  print $obj->foo;
    +
    +=cut
    +
    +sub object {
    +  map { 
    +    my $name = $_->{name};
    +    my $hash_key = $_->{hash_key} || $_->{name};
    +    my $class = $_->{class};
    +    my $init = $_->{auto_init};
    +    if ( $init and ! $class ) { 
    +      Carp::croak("Use of auto_init requires value for class parameter") 
    +    }
    +    my $new_method = $_->{new_method} || 'new';
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar @_ ) {
    +	my $value = shift;
    +	if ( $class and ! UNIVERSAL::isa( $value, $class ) ) {
    +	  Carp::croak "Wrong argument type ('$value') in assigment to $name";
    +	}
    +	$self->{$hash_key} = $value;
    +      } else {
    +	if ( $init and ! defined $self->{$hash_key} ) {
    +	  $self->{$hash_key} = $class->$new_method();
    +	}
    +	$self->{$hash_key};
    +      }
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Standard/Inheritable.pm b/lib/Class/MakeMethods/Standard/Inheritable.pm
    new file mode 100644
    index 0000000..d1b72ac
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Standard/Inheritable.pm
    @@ -0,0 +1,428 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Standard::Inheritable - Overridable data
    +
    +=head1 SYNOPSIS
    +
    +  package MyClass;
    +
    +  use Class::MakeMethods( 'Standard::Inheritable:scalar' => 'foo' );
    +  # We now have an accessor method for an "inheritable" scalar value
    +  
    +  MyClass->foo( 'Foozle' );   # Set a class-wide value
    +  print MyClass->foo();	      # Retrieve class-wide value
    +  
    +  my $obj = MyClass->new(...);
    +  print $obj->foo();          # All instances "inherit" that value...
    +  
    +  $obj->foo( 'Foible' );      # until you set a value for an instance.
    +  print $obj->foo();          # This now finds object-specific value.
    +  ...
    +  
    +  package MySubClass;
    +  @ISA = 'MyClass';
    +  
    +  print MySubClass->foo();    # Intially same as superclass,
    +  MySubClass->foo('Foobar');  # but overridable per subclass,
    +  print $subclass_obj->foo(); # and shared by its instances
    +  $subclass_obj->foo('Fosil');# until you override them... 
    +  ...
    +  
    +  # Similar behaviour for hashes and arrays is currently incomplete
    +  package MyClass;
    +  use Class::MakeMethods::Standard::Inheritable (
    +    array => 'my_list',
    +    hash => 'my_index',
    +  );
    +  
    +  MyClass->my_list(0 => 'Foozle', 1 => 'Bang!');
    +  print MyClass->my_list(1);
    +  
    +  MyClass->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  print MyClass->my_index('foo');
    +
    +
    +=head1 DESCRIPTION
    +
    +The MakeMethods subclass provides accessor methods that search an inheritance tree to find a value. This allows you to set a shared or default value for a given class, optionally override it in a subclass, and then optionally override it on a per-instance basis. 
    +
    +Note that all MakeMethods methods are inheritable, in the sense that they work as expected for subclasses. These methods are different in that the I accessed by each method can be inherited or overridden in each subclass or instance. See L< Class::MakeMethods::Utility::Inheritable> for more about this type of "inheritable" or overridable" data.
    +
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for more information.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. 
    +
    +Valid method-type names for this package are listed in L<"METHOD
    +GENERATOR TYPES">.
    +
    +See L and L for more information.
    +
    +=cut
    +
    +package Class::MakeMethods::Standard::Inheritable;
    +
    +$VERSION = 1.000;
    +use strict;
    +
    +use Class::MakeMethods::Standard '-isasubclass';
    +use Class::MakeMethods::Utility::Inheritable qw(get_vvalue set_vvalue find_vself);
    +use Class::MakeMethods::Utility::ArraySplicer 'array_splicer';
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 scalar - Class-specific Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class or instance method, on the declaring class or any subclass. 
    +
    +=item *
    +
    +If called without any arguments returns the current value for the callee. If the callee has not had a value defined for this method, searches up from instance to class, and from class to superclass, until a callee with a value is located.
    +
    +=item *
    +
    +If called with an argument, stores that as the value associated with the callee, whether instance or class, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Standard::Inheritable (
    +    scalar => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  MyClass->foo('Foozle');
    +  
    +  # Retrieve value
    +  print MyClass->foo;
    +
    +=cut
    +
    +sub scalar {
    +  my $class = shift;
    +  map { 
    +    my $method = $_;
    +    my $name = $method->{name};
    +    $method->{data} ||= {};
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	get_vvalue($method->{data}, $self);
    +      } else {
    +	my $value = shift;
    +	set_vvalue($method->{data}, $self, $value);
    +      }
    +    }
    +  } $class->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 array - Class-specific Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, Must be called on a hash-based instance.
    +
    +=item * 
    +
    +The class value will be a reference to an array (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the contents of the array in list context, or an array reference in scalar context (or undef).
    +
    +=item *
    +
    +If called with a single array ref argument, sets the contents of the array to match the contents of the provided one.
    +
    +=item *
    +
    +If called with a single numeric argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef).
    +
    +=item *
    +
    +If called with a two arguments, the first undefined and the second an array ref argument, uses that array's contents as a list of indexes to return a slice of the referenced array.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with a non-ref index and an associated value, stores the value at the given index in the referenced array. If the class value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
    +
    +=item *
    +
    +If called with a list of argument pairs, each with the first item being a reference to an array of up to two numbers, loops over each pair and uses those numbers to splice the value array. 
    +
    +The first controlling number is the position at which the splice will begin. Zero will start before the first item in the list. Negative numbers count backwards from the end of the array. 
    +
    +The second number is the number of items to be removed from the list. If it is omitted, or undefined, or zero, no items are removed. If it is a positive integer, that many items will be returned.
    +
    +If both numbers are omitted, or are both undefined, they default to containing the entire value array.
    +
    +If the second argument is undef, no values will be inserted; if it is a non-reference value, that one value will be inserted; if it is an array-ref, its values will be copied.
    +
    +The method returns the items that removed from the array, if any.
    +
    +=back
    +
    +Sample declaration and usage:
    +  
    +  package MyClass;
    +  use Class::MakeMethods::Standard::Inheritable (
    +    array => 'bar',
    +  );
    +  ...
    +  
    +  # Clear and set contents of list
    +  print MyClass->bar([ 'Spume', 'Frost' ] );  
    +  
    +  # Set values by position
    +  MyClass->bar(0 => 'Foozle', 1 => 'Bang!');
    +  
    +  # Positions may be overwritten, and in any order
    +  MyClass->bar(2 => 'And Mash', 1 => 'Blah!');
    +  
    +  # Retrieve value by position
    +  print MyClass->bar(1);
    +  
    +  # Direct access to referenced array
    +  print scalar @{ MyClass->bar() };
    +
    +There are also calling conventions for slice and splice operations:
    +
    +  # Retrieve slice of values by position
    +  print join(', ', MyClass->bar( undef, [0, 2] ) );
    +  
    +  # Insert an item at position in the array
    +  MyClass->bar([3], 'Potatoes' );  
    +  
    +  # Remove 1 item from position 3 in the array
    +  MyClass->bar([3, 1], undef );  
    +  
    +  # Set a new value at position 2, and return the old value 
    +  print MyClass->bar([2, 1], 'Froth' );
    +
    +=cut
    +
    +sub array {
    +  my $class = shift;
    +  map { 
    +    my $method = $_;
    +    my $name = $method->{name};
    +    $name => sub {
    +      my $self = shift;
    +
    +     if ( scalar(@_) == 0 ) {
    +	my $v_self = find_vself($method->{data}, $self);
    +	my $value = $v_self ? $method->{data}{$v_self} : ();
    +	if ( $method->{auto_init} and ! $value ) {
    +	  $value = $method->{data}{$self} = [];
    +	}
    +	! $value ? () : wantarray ? @$value : $value;
    +	
    +      } elsif ( scalar(@_) == 1 and ref $_[0] eq 'ARRAY' ) {
    +	$method->{data}{$self} = [ @{ $_[0] } ];
    +	wantarray ? @{ $method->{data}{$self} } : $method->{data}{$self}
    +	
    +      } else {
    +	if ( ! exists $method->{data}{$self} ) {
    +	  my $v_self = find_vself($method->{data}, $self);
    +	  $method->{data}{$self} = [ $v_self ? @$v_self : () ];
    +	}
    +	return array_splicer( $method->{data}{$self}, @_ );
    +      }
    +    } 
    +  } $class->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 hash - Class-specific Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, Must be called on a hash-based instance.
    +
    +=item * 
    +
    +The class value will be a reference to a hash (or undef).
    +
    +=item *
    +
    +If called without any arguments, returns the contents of the hash in list context, or a hash reference in scalar context. If the callee has not had a value defined for this method, searches up from instance to class, and from class to superclass, until a callee with a value is located.
    +
    +=item *
    +
    +If called with one non-ref argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef). If the callee has not had a value defined for this method, searches up from instance to class, and from class to superclass, until a callee with a value is located.
    +
    +=item *
    +
    +If called with one array-ref argument, uses the contents of that array to retrieve a slice of the referenced hash. If the callee has not had a value defined for this method, searches up from instance to class, and from class to superclass, until a callee with a value is located.
    +
    +=item *
    +
    +If called with one hash-ref argument, sets the contents of the referenced hash to match that provided.
    +
    +=item *
    +
    +If called with a list of key-value pairs, stores the value under the given key in the hash associated with the callee, whether instance or class. If the callee did not previously have a hash-ref value associated with it, searches up instance to class, and from class to superclass, until a callee with a value is located, and copies that hash before making the assignments. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the contents of the hash in list context, or a hash reference in scalar context.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Standard::Inheritable (
    +    hash => 'baz',
    +  );
    +  ...
    +  
    +  # Set values by key
    +  MyClass->baz('foo' => 'Foozle', 'bar' => 'Bang!');
    +  
    +  # Values may be overwritten, and in any order
    +  MyClass->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
    +  
    +  # Retrieve value by key
    +  print MyClass->baz('foo');
    +  
    +  # Retrive slice of values by position
    +  print join(', ', MyClass->baz( ['foo', 'bar'] ) );
    +  
    +  # Direct access to referenced hash
    +  print keys %{ MyClass->baz() };
    +  
    +  # Reset the hash contents to empty
    +  @{ MyClass->baz() } = ();
    +
    +B 
    +
    +=cut
    +
    +sub hash {
    +  my $class = shift;
    +  map { 
    +    my $method = $_;
    +    my $name = $method->{name};
    +    $name => sub {
    +      my $self = shift;
    +      if ( scalar(@_) == 0 ) {
    +	my $v_self = find_vself($method->{data}, $self);
    +	my $value = $v_self ? $method->{data}{$v_self} : ();
    +	if ( $method->{auto_init} and ! $value ) {
    +	  $value = $method->{data}{$self} = {};
    +	}
    +	! $value ? () : wantarray ? %$value : $value;
    +      } elsif ( scalar(@_) == 1 ) {
    +	if ( ref($_[0]) eq 'HASH' ) {
    +	  $method->{data}{$self} = { %{$_[0]} };
    +	} elsif ( ref($_[0]) eq 'ARRAY' ) {
    +	  my $v_self = find_vself($method->{data}, $self);
    +	  return unless $v_self;
    +	  return @{$method->{data}{$v_self}}{ @{$_[0]} } 
    +	} else {
    +	  my $v_self = find_vself($method->{data}, $self);
    +	  return unless $v_self;
    +	  return $method->{data}{$v_self}->{ $_[0] };
    +	}
    +      } elsif ( scalar(@_) % 2 ) {
    +	Carp::croak "Odd number of items in assigment to $method->{name}";
    +      } else {
    +	if ( ! exists $method->{data}{$self} ) {
    +	  my $v_self = find_vself($method->{data}, $self);
    +	  $method->{data}{$self} = { $v_self ? %$v_self : () };
    +	}
    +	while ( scalar(@_) ) {
    +	  my $key = shift();
    +	  $method->{data}{$self}->{ $key } = shift();
    +	}
    +	wantarray ? %{ $method->{data}{$self} } : $method->{data}{$self};
    +      }
    +    } 
    +  } $class->_get_declarations(@_)
    +} 
    +
    +########################################################################
    +
    +=head2 object - Class-specific Ref Accessor
    +
    +For each method name passed, uses a closure to generate a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +May be called as a class method, or on any instance or subclass, Must be called on a hash-based instance.
    +
    +=item * 
    +
    +The class value will be a reference to an object (or undef).
    +
    +=item *
    +
    +If called without any arguments returns the current value for the callee. If the callee has not had a value defined for this method, searches up from instance to class, and from class to superclass, until a callee with a value is located.
    +
    +=item *
    +
    +If called with an argument, stores that as the value associated with the callee, whether instance or class, and returns it, 
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyClass;
    +  use Class::MakeMethods::Standard::Inheritable (
    +    object => 'foo',
    +  );
    +  ...
    +  
    +  # Store value
    +  MyClass->foo( Foozle->new() );
    +  
    +  # Retrieve value
    +  print MyClass->foo;
    +
    +B 
    +
    +=cut
    +
    +sub object { }
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Standard/Universal.pm b/lib/Class/MakeMethods/Standard/Universal.pm
    new file mode 100644
    index 0000000..641b159
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Standard/Universal.pm
    @@ -0,0 +1,336 @@
    +=head1 NAME
    +
    +Class::MakeMethods::Standard::Universal - Generic Methods
    +
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Universal (
    +    no_op => 'this',
    +    abstract => 'that',
    +    delegate => { name=>'play_music', target=>'instrument', method=>'play' },
    +  );
    +
    +
    +=head1 DESCRIPTION
    +
    +The Standard::Universal suclass of MakeMethods provides a [INCOMPLETE].
    +
    +=head2 Calling Conventions
    +
    +When you C this package, the method names you provide
    +as arguments cause subroutines to be generated and installed in
    +your module.
    +
    +See L for more information.
    +
    +=head2 Declaration Syntax
    +
    +To declare methods, pass in pairs of a method-type name followed
    +by one or more method names. 
    +
    +Valid method-type names for this package are listed in L<"METHOD
    +GENERATOR TYPES">.
    +
    +See L and L for more information.
    +
    +=cut
    +
    +package Class::MakeMethods::Standard::Universal;
    +
    +$VERSION = 1.000;
    +use strict;
    +use Carp;
    +use Class::MakeMethods::Standard '-isasubclass';
    +
    +########################################################################
    +
    +=head1 METHOD GENERATOR TYPES
    +
    +=head2 no_op - Placeholder
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Does nothing.
    +
    +=back
    +
    +You might want to create and use such methods to provide hooks for
    +subclass activity.
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Universal (
    +    no_op => 'whatever',
    +  );
    +  ...
    +  
    +  # Doesn't do anything
    +  MyObject->whatever();
    +
    +=cut
    +
    +sub no_op {
    +  map { 
    +    my $method = $_;
    +    $method->{name} => sub { }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 abstract - Placeholder
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Fails with an error message.
    +
    +=back
    +
    +This is intended to support the use of abstract methods, that must
    +be overidden in a useful subclass.
    +
    +If each subclass is expected to provide an implementation of a given method, using this abstract method will replace the generic error message below with the clearer, more explicit error message that follows it:
    +
    +  Can't locate object method "foo" via package "My::Subclass"
    +  The "foo" method is abstract and can not be called on My::Subclass
    +
    +However, note that the existence of this method will be detected by UNIVERSAL::can(), so it is not suitable for use in optional interfaces, for which you may wish to be able to detect whether the method is supported or not.
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Universal (
    +    abstract => 'whatever',
    +  );
    +  ...
    +  
    +  package MySubclass;
    +  sub whatever { ... }
    +  
    +  # Failure
    +  MyObject->whatever();
    +  
    +  # Success
    +  MySubclass->whatever();
    +
    +=cut
    +
    +sub abstract {
    +  map { 
    +    my $method = $_;
    +    $method->{name} => sub { 
    +      my $self = shift;
    +      my $class = ref($self) ? "a " . ref($self) . " object" : $self;
    +      croak("The $method->{name} method is abstract and can not be called on $class");
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 call_methods - Call methods by name
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Accepts a hash of key-value pairs, or a reference to hash of such pairs. For each pair, the key is interpreted as the name of a method to call, and the value is the argument to be passed to that method.
    +
    +=back
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Universal (
    +    call_methods => 'init',
    +  );
    +  ...
    +  
    +  my $object = MyObject->new()
    +  $object->init( foo => 'Foozle', bar => 'Barbados' );
    +  
    +  # Equivalent to:
    +  $object->foo('Foozle');
    +  $object->bar('Barbados');
    +
    +=cut
    +
    +sub call_methods {
    +  map { 
    +    my $method = $_;
    +    $method->{name} => sub { 
    +      my $self = shift;
    +      local @_ = %{$_[0]} if ( scalar @_ == 1 and ref($_[0]) eq 'HASH');
    +      while (scalar @_) { 
    +	my $key = shift;
    +	$self->$key( shift ) 
    +      }
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +
    +########################################################################
    +
    +=head2 join_methods - Concatenate results of other methods
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Has a list of other methods names as an arrayref in the 'methods' parameter. B.
    +
    +=item *
    +
    +When called, calls each of the named method on itself, in order, and returns the concatenation of their results.
    +
    +=item *
    +
    +If a 'join' parameter is provided it is included between each method result.
    +
    +=item *
    +
    +If the 'skip_blanks' parameter is omitted, or is provided with a true value, removes all undefined or empty-string values from the results.
    +
    +=back
    +
    +=cut
    +
    +sub join_methods {
    +  map { 
    +    my $method = $_;
    +    $method->{methods} or confess;
    +    $method->{join} = '' if ( ! defined $method->{join} );
    +    $method->{skip_blanks} = '1' if ( ! defined $method->{skip_blanks} );
    +    $method->{name} => sub { 
    +      my $self = shift;
    +      my $joiner = $method->{join};
    +      my @values =  map { $self->$_() } @{ $method->{methods} };
    +      @values = grep { defined and length } @values if ( $method->{skip_blanks} );
    +      join $joiner, @values;
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 alias - Call another method
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Calls another method on the same callee.
    +
    +=back
    +
    +You might create such a method to extend or adapt your class' interface.
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Universal (
    +    alias => { name=>'click_here', target=>'complex_machinery' }
    +  );
    +  sub complex_machinery { ... }
    +  ...
    +  
    +  $myobj->click_here(...); # calls $myobj->complex_machinery(...)
    +
    +=cut
    +
    +sub alias {
    +  map { 
    +    my $method = $_;
    +    $method->{name} => sub { 
    +      my $self = shift;
    +      
    +      my $t_method = $method->{target} or confess("no target");
    +      my @t_args = $method->{target_args} ? @{$method->{target_args}} : ();
    +      
    +      $self->$t_method(@t_args, @_);
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head2 delegate - Use another object to provide method
    +
    +For each method name passed, returns a subroutine with the following characteristics:
    +
    +=over 4
    +
    +=item *
    +
    +Calls a method on self to retrieve another object, and then calls a method on that object and returns its value.
    +
    +=back
    +
    +You might want to create and use such methods to faciliate composition of objects from smaller objects.
    +
    +Sample declaration and usage:
    +
    +  package MyObject;
    +  use Class::MakeMethods::Standard::Universal (
    +    'Standard::Hash:object' => { name=>'instrument' },
    +    delegate => { name=>'play_music', target=>'instrument', method=>'play' }
    +  );
    +  ...
    +  
    +  my $object = MyObject->new();
    +  $object->instrument( MyInstrument->new );
    +  $object->play_music;
    +
    +=cut
    +
    +sub delegate {
    +  map { 
    +    my $method = $_;
    +    $method->{method} ||= $method->{name};
    +    $method->{name} => sub { 
    +      my $self = shift;
    +      
    +      my $t_method = $method->{target} or confess("no target");
    +      my @t_args = $method->{target_args} ? @{$method->{target_args}} : ();
    +      
    +      my $m_method = $method->{method} or confess("no method");
    +      my @m_args = $method->{method_args} ? @{$method->{method_args}} : ();
    +      push @m_args, $self if ( $method->{target_args_self} );
    +      
    +      my $obj = $self->$t_method( @t_args )
    +	or croak("Can't delegate $method->{name} because $t_method is empty");
    +      
    +      $obj->$m_method(@m_args, @_);
    +    }
    +  } (shift)->_get_declarations(@_)
    +}
    +
    +########################################################################
    +
    +=head1 SEE ALSO
    +
    +See L for general information about this distribution. 
    +
    +See L for more about this family of subclasses.
    +
    +=cut
    +
    +1;
    diff --git a/lib/Class/MakeMethods/Template.pm b/lib/Class/MakeMethods/Template.pm
    new file mode 100644
    index 0000000..d5cd8f5
    --- /dev/null
    +++ b/lib/Class/MakeMethods/Template.pm
    @@ -0,0 +1,1255 @@
    +package Class::MakeMethods::Template;
    +
    +use strict;
    +use Carp;
    +
    +use Class::MakeMethods '-isasubclass';
    +
    +use vars qw( $VERSION );
    +$VERSION = 1.008;
    +
    +sub _diagnostic { &Class::MakeMethods::_diagnostic }
    +
    +########################################################################
    +### TEMPLATE LOOKUP AND CACHING: named_method(), _definition()
    +########################################################################
    +
    +use vars qw( %TemplateCache );
    +
    +# @results = $class->named_method( $name, @arguments );
    +sub named_method {
    +  my $class = shift;
    +  my $name = shift;
    +  
    +  # Support direct access to cached Template information
    +  if (exists $TemplateCache{"$class\::$name"}) {
    +    return $TemplateCache{"$class\::$name"};
    +  }
    +  
    +  my @results = $class->$name( @_ );
    +  
    +  if ( scalar @results == 1 and ref $results[0] eq 'HASH' ) {
    +    # If this is a hash-definition format, cache the results for speed.
    +    my $def = $results[0];
    +    $TemplateCache{"$class\::$name"} = $def;
    +    _expand_definition($class, $name, $def);
    +    return $def;
    +  }
    +  
    +  return wantarray ? @results : $results[0];
    +}
    +
    +# $mm_def = _definition( $class, $target );
    +sub _definition {
    +  my ($class, $target) = @_;
    +  
    +  while ( ! ref $target ) {
    +    $target =~ s/\s.*//;
    +    
    +    # If method name contains a colon or double colon, call the method on the
    +    # indicated class.
    +    my $call_class = ( ( $target =~ s/^(.*)\:{1,2}// ) 
    +      ? Class::MakeMethods::_find_subclass($class, $1) : $class );
    +    $target = $call_class->named_method( $target );
    +  }
    +  _diagnostic('mmdef_not_interpretable', $target) 
    +	unless ( ref($target) eq 'HASH' or ref($target) eq __PACKAGE__ );
    +  
    +  return $target;
    +}
    +
    +########################################################################
    +### TEMPLATE INTERNALS: _expand_definition()
    +########################################################################
    +
    +sub _expand_definition {
    +  my ($class, $name, $mm_def) = @_;
    +  
    +  return $mm_def if $mm_def->{'-parsed'};
    +  
    +  $mm_def->{'template_class'} = $class;
    +  $mm_def->{'template_name'} = $name;
    +  
    +  # Allow definitions to import values from each other.
    +  my $importer;
    +  foreach $importer ( qw( interface params behavior code_expr modifier ) ) {
    +    my $rules = $mm_def->{$importer}->{'-import'} || $mm_def->{'-import'};
    +    my @rules = ( ref $rules eq 'HASH' ? %$rules : ref $rules eq 'ARRAY' ? @$rules : () );
    +    unshift @rules, '::' . $class . ':generic' => '*' if $class->can('generic');
    +    while ( 
    +      my ($source, $names) = splice @rules, 0, 2
    +    ) {
    +      my $mmi = _definition($class, $source);
    +      foreach ( ( $names eq '*' ) ? keys %{ $mmi->{$importer} } 
    +			: ( ref $names ) ? @{ $names } : ( $names ) ) {
    +	my $current = $mm_def->{$importer}{$_};
    +	my $import = $mmi->{$importer}{$_};
    +	if ( ! $current ) {
    +	  $mm_def->{$importer}{$_} = $import;
    +	} elsif ( ref($current) eq 'ARRAY' ) {
    +	  my @imports = ref($import) ? @$import : $import;
    +	  foreach my $imp ( @imports ) {
    +	    push @$current, $imp unless ( grep { $_ eq $imp } @$current );
    +	  }
    +	}
    +      }
    +    }
    +    delete $mm_def->{$importer}->{'-import'};
    +  }
    +  delete $mm_def->{'-import'};
    +  
    +  _describe_definition( $mm_def ) if $Class::MakeMethods::CONTEXT{Debug};
    +
    +  
    +  $mm_def->{'-parsed'} = "$_[1]";
    +  
    +  bless $mm_def, __PACKAGE__;
    +}
    +
    +sub _describe_definition {
    +  my $mm_def = shift;
    +  
    +  my $def_type = "$mm_def->{template_class}:$mm_def->{template_name}";
    +  warn "----\nMethods info for $def_type:\n";
    +  if ( $mm_def->{interface} ) {
    +    warn join '', "Templates: \n", map {
    +	"  $_: " . _describe_value($mm_def->{interface}{$_}) . "\n"
    +      } keys %{$mm_def->{interface}};
    +  }
    +  if ( $mm_def->{modifier} ) {
    +    warn join '', "Modifiers: \n", map {
    +	"  $_: " . _describe_value($mm_def->{modifier}{$_}) . "\n"
    +      } keys %{$mm_def->{modifier}};
    +  }
    +}
    +
    +sub _describe_value {
    +  my $value = $_[0];
    +  ref($value) eq 'ARRAY' ? join(', ', @$value) :
    +  ref($value) eq 'HASH'  ? join(', ', %$value) : 
    +				      "$value";
    +}
    +
    +########################################################################
    +### METHOD GENERATION: make_methods()
    +########################################################################
    +
    +sub make_methods {
    +  my $mm_def = shift;
    +  
    +  return unless ( scalar @_ );
    +  
    +  # Select default interface and initial method parameters
    +  my $defaults = { %{ ( $mm_def->{'params'} ||= {} ) } };
    +  $defaults->{'interface'} ||= $mm_def->{'interface'}{'-default'} || 'default';
    +  $defaults->{'target_class'} = $mm_def->_context('TargetClass');
    +  $defaults->{'template_class'} = $mm_def->{'template_class'};
    +  $defaults->{'template_name'} = $mm_def->{'template_name'};
    +  
    +  my %interface_cache;
    +  
    +  # Our return value is the accumulated list of method-name => method-sub pairs
    +  my @methods; 
    +
    +  while (scalar @_) {
    +
    +    ### PARSING ### Requires: $mm_def, $defaults, @_
    +    
    +    my $m_name = shift @_;
    +    _diagnostic('make_empty') unless ( defined $m_name and length $m_name );
    +    
    +    # Normalize: If we've got an array of names, replace it with those names 
    +    if ( ref $m_name eq 'ARRAY' ) {
    +      my @items = @{ $m_name };
    +      # If array is followed by a params hash, each one gets the same params
    +      if ( scalar @_ and ref $_[0] eq 'HASH' and ! exists $_[0]->{'name'} ) {
    +	my $params = shift;
    +	@items = map { $_, $params } @items
    +      }
    +      unshift @_, @items;
    +      next;
    +    }
    +    
    +    # Parse interfaces, modifiers and parameters
    +    if ( $m_name =~ s/^-// ) {
    +      if (  $m_name !~ s/^-// ) {
    +	# -param => value
    +	$defaults->{$m_name} = shift @_; 
    +      } else {
    +	if ( $m_name eq '' ) {
    +	  # '--' => { param => value ... }
    +	  %$defaults = ( %$defaults, %{ shift @_ } );
    +		
    +	} elsif ( exists $mm_def->{'interface'}{$m_name} ) {
    +	  # --interface
    +	  $defaults->{'interface'} = $m_name;
    +	
    +	} elsif ( exists $mm_def->{'modifier'}{$m_name} ) {
    +	  # --modifier
    +	  $defaults->{'modifier'} .= 
    +			    ( $defaults->{'modifier'} ? ' ' : '' ) . "-$m_name";
    +	
    +	} elsif ( exists $mm_def->{'behavior'}{$m_name} ) {
    +	  # --behavior as shortcut for single-method interface
    +	  $defaults->{'interface'} = $m_name;
    +	
    +	} else {
    +	  _diagnostic('make_bad_modifier', $mm_def->{'name'}, "--$m_name");
    +	}
    +      }
    +      next;
    +    }
    +    
    +    # Make a new meta-method hash
    +    my $m_info;
    +    
    +    # Parse string, string-then-hash, and hash-only meta-method parameters
    +    if ( ! ref $m_name ) {
    +      if ( scalar @_ and ref $_[0] eq 'HASH' and ! exists $_[0]->{'name'} ) {
    +	%$m_info = ( 'name' => $m_name, %{ shift @_ } );
    +      } else {
    +	$m_info = { 'name' => $m_name };
    +      }
    +    
    +    } elsif ( ref $m_name eq 'HASH' ) {
    +      unless ( exists $m_name->{'name'} and length $m_name->{'name'} ) {
    +	_diagnostic('make_noname');
    +      }
    +      $m_info = { %$m_name };
    +    
    +    } else {
    +      _diagnostic('make_unsupported', $m_name);
    +    }
    +    _diagnostic('debug_declaration', join(', ', map { defined $_ ? $_ : '(undef)' } %$m_info) );
    +
    +    ### INITIALIZATION ### Requires: $mm_def, $defaults, $m_info
    +    
    +    my $interface = (
    +      $interface_cache{ $m_info->{'interface'} || $defaults->{'interface'} } 
    +	||= _interpret_interface( $mm_def, $m_info->{'interface'} || $defaults->{'interface'} )
    +    );
    +    %$m_info = ( 
    +      %$defaults, 
    +      ( $interface->{-params} ? %{$interface->{-params}} : () ),
    +      %$m_info 
    +    );
    +
    +    
    +    # warn "Actual: " . Dumper( $m_info );
    +
    +
    +    # Expand * and *{...} strings.
    +    foreach (grep defined $m_info->{$_}, keys %$m_info) {
    +      $m_info->{$_} =~ s/\*(?:\{([^\}]+)?\})?/ $m_info->{ $1 || 'name' } /ge
    +    }
    +    if ( $m_info->{'modifier'} and $mm_def->{modifier}{-folding} ) {
    +      $m_info->{'modifier'} = _fold_modifiers( $m_info->{'modifier'}, 
    +			$mm_def->{modifier}{-folding} )
    +    }
    +    
    +    ### METHOD GENERATION ### Requires: $mm_def, $interface, $m_info
    +    
    +    # If the MM def provides an initialization "-init" call, run it.
    +    if ( local $_ = $mm_def->{'behavior'}->{'-init'} ) {
    +      push @methods, map $_->( $m_info ), (ref($_) eq 'ARRAY') ? @$_ : $_;
    +    }
    +    # Build Methods
    +    for ( grep { /^[^-]/ } keys %$interface ) { 
    +      my $function_name = $_;
    +      $function_name =~ s/\*/$m_info->{'name'}/g;
    +      
    +      my $behavior = $interface->{$_};
    +      
    +      # Fold in additional modifiers
    +      if ( $m_info->{'modifier'} ) { 
    +	if ( $behavior =~ /^\-/ and $mm_def->{modifier}{-folding} ) {
    +	  $behavior = $m_info->{'modifier'} = 
    +			_fold_modifiers( "$m_info->{'modifier'} $behavior", 
    +			    $mm_def->{modifier}{-folding} )
    +	} else {
    +	  $behavior = "$m_info->{'modifier'} $behavior";
    +	}
    +      }
    +
    +      my $builder = 
    +	( $mm_def->{'-behavior_cache'}{$behavior} ) ? 
    +	$mm_def->{'-behavior_cache'}{$behavior} : 
    +	( ref($mm_def->{'behavior'}{$behavior}) eq 'CODE' ) ? 
    +	$mm_def->{'behavior'}{$behavior} : 
    +_behavior_builder( $mm_def, $behavior, $m_info );
    +      
    +      my $method = &$builder( $m_info );
    +      
    +      _diagnostic('debug_make_behave', $behavior, $function_name, $method);
    +      push @methods, ($function_name => $method) if ($method);
    +    }
    +    
    +    # If the MM def provides a "-subs" call, for forwarding and other
    +    # miscelaneous "subsidiary" or "contained" methods, run it.
    +    if ( my $subs = $mm_def->{'behavior'}->{'-subs'} ) {
    +      my @subs = (ref($subs) eq 'ARRAY') ? @$subs : $subs;
    +      foreach my $sub ( @subs ) {
    +	my @results = $sub->($m_info);
    +	if ( scalar @results == 1 and ref($results[0]) eq 'HASH' ) {
    +	  # If it returns a hash of helper method types, check the method info
    +	  # for any matching names and call the corresponding method generator.
    +	  my $types = shift @results;
    +	  foreach my $type ( keys %$types ) {
    +	    my $names = $m_info->{$type} or next; 
    +	    my @names = ref($names) eq 'ARRAY' ? @$names : split(' ', $names);
    +	    my $generator = $types->{$type};
    +	    push @results, map { $_ => &$generator($m_info, $_) } @names;
    +	  }	
    +	}
    +	push @methods, @results;
    +      }
    +    }
    +    
    +    # If the MM def provides a "-register" call, for registering meta-method
    +    # information for run-time access, run it.
    +    if ( local $_ = $mm_def->{'behavior'}->{'-register'} ) {
    +      push @methods, map $_->( $m_info ), (ref($_) eq 'ARRAY') ? @$_ : $_;
    +    }
    +  }
    +  
    +  return @methods;
    +}
    +
    +# I'd like for the make_methods() sub to be simpler, and to take advantage
    +# of the standard _get_declarations parsing provided by the superclass.
    +# Sadly the below doesn't work, due to a few order-of-operations peculiarities 
    +# of parsing interfaces and modifiers, and their associated default paramters.
    +# Perhaps it might work if the processing of --options could be overridden with
    +# a callback sub, so that interfaces and their params can be parsed in order.
    +sub _x_get_declarations {	
    +  my $mm_def = shift;
    +
    +  my @declarations = $mm_def::SUPER->_get_declarations( @_ );
    +
    +  # use Data::Dumper;
    +  # warn "In: " . Dumper( \@_ );
    +  # warn "Auto: " . Dumper( \@declarations );
    +
    +  my %interface_cache;
    +
    +  while (scalar @declarations) {
    +    
    +    my $m_info = shift @declarations;
    +
    +    # Parse interfaces and modifiers
    +    my @specials = grep $_, split '--', ( delete $m_info->{'--'} || '' );
    +    foreach my $special ( @specials ) {
    +      if ( exists $mm_def->{'interface'}{$special} ) {
    +	# --interface
    +	$m_info->{'interface'} = $special;
    +      
    +      } elsif ( exists $mm_def->{'modifier'}{$special} ) {
    +	# --modifier
    +	$m_info->{'modifier'} .= 
    +			  ( $m_info->{'modifier'} ? ' ' : '' ) . "-$special";
    +      
    +      } elsif ( exists $mm_def->{'behavior'}{$special} ) {
    +	# --behavior as shortcut for single-method interface
    +	$m_info->{'interface'} = $special;
    +      
    +      } else {
    +	_diagnostic('make_bad_modifier', $mm_def->{'name'}, "--$special");
    +      }
    +    }
    +
    +    my $interface = (
    +	$interface_cache{ $m_info->{'interface'} } 
    +	  ||= _interpret_interface( $mm_def, $m_info->{'interface'} )
    +    );
    +    $m_info = { %$m_info, %{$interface->{-params}} } if $interface->{-params};
    +
    +    _diagnostic('debug_declaration', join(', ', map { defined $_ ? $_ : '(undef)' } %$m_info) );
    +    
    +    # warn "Updated: " . Dumper( $m_info );
    +  }
    +}
    +
    +########################################################################
    +### TEMPLATES: _interpret_interface()
    +########################################################################
    +
    +sub _interpret_interface {
    +  my ($mm_def, $interface) = @_;
    +  
    +  if ( ref $interface eq 'HASH' ) { 
    +    return $interface if exists $interface->{'-parsed'};
    +  } 
    +  elsif ( ! defined $interface or ! length $interface ) { 
    +    _diagnostic('tmpl_empty');
    +
    +  } 
    +  elsif ( ! ref $interface ) {
    +    if ( exists $mm_def->{'interface'}{ $interface } ) {
    +      if ( ! ref $mm_def->{'interface'}{ $interface } ) { 
    +	$mm_def->{'interface'}{ $interface } = 
    +				{ '*' => $mm_def->{'interface'}{ $interface } };
    +      }
    +    } elsif ( exists $mm_def->{'behavior'}{ $interface } ) {
    +      $mm_def->{'interface'}{ $interface } = { '*' => $interface };
    +    } else {
    +      _diagnostic('tmpl_unkown', $interface);
    +    }
    +    $interface = $mm_def->{'interface'}{ $interface };
    +    
    +    return $interface if exists $interface->{'-parsed'};
    +  }
    +  elsif ( ref $interface ne 'HASH' ) {
    +    _diagnostic('tmpl_unsupported', $interface);
    +  } 
    +  
    +  $interface->{'-parsed'} = "$_[1]";
    +  
    +  # Allow interface inheritance via -base specification
    +  if ( $interface->{'-base'} ) {
    +    for ( split ' ', $interface->{'-base'} ) {
    +      my $base = _interpret_interface( $mm_def, $_ );
    +      %$interface = ( %$base, %$interface );
    +    }
    +    delete $interface->{'-base'};
    +  }
    +  
    +  for (keys %$interface) {
    +    # Remove empty/undefined items.
    +    unless ( defined $interface->{$_} and length $interface->{$_} ) {
    +      delete $interface->{$_};
    +      next;
    +    }
    +  }
    +  # _diagnostic('debug_interface', $_[1], join(', ', %$interface ));
    +  
    +  return $interface;
    +}
    +
    +########################################################################
    +### BEHAVIORS AND MODIFIERS: _fold_modifiers(), _behavior_builder()
    +########################################################################
    +
    +sub _fold_modifiers {
    +  my $spec = shift;
    +  my $rules = shift;
    +  my %rules = @$rules;
    +  
    +  # Longest first, to prevent over-eager matching.
    +  my $rule = join '|', map "\Q$_\E", 
    +	sort { length($b) <=> length($a) } keys %rules;
    +  # Match repeatedly from the front.
    +  1 while ( $spec =~ s/($rule)/$rules{$1}/ );
    +  $spec =~ s/(^|\s)\s/$1/g;
    +  return $spec;
    +}
    +
    +sub _behavior_builder {
    +  my ( $mm_def, $behavior, $m_info ) = @_;
    +  
    +  # We're going to have to do some extra work here, so we'll cache the result
    +  my $builder;
    +  
    +  # Separate the modifiers
    +  my $core_behavior = $behavior;
    +  my @modifiers;
    +  while ( $core_behavior =~ s/\-(\w+)\s// ) { push @modifiers, $1 }
    +  
    +  # Find either the built-in or universal behavior template
    +  if ( $mm_def->{'behavior'}{$core_behavior} ) {
    +    $builder = $mm_def->{'behavior'}{$core_behavior};
    +  } else {
    +    my $universal = _definition('Class::MakeMethods::Template::Universal','generic');
    +    $builder = $universal->{'behavior'}{$core_behavior} 
    +  }
    +  
    +  # Otherwise we're hosed.
    +  $builder or _diagnostic('make_bad_behavior', $m_info->{'name'}, $behavior);
    +  
    +  if ( ! ref $builder ) {
    +    # If we've got a text template, pass it off for interpretation.
    +    my $code = ( ! $Class::MakeMethods::Utility::DiskCache::DiskCacheDir ) ?
    +      _interpret_text_builder($mm_def, $core_behavior, $builder, @modifiers) 
    +    : _disk_cache_builder($mm_def, $core_behavior, $builder, @modifiers);
    +    
    +    # _diagnostic('debug_eval_builder', $name, $code);
    +    local $^W unless $Class::MakeMethods::CONTEXT{Debug};
    +    $builder = eval $code;
    +    if ( $@ ) { _diagnostic('behavior_eval', $@, $code) }
    +    unless (ref $builder eq 'CODE') { _diagnostic('behavior_eval', $@, $code) }
    +  
    +  } elsif ( scalar @modifiers ) {
    +    # Can't modify code subs
    +    _diagnostic('make_behavior_mod', join(', ', @modifiers), $core_behavior);
    +  }
    +  
    +  $mm_def->{'-behavior_cache'}{$behavior} = $builder;
    +
    +  return $builder;
    +}
    +
    +########################################################################
    +### CODE EXPRESSIONS: _interpret_text_builder(), _disk_cache_builder()
    +########################################################################
    +
    +sub _interpret_text_builder {
    +  require Class::MakeMethods::Utility::TextBuilder;
    +  
    +  my ( $mm_def, $name, $code, @modifiers ) = @_;
    +  
    +  foreach ( @modifiers ) {
    +    exists $mm_def->{'modifier'}{$_} 
    +      or _diagnostic('behavior_mod_unknown', $name, $_);
    +  }
    +  
    +  my @exprs = grep { $_ } map { 
    +	$mm_def->{'modifier'}{ $_ }, 
    +	$mm_def->{'modifier'}{ "$_ $name" } || $mm_def->{'modifier'}{ "$_ *" }
    +      } ( '-all', ( scalar(@modifiers) ? @modifiers : '-default' ) );
    +  
    +  # Generic method template
    +  push @exprs, "return sub _SUB_ATTRIBS_ { \n  my \$self = shift;\n  * }";
    +  
    +  # Closure-generator
    +  push @exprs, "sub { my \$m_info = \$_[0]; * }";
    +  
    +  my $exprs = $mm_def->{code_expr};
    +  unshift @exprs, { 
    +	( map { $_=>$exprs->{$_} } grep /^[^-]/, keys %$exprs ),
    +	'_BEHAVIOR_{}' => $mm_def->{'behavior'},
    +	'_SUB_ATTRIBS_' => '',
    +  };
    +  
    +  my $result = Class::MakeMethods::Utility::TextBuilder::text_builder($code,
    +								       @exprs);
    +  
    +  my $modifier_string = join(' ', map "-$_", @modifiers);
    +  my $full_name = "$name ($mm_def->{template_class} $mm_def->{template_name}" .
    +		    ( $modifier_string ? " $modifier_string" : '' ) . ")";
    +  
    +  _diagnostic('debug_template_builder', $full_name, $code, $result);
    +  
    +  return $result;
    +}
    +
    +sub _disk_cache_builder { 
    +  require Class::MakeMethods::Utility::DiskCache;
    +  my ( $mm_def, $core_behavior, $builder, @modifiers ) = @_;
    +  
    +  Class::MakeMethods::Utility::DiskCache::disk_cache( 
    +    "$mm_def->{template_class}::$mm_def->{template_name}", 
    +    join('.', $core_behavior, @modifiers),
    +    \&_interpret_text_builder, ($mm_def, $core_behavior, $builder, @modifiers)
    +  );
    +}
    +
    +1;
    +
    +__END__
    +
    +
    +=head1 NAME
    +
    +Class::MakeMethods::Template - Extensible code templates 
    +
    +
    +=head1 SYNOPSIS
    +
    +  package MyObject;
    +  use Class::MakeMethods::Template::Hash (
    +    'new'       => 'new',
    +    'string'    => 'foo',
    +    'number'    => 'bar',
    +  );
    +   
    +  my $obj = MyObject->new( foo => "Foozle", bar => 23 );
    +  print $obj->foo();
    +  $obj->bar(42);
    +
    +
    +=head1 MOTIVATION
    +
    +If you compare the source code of some of the closure-generating
    +methods provided by other subclasses of Class::MakeMethods,
    +such as the C accessors provided by the various Standard::*
    +subclasses, you will notice a fair amount of duplication. This
    +module provides a way of assembling common pieces of code to
    +facilitate support the maintenance of much larger libraries of
    +generated methods.
    +
    +
    +=head1 DESCRIPTION
    +
    +This module extends the Class::MakeMethods framework by providing
    +an abstract superclass for extensible code-templating method
    +generators.
    +
    +Common types of methods are generalized into B