{
    "mode": "perldoc",
    "parameter": "HTML::Mason::FAQ",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/HTML%3A%3AMason%3A%3AFAQ/json",
    "generated": "2026-06-12T23:08:09Z",
    "sections": {
        "NAME": {
            "content": "HTML::Mason::FAQ - Frequently asked questions\n\nAUTOHANDLERS, METHODS, ATTRIBUTES, INHERITANCE\nCan I set a page's inheritance dynamically at request time (e.g. based on URL arguments)?\nNo. Inheritance is a fixed property of a component, determined once when the component is\nloaded. Dynamic inheritance is on the todo list.\n\nHow can I tell Mason to use autohandlers or dhandlers when calling one component from another component (i.e. internal redirect)?\nUsually this situation arises when a top-level component makes a run-time decision to use a\nsecond component as the \"real\" page, and calls it via <& &> or $m->comp.\n\nAutohandlers and dhandlers are only triggered for the top-level component of a request. In 1.1,\nyou can use an Apache internal redirect or a Mason subrequest ($m->subexec) to solve the\nproblem.\n\nI added a simple autohandler to a directory and now my pages don't appear.\nMake sure to include a call to $m->callnext somewhere in the autohandler.\n\nWhere does a dhandler inherit from? Can I change it to inherit based on the URL path?\nA dhandler's inheritance is determined by its location in the hierarchy, not by the URL that\ninvoked it.\n\nConsider a site with the following components:\n\n/autohandler\n/dhandler\n/products/autohandler\n\nand suppose a request comes in for /products/index.html. /dhandler will handle the request but\nwill still inherit from /autohandler.\n\nThis is not always the desired behavior, but there is no easy way to change it. If you want\n/products/* requests to use /products/autohandler, you'll need to create /products/dhandler as\nwell.\n\nCan I change the value of an attribute dynamically, based on the request?\nNo, attributes are static. The closest thing to a dynamic attribute is a method. If you've been\nusing an attribute widely and don't want to change it to a method everywhere, consider using an\nattribute/method combination. Suppose your attribute is called 'bgcolor'. Create a default\nmethod called 'bgcolor' in the autohandler:\n\n<%method bgcolor>\n<%init>\nreturn $m->basecomp->attr('bgcolor');\n<%init>\n</%method>\n\nThen replace every other\n\n$m->basecomp->attr('bgcolor');\n\nwith\n\n$m->basecomp->callmethod('bgcolor')\n\nor\n\n<& SELF:bgcolor &>\n\nNow you can leave the attribute definitions alone, but define a method if and when you need a\ndynamically computed value.\n",
            "subsections": [
                {
                    "name": "When using multiple component roots and autohandlers, does every autohandler in every root get called, and in what or",
                    "content": "Mason will try each autohandler path in turn, e.g.\n\n/foo/bar/baz/autohandler\n/foo/bar/autohandler\n/foo/autohandler\n/autohandler\n\nFor each path, it will search all of the component roots, and only run the *first* autohandler\nfound. Some of the autohandlers might come from one root and some from another. However, there\nis no way that multiple autohandlers would be run for the same path (/foo/autohandler, for\nexample.) There is also no way for /foo/autohandler in root 1 to explicitly call\n/foo/autohandler in root 2.\n\nPeople sometimes ask for this behavior to be changed. We feel it's a bad idea because multiple\ncomponent roots, right now, are very clean in both behavior and implementation. Trying to run\nmultiple autohandlers for the same path would require a complex set of precedence rules that\nwould almost certainly lead to unpredictable behavior. (Think about multiple versions of\nmultiple autohandlers at different directory levels, and trying to predict which order they'd\nrun in.)\n"
                }
            ]
        },
        "CACHING": {
            "content": "When I change a component I don't always see the results in the output. How do I invalidate Mason code caches?\nMason employs two kinds of code caching. First, Mason caches loaded components in memory.\nSecond, Mason keeps an object file (a compiled version of the component) for every loaded\ncomponent under dataroot/obj.\n\nBefore executing a memory-cached component, Mason compares the stored timestamp with the\ntimestamp of the source file. If the source file has a later timestamp, Mason will load the\ncomponent from the filesystem.\n\nSimilarly, before using an object file, Mason compares the modified timestamp of the source and\nobject files. If the source file has a later timestamp, then it is reparsed and the object file\nis overwritten.\n\nThe system is designed so that you will immediately see the effects of source file changes.\nThere are several ways for this system to breakdown; most are easy to avoid once you know about\nthem.\n\n* If you copy or move in a component source file from elsewhere, it will retain the original\nfile's timestamp, which may be earlier than the object file.\n\n* If you use tar, rsync, rdist or similar programs to transfer components, the timestamps of the\ncreated files may not be updated to the current time. Check the program's documentation for\ntimestamp-related options.\n\n* If you use a shared file system like NFS, the timestamps of locally created files may not jibe\nwith timestamps of NFS files due to differences in machine clocks.\n\n* If you ftp files onto a running server, Mason may read the file while it is incomplete. If the\nftp then completes within the same second, Mason will not notice the change, and won't ever read\nthe complete file.\n\nWhen in doubt, touching the source files (with the Unix touch command, or by re-saving in an\neditor) should force Mason to reload the component. If that does not work, try removing the\nobject files and/or restarting the server to clear the memory cache. However, these remedies\nshould be necessary only to diagnose the caching problem, not for normal Mason operation. On a\nnormal Mason system cache expiration should just work \"as expected\".\n\nMason code caching breaks down often in my situation. Couldn't you do something smarter than just comparing the timestamps?\nWhen coming up with invalidation schemes, we must consider efficiency as well as failure\npredictability. The current scheme does fail in certain situations, but those situations are\nvery predictable. If you incorrectly use tar or copy or another technique mentioned above,\nyou'll see the cache invalidation failure very quickly.\n\nSome alternatives that have been suggested:\n\n* Compare the sizes of the files as well as timestamps, or use the more liberal \"source\ntimestamp != object timestamp\". This would indeed increase the chance of catching a change. But\nit would still fail occasionally (e.g. when changing a single character, or when copying an\nold-timestamp file that just happens to match the current timestamp), resulting in intermittent,\nhead-scratching errors. In our opinion, it is better to fail miserably up front and be forced to\nfix your system than to have a mostly-working system that fails once a week. This is especially\ntrue when you are relying on Mason's cache invalidation on a production system.\n\n* Comparing MD5 or other signatures of the content. This would be very accurate, but would\nrequire reading and processing the source file instead of just performing a stat. This extra\nexpense reduces the effectiveness of the cache.\n\nThe bottom line: If you are relying on Mason's cache invalidation on a production system, you\nshould take the time and build in the appropriate infrastructure to ensure that source file\ntimestamps are always up-to-date after they are copied/untarred into place.\n\nWhen I change code in a library file I don't see the results. How can I get Mason to reread the library files?\nmodperl processes, in general, do not automatically reread your library files. You either have\nto stop and start the server whenever you change a library file, or install something like\nApache::Reload which will automate their reloading. However, see ApacheReload for important\nusage information.\n\nOnce I've made an error in a component, the error keeps appearing in the logs, no matter how many times I fix it and reload!\nAre you using Apache::Reload in its default (!ReloadAll) mode? If so, see ApacheReload for\ndetails.\n\nDo data cache files expire automatically when a component or its dependencies change?\nUnfortunately they do not. This is on the to-do list.\n\nWith Mason 1.1x and beyond, you can use the following idiom to say ``expire when my component\nsource file changes'':\n\n$m->cache(...,\nexpireif=>sub {\n(stat($m->currentcomp->sourcefile))[9] > $[0]->getcreatedat\n} )\n\nWith Mason <= 1.05, the idiom looks like:\n\n$m->cache(...,\nexpireif=>sub {\n(stat($m->currentcomp->sourcefile))[9] > $[0]\n} )\n",
            "subsections": []
        },
        "COMPONENTS": {
            "content": "What is a component?\nA component is a file that contains some combination of text (typically HTML), perl code and\nHTML::Mason directives.\n\nSome components are accessed directly by web browsers. These are called top-level components. A\ntop-level component might consist purely of static HTML.\n\nOther components are support components, which are called by top-level components or other\nsupport components. These components are analogous to perl subroutines -- they allow you to\ncreate small packages of code that you can reuse throughout your project.\n\nHow do components communicate with each other?\nComponents can return values to their callers, just like subroutines.\n\nSome components may have very simple return values. As an example, consider a component called\nisNetscape which returns a true value when the client's browser is Netscape and undef when it is\nnot. The isNetscape component could then be used easily in an if() or other control statement.\n\nOf course, components can also return strings of text, arrays, hashes or other arbitrarily\ncomplex perl data structures.\n\nHow do I use modules in components?\nTechnically you can just say \"use module-name\" at the beginning of a component. The\ndisadvantages of this method are that:\n\n* the module will be used separately by every httpd child process, costing both time and memory.\n\n* it is difficult to keep track of all the modules being used on a site.\n\nA more efficient method is to put the use line in the handler.pl or use the PerlModule\ndirective. If you want components to be able to refer to symbols exported by the module, you\nneed to use the module inside the HTML::Mason::Commands package. See the \"External modules\"\nsection of the Administrator's Guide:\n\nCan I define subroutines in components?\nDefining a named subroutine in a <%perl> or <%init> section does not work reliably because such\na definition would end up residing inside another subroutine, and Perl doesn't like that.\n\nYou can technically define named subroutines inside the <%once> section of any component, but we\nhighly discourage this, because all components are executed in the same namespace. This makes it\neasy to create two subroutines with the same name in two different components.\n\nConsider the following options:\n\n* If the routine is going to display HTML, use a separate component or a <%def> subcomponent.\n\n* If the subroutine is only of use in your component, use an anonymous subroutine defined in\n<%once>. Even though you could define the anonymous subroutine in any section, a <%once> is\nrecommended, both for performance and to avoid nested-anonymous-subroutine leaks in Perl <=5.6.\nExample:\n\n<%once>\nmy $foo = sub {\n...\n};\n</%once>\n\n...\n\n% $foo->()\n\n* If the subroutine is of interest to more than just your component, have you considered putting\nit in a module?\n\nNote that calling a component, while reasonably fast, is about an order of magnitude slower than\ncalling an equivalent subroutine. So if you're going to call the routine many times in a loop,\nyou may wish to use the anonymous subroutine for performance reasons. Benchmark for yourself.\n\nDoes Mason set the current working directory (\".\") for me?\nMason does not touch the working directory, as this would entail an unnecessary performance hit\nfor the majority of users that don't need it.\n\nIn an Apache environment, the working directory will be set in a more-or-less random way,\ndepending on such seemingly irrelevant factors as whether you started the server in\nsingle-process mode or not. In a non-Apache environment the working directory will be whatever\nit was before Mason started executing.\n\nOften people expect the working directory to be the directory of the current component. You can,\ninstead, get that directory manually with\n\n$m->currentcomp->sourcedir\n\nHow do I exit from all components including the ones that called me?\nUse $m->abort, documented in the Request manual:\n\nWhy does my output have extra newlines/whitespace and how can I get rid of it?\nAny newlines that are not either inside a tag or on a %-line will become part of the output.\nSince browsers ignore extra whitespace this is not generally a problem, but there are situations\nwhere it matters, e.g. within <pre> tags.\n\nFirst, for components that only return a value and shouldn't output *any* content, you should\nalways use <%init>:\n\n<%args>\n$foo\n</%args>\n\nThis content will be ignored.\n\n<%init>\nmy $bar = $dbh->selectrowarray(\"SELECT bar FROM t WHERE foo=?\", $foo);\nreturn $bar;\n</%init>\n\nIn components that do display content, there are various strategies. To eliminate selected\nnewlines, use the backslash. For example,\n\n<PRE>\nfoo\\\n% if (1) {\nbar\\\n% }\nbaz\n</PRE>\n\noutputs \"foobarbaz\" with no newlines.\n\nTo prevent a component from outputting any newlines, use a filter:\n\n<%filter>\ns/\\n//g;\n</%filter>\n\nTo emit binary data without the risk of inserting extra whitespace, surround your code with\n$m->clearbuffer and $m->abort, to suppress any preceding and following content:\n\n<%init>\n$m->clearbuffer;\nmy $fh = IO::File->new('< binaryfile') or die $!;\nmy $buffer;\nwhile (read $fh, $buffer, 8192) {\n$m->print($buffer);\n}\n$m->abort;\n</%init>\n\nAt some point Mason will probably offer a \"reasonable\" whitespace removal feature, controlled by\nparameter.\n\nI'm trying to generate an image or other binary file, but it seems to be getting corrup\nThis is almost always caused by unwanted whitespace at the beginning or end of your binary data.\nPut a $m->clearbuffer before, and an $m->abort after, your code. See the last part of the\nanswer above.\n\nIn Apache 1.0 a real working example looks like this:\n\nmy $fh;\nmy $fileName = '/tmp/mypic.jpg';\nopen ( $fh, $fileName ) or die $!;\n\n$m->clearbuffer();\n$r->contenttype( 'image/jpeg' ); # set mime-type\n$r->sendhttpheader;\n$r->sendfd ( $fh );\nclose ( $fh );\n\nIn Apache 2.0 use:\n\nuse Apache2::Const qw(HTTPOK)\n\nmy $fileName = 'someimage.jpg';\n$m->clearbuffer();\n$r->contenttype( 'image/jpeg' );\n$r->sendfile( $fileName )\n$r->abort( Apache2::Const::HTTPOK );\n\nHow do I put comments in components?\n* Put general comments in the <%doc> section.\n\n* In the <%init> and <%cleanup> sections, and in a <%perl> block, use standard Perl comments\n('#').\n\n* In Mason 1.3 and beyond, use <%# %> for single or multi-line comments anywhere outside of Perl\nsections. Before 1.3, this syntax isn't guaranteed to work; one alternative is to begin a line\nwith %#.\n\n* If you are producing HTML, you can use standard HTML comments delimited by <!-- -->. The\ndifference is that these comments will appear in the final output.\n\nWhat's a good way to temporarily comment out code in a component?\nFor HTML, you might be tempted to surround the section with <!-- -->. But be careful! Any code\ninside the section will still execute. Here's a example of commenting out a call to an ad\nserver:\n\n<!-- temporarily comment out\n<& FetchAd &>\n-->\n\nThe ad will still be fetched and counted, but not displayed!\n\nA better way to block out a section is if (0):\n\n% if (0) {\n...\n% }\n\nCode blocked out in this way will neither be executed nor displayed, and multiple if (0) blocks\ncan be nested inside each other (unlike HTML comments).\n\nAnother way to block out code is with a <%doc> tag or a <%# %> comment, although these not\ncannot be nested.\n\nHow can I capture the output of a component (and modify it, etc.) instead of having it automatically output?\nUse $m->scomp, documented in the Request manual:\n\nCan I use globals in components?\nAll HTML::Mason components run in the same package (HTML::Mason::Commands), so if you set a\nglobal variable in one you'll be able to read it in all the others. The only problem is that\nMason by default parses components with strict mode on, so you'll get a warning about the global\n(and Mason considers all such warnings fatal). To avoid errors, simply declare your globals via\nthe MasonAllowGlobals parameter.\n\nPerlSetVar MasonAllowGlobals $dbh\nPerlAddVar MasonAllowGlobals $user\n\nIf you have a handler.pl file, you can also declare global variables in the handler() subroutine\nas long as you explicitly put them in the HTML::Mason::Commands package.\n\npackage HTML::Mason::Commands;\nuse vars qw(...);\n\nor use the Parser allowglobals parameter.\n\nAlternatively you can turn off strict entirely by passing:\n\nusestrict => 0\n\nwhen you create the Parser object. Then you can use all the globals you want. Doing this is\nterribly silly, however, and is bound to get you in trouble down the road.\n\nHow do I share variables between components?\nFirst, you can pass variables from one component to another.\n\nSecond, you can use globals. All components run in the same package (HTML::Mason::Commands as of\nthis writing), so globals in this package are visible to all components. See the previous\nquestion.\n\nThere is no way to share a variable between just a few components; this is a limitation of\nPerl's scoping rules. You can make a variable /visible/ to only certain components using 'our'\ndeclarations:\n\n<%once>\nour ($sharedvar);\n</%once>\n\nSee the Perl documentation on 'our' to make sure you understand what this is doing.\n\nThe <%shared> section is /not/ for sharing variables among different file components. It is for\nsharing variables among the subcomponents and methods of a single file component.\n\nWhy does the order of output get mixed up when I use print or $r->print?\nThis should no longer happen with Mason 1.10+. For those users still using older versions of\nMason, read the following:\n\nSince your server is most likely in batch mode, all Mason output gets buffered til the end of\nthe request. print and $r->print circumvent the buffer and thus come out before other Mason\noutput.\n\nSolution: don't use print or $r->print. Use $m->out if you must output inside a Perl section.\nSee the section on output mode in the Administrator's Guide.\n\nand the section on $m->out in the Request manual.\n\nWhy doesn't my <%cleanup> code run every time the component runs?\nA <%cleanup> block is equivalent to a \"<%perl>\" block at the end of the component. This means it\nwill NOT execute if the component explicitly returns, or if an abort or error occurs in that\ncomponent or one of its children.\n\nIf you need code that is guaranteed to run when the component or request exits, consider using a\nmodperl cleanup handler, or creating a custom class with a DESTROY method.\n\nIs <%args> exactly like %ARGS, and do I need to worry about it?\nMason allows you to predeclare arguments to components by specifying variables to hold those\narguments in an <%args></%args> section. Because these are perl variables that you are\npredeclaring, they must have legal perl identifier names -- they can't, for example, contain\nperiods.\n\nIf you want to pass arguments that are not identified with legal perl names, you must manually\npull those arguments out of the %ARGS hash that modperl sets up for you. Why would you want to\nname your arguments un-legally, you ask? Well, just for starters, the form input element <input\ntype=\"image\" name=\"clickable\"> will pass arguments clickable.x and clickable.y to the action url\nautomatically. If you want to access these, you'd have to use $ARGS{clickable.x} and\n$ARGS{clickable.y} rather than trying to declare them in <%args>.\n\nWhy does Mason display the wrong line numbers in errors?\nDue to limitations in the 1.0x parser, Mason can only display line numbers relative to object\nfiles.\n\nIn 1.1 and on, error line numbers correctly reflect the component source.\n\nHow can I get a list of components matching a path pattern?\nUse the resolver's globpath method:\n\nmy @paths = $m->interp->resolver->globpath('/some/comp/path/*');\n\nThis will work even with multiple component roots; you'll get a combined list of all matching\ncomponent paths in all component roots.\n\nCan I access $m (the request object) from outside a component, e.g. inside a subroutine?\nIn 1.1x and on, use\n\nmy $m = HTML::Mason::Request->instance;\n\nBefore 1.1x, use\n\nmy $m = HTML::Mason::Commands::m;\n\nHow can I make the |h escape flag work with my Russian/Japanese/other-non-western encoding?\nThe |h flag is implemented with [=HTML::Entities::encodehtml]. This function, by default,\nescapes control chars and high-bit chars as well as <, >, &, and \". This works well for\nISO-8559-1 encoding but not with other encodings.\n\nTo make |h escape just <, >, &, and \", which is often what people want, put the following in\nyour Apache configuration:\n\nPerlSetVar  MasonEscapeFlags  \"h => \\&HTML::Mason::Escapes::basichtmlescape\"\n\nOr, in a top-level autohandler:\n\n$m->interp->setescape( h => \\&HTML::Mason::Escapes::basichtmlescape );\n\nWhen using multiple component roots, is there a way to explicitly call a component in a specific root?\nMultiple component roots were designed to work just like Perl's @INC. A given component path\nmatches exactly one file, the first file found in an ordered search through the roots. There is\nno way to explicitly ask for a file in a specific root.\n\nPeople sometimes ask for the ability to do this. We feel it's a bad idea because it would\nendanger the cleanliness of multiple component roots in both behavior and implementation. As it\nstands now, the rules are very easy to understand and the implementation is very clean and\nisolated; only the resolver really needs know about multiple component roots.\n\nIf you want to be able to explicitly refer to components in a given root, put an extra\nsubdirectory between the root and the components. e.g. put your components in\n\n/usr/local/htdocs/global/global/...\n\nthen add the root as\n\n['global', '/usr/local/htdocs/global']\n\nNow you can prefix a path with /global to refer to any component in that root.\n\nAlternatively, [http://search.cpan.org/dist/MasonX-Request-ExtendedCompRoot\nMasonX::Request::ExtendedCompRoot] is a subclass of Mason that does allow you to call components\nin a specific component root.\n\nIs there a syntax checker like perl -c for components?\nIt is impossible to write a truly generic standalone script to syntax check components, because\ncomponents rely on certain globals and modules to be present in their environment. Mason may\nreport compile errors from such a script even though they would not occur in your normal web\nenvironment.\n\nThe best you can do is write a standalone script that mimics your web environment as much as\npossible - in particular, declaring the same globals and loading the same modules. Instead of\nactually executing components, your script need only load them with $interp->load(). This method\nwill throw a fatal error if a component fails to load.\n",
            "subsections": []
        },
        "HTTP AND HTML": {
            "content": "How do I access GET or POST arguments?\nGET and POST arguments are automatically parsed and placed into named component arguments just\nas if you had called the component with <& &> or $m->comp. So you can get at GET/POST data by\npre-declaring argument names and/or using the %ARGS hash which is always available.\n\nHow can I access the raw content of a POST in a Mason component?\nIt depends on your environment as to what you can do.\n\nApache/modperl has an easier way of doing it than CGI/FCGi, which uses FakeApache. As you can\nsee from the comment, since FakeApache implements read, I couldn't get it to be completely\ndynamic:\n\nmy $inputText;\n# FakeApache implements read, so we can't automatically tell\n# if we're in modperl or FCGI\nif (0 && $r->can('read')){\n$r->read( $inputText, $r->headersin->{'Content-length'} );\n}\nelse {\nmy %params = $r->params;\nmy $postedcontent = $params{POSTDATA} || $params{keywords};\n$postedcontent ||= join '', %params if ($r->method eq 'POST');\n$postedcontent = join '', @$postedcontent if (ref $postedcontent eq 'ARRAY');\n$inputText = $postedcontent\n}\n\n-- Gareth Kirwan\n\nProbably $r->params does not work. there is no such method in 'man Apache'\n\n-- Rajesh Kumar Mallah.\n\nWhat happens if I include query args in a POST?\nAs of Mason 1.01, query string and POST arguments are always combined.\n\nShould I use CGI.pm to read GET/POST arguments?\nNo! HTML::Mason automatically parses GET/POST arguments and places them in declared component\narguments and %ARGS (see previous question). If you create a CGI object in the usual way for a\nPOST request, it will hang the process trying to read $r->content a second time.\n\nCan I use CGI.pm to output HTML constructs?\nYes. To get a new CGI object, use\n\nmy $query = new CGI('');\n\nYou have to give the empty string argument or CGI will try to read GET/POST arguments.\n\nTo print HTML constructs returned by CGI functions, just enclose them in <%%>, e.g.\n\n<% $query->radiogroup(...) %>\n\nHow do I modify the outgoing HTTP headers?\nUse the usual Apache.pm functions, such as $r->headerout. See the \"Sending HTTP Headers\"\nsection in the Component Developer's Guide.\n\nHow do I do an external redirect?\nIn Mason 1.0x, use code like this:\n\n$m->clearbuffer;\n# The next two lines are necessary to stop Apache from re-reading\n# POSTed data.\n$r->method('GET');\n$r->headersin->unset('Content-length');\n$r->contenttype('text/html');\n$r->headerout('Location' => $location);\n$m->abort(301);\n\nIn Mason 1.1x, use the [=$m->redirect] method.\n\nSee the next question if your redirect isn't producing the right status code.\n\nWhen trying to use $m->redirect I get 'Can't locate object method \"redirect\" via package \"HTML::Mason::!ApacheHandler\"'.\n$m->redirect is supported only in Mason 1.1x and on. Check your Mason version by putting\n\nVersion = <% $HTML::Mason::VERSION %>\n\nin a component.\n\nWhy isn't my status code reaching users' browsers?\nIf you are using a handler.pl, your handler() routine should always return the error code that",
            "subsections": [
                {
                    "name": "handle_request",
                    "content": "very, very simple handler() routine would look like this:\n\nsub handler {\nmy $r = shift;\n$ah->handlerequest($r);\n}\n\nIf you are using $m->abort or $m->redirect and there is an eval() wrapped directly or indirectly\naround the call, you must take care to propagate abort exceptions after the eval(). This looks\nlike:\n\neval { $m->comp('...') };\nif ($@) {\nif ($m->aborted) {\ndie $@;\n} else {\n# deal with non-abort exceptions\n}\n}\n\nHow can I handle file uploads under Mason?\nThe basic HTML for an upload form looks like:\n\n<form action=\"...\" method=\"post\" enctype=\"multipart/form-data\">\nUpload new file:\n<input name=\"userfile\" type=\"file\" class=\"button\">\n<input type=\"submit\" value=\"Upload\">\n\nThe way you handle the submission depends on which args method you chose for the !ApacheHandler\nclass.\n\nUnder the 'CGI' method (default for 1.0x), you can use the [=$m->cgiobject] method to retrieve\na CGI.pm object which can be used to retrieve the uploaded file. Here is an example using the\n'CGI' method:\n\n<%init>\nmy $query = $m->cgiobject;\n\n# get a filehandle for the uploaded file\nmy $fh = $query->upload('userfile');\n\n# print out the contents of the uploaded file\nwhile (<$fh>) {\nprint;\n}\nclose($fh);\n</%init>\n\nPlease see the [CGI.pm\nhttp://search.cpan.org/~lds/CGI.pm-3.05/CGI.pm#CREATINGAFILEUPLOADFIELD documentation] for\nmore details.\n\nUnder the 'modperl' method (default for 1.1x), the request object available as [=$r] in your\ncomponents will be an object in the Apache::Request class (as opposed to the Apache class). This\nobject is capable of returning Apache::Upload objects for parameters which were file uploads.\nPlease see the [Apache::Request\nhttp://search.cpan.org/~joesuf/libapreq-1.3/Request/Request.pm#Apache%3A%3AUploadMETHODS\ndocumentation] for more details. Here is an example using the 'modperl' method:\n\n<%init>\n\n# NOTE: If you are using libapreq2 + modperl2 + Apache 2,\n# you will need to uncomment the following line:\n# use Apache::Upload;\n\n# you can store the file's contents in a scalar\nmy $filecontents;\n\n# create an Apache::Upload object\nmy $upload = $r->upload;\n\n# get a filehandle for the uploaded file\nmy $uploadfh = $upload->fh;\n\nwhile(<$uploadfh>) {\n# loop through the file and copy each line to $filecontents\n$filecontents .= $;\n}\nclose($uploadfh);\n</%init>\n\nFor more information on how to manually set the args method, see the !ApacheHandler\ndocumentation.\n\nIf you are using CGI.pm, there are some configuration issues to be aware of. CGI.pm needs a tmp\ndirectory, and you probably want to be able to specify what that directory is.\n\nTry doing this in your httpd.conf or handler.pl:\n\n<Perl>\nuse CGI qw(-privatetempfiles);\n</Perl>\n\nYou must do this before you load either the HTML::Mason or HTML::Mason::!ApacheHandler\nmodules.\n\nThat may change which directories CGI tries to use.\n\nYou could also try\n\n$CGI::TempFile::TMPDIRECTORY = '/tmp';\n\nduring startup, either in your httpd.conf or handler.pl\n\nThe root of the problem is probably that the temp directory is being chosen when the module\nloads uring server startup while its still root. It sees it can write to /usr/tmp and is happy.\nThen when actually running as nobody it dies.\n\nI bet Lincoln would welcome a patch (hint, hint). One solution would be to check if you're\nrunning under modperl and you're root. If so, then check Apache->server->uid and see if that id\ncan write to the temp directory too.\n\nHow can I redirect the current request to be a file download?\nA detailed explanation is provided in ForceFileDownload.\n\nHow can I manipulate cookies?\nYou can use the helpful modules Apache::Cookie and CGI::Cookie. It's also fairly easy to roll\nyour own cookie-manipulation functions, using the methods provided by the $r global.\n\nOne thing to avoid: the combination of CGI::Cookie, Apache::Request, and POST requests has\ncaused people problems. It seems that Apache::Cookie and Apache::Request make a better pair.\n\nHow can I populate form values automatically?\nSeveral CPAN modules provide form-filling capabilities. HTML::!FillInForm is one good choice and\nworks well with Mason. Here's a sample code snippet:\n\n<%filter>\n$ = HTML::FillInForm->new->fill(scalarref => \\$, fdat => \\%ARGS );\n</%filter>\n\nThis will work for any component that contains a complete form in its output.\n\nIf you are using Apache::Request to process incoming arguments under modperl (the default as of\n1.10), then you can also do this:\n\n<%filter>\nuse HTML::FillInForm;\n$ = HTML::FillInForm->new->fill(scalarref => \\$, fobject => $r );\n</%filter>\n\nThese two examples are slightly different from each other, in that each makes a different set of\nparameters available to HTML::!FillInForm. In the first example, the arguments used are those\nthat were explicitly passed to the component. In the second example, the arguments are those\nthat were passed in the initial HTTP request. Of course, variations on this are possible by\nmixing and matching %ARGS, $m->requestargs, $m->callerargs, and so on.\n"
                }
            ]
        },
        "INSTALLATION": {
            "content": "What else do I need to use Mason?\nIf you are planning on using Mason in a web environment with the Apache webserver, you'll need a\nworking copy of Apache and modperl installed. Make sure that your modperl installation works\ncorrectly before trying to get Mason working. Also, if you are running RedHat Linux, beware the\nmodperl RPMs that ship with RedHat. They were unreliable for a very long time, and their\ncurrent state is still murky.\n\nWhat platforms does Mason run on?\nBecause Mason consists of only Perl code, it should work anywhere Perl runs (including most Unix\nand Win32 variants). If it doesn't work on your operating system, let us know.\n\nCan I run Mason outside a web server?\nYes, in fact Mason can be useful for generating a set of web pages offline, as a general\ntemplating tool, or even as a code generator for another language. See the \"Standalone Mode\"\nsection of the Interpreter manual.\n\nCan I run Mason via CGI?\nYes. See \"Using Mason from a CGI script\" in the Interpreter manual.\n\nThe examples in the docs requires that you have Mason 1.10+ installed.\n\nNote that running Mason under CGI (or other non-persistent environments) will entail a\nsubstantial performance hit, since the perl interpreter will have to load, load up Mason and its\nsupporting modules for every CGI execution. Using modperl or similar persistent environments\n(SpeedyCGI, FastCGI, etc.) avoids this performance bottleneck.\n\nCan I use Mason with Apache/modperl 2.0?\nYes, as of Mason 1.27 (released 10/28/2004), there is support for Apache/modperl 2.0 in the\ncore Mason code. You may find other hints at ApacheModPerl2.\n\nWhere can I find a web host supporting Mason?\nPlease check the [Hosting] page for a list of hosting providers supporting HTML::Mason. You may\nalso be interested in the list of [http://perl.apache.org/help/isps.html ISPs supporting\nmodperl], however, there are reports that this document has not been maintained in several\nyears.\n\nWhat does the error \"Can't locate object method 'TIEHASH' via package 'Apache::Table'\" mean?\nIt means that Mason is trying to use some of modperl's \"table\" interface methods, like\n$r->dirconfig->get('key') or the like. It's failing because your modperl server wasn't\ncompiled with support for Apache's Table API.\n\nTo fix the problem, you'll have to recompile your server, adding the PERLTABLEAPI=1 flag (or\nEVERYTHING=1).\n\nIf you can't recompile your server, you can edit the Mason source code. Find a line in\nApacheHandler.pm that looks like this (it's line 365 in Mason 1.04):\n\nmy @val = $modperl::VERSION < 1.24 ? $c->dirconfig($p) :\n$c->dirconfig->get($p);\n\nand change it to:\n\nmy @val = Apache::perlhook('TableApi') ? $c->dirconfig->get($p) :\n$c->dirconfig($p);\n\nRecent versions of Mason use that, or a variant of it.\n\nWhat does the error \"Can't locate Apache/Request.pm in @INC\" m\nYou are using the default !ApacheHandler argsmethod ('modperl'), which requires that you have\ninstalled the Apache::Request package (libapreq).\n\nYou can either install libapreq, or change argsmethod to 'CGI'. The latter is a bit slower and\nuses more memory.\n\nWhy am I getting segmentation faults (or silently failing on startup)?\nThere are a few known modperl issues that cause segmentation faults or a silent failure on the\npart of Apache to start itself up. Though not specific to Mason, they are worth keeping in mind:\n\n* Are you using a dynamically-linked modperl? DSO modperl builds were unstable for a long\ntime, although they might finally be getting better. Rebuild Apache with modperl linked\nstatically and see if the problem goes away. Also see\nhttp://perl.apache.org/docs/1.0/guide/install.html#WhenDSOcanbeUsed.\n\n* Earlier versions of XML::Parser and Apache could conflict, because both would statically\ncompile in expat for XML parsing. This was fixed as of Apache version 1.3.20 and XML::Parser\n2.30, both of which can be compiled against the same shared libexpat. You can also build Apache\nwith '--disable-rule=EXPAT'. Matthew Kennedy points out that 'If \"strings `which httpd` | grep\n-i xml\" returns anything, you have this problem.'\n\n* Are you using Perl 5.6.0? Though not widespread, Perl 5.6.0 can generate sporadic segmentation\nfaults at runtime for some Perl code. Specifically, evals of moderate complexity appear\nproblematic. And, since Mason uses lots of evals of moderate complexity, you can't avoid them.\nIf the two suggestions above don't solve your segfault problem and you are running Perl 5.6.0,\ntry upgrading to Perl 5.6.1.\n\nMISCELLANEOUS\n\nWhere did the name come from?\nIt was inspired by a recent reading of Ken Follett's \"The Pillars Of The Earth.\" The book\ncentered around the life of a mason, a builder of great churches and buildings.\n\nPERFORMANCE\n\nIs Mason fast?\nIt is typically more than fast enough. 50-100 requests per second for a simple component is\ntypical for a reasonably modern Linux system. Some simple benchmarking indicates that a Mason\ncomponent is typically about two to three times slower than an equivalent, hand-coded modperl\nmodule.\n\nAlthough benchmarks on [http://chamas.com/bench/ Apache Hello World! benchmarks] site shows that\nMason code is five (simple Hello World page, [=hello.mas]) to ten (heavyweight template,\n[=h2000.mas]) times slower than modperl solution.\n\nBeware of \"Hello World!\" and other simple benchmarks. While these benchmarks do a good job of\nmeasuring the setup and initialization time for a package, they are typically not good measures\nof how a package will perform in a complex, real-world application. As with any program, the\nonly way to know if it meets your requirements is to test it yourself.\n\nIn general, however, if your application is fast enough in pure modperl, it will most likely be\nfast enough under HTML::Mason as well.\n\nHow can I make my Mason application run faster?\nThe first thing you can do to optimize Mason performance is to optimize your modperl\ninstallation. Consider implementing some of the tuning tips recommended in modperltuning,\nwhich ships with every copy of modperl.\n\nIf your application still needs to run faster, consider using Mason's caching methods ($m->cache\nand $m->cacheself) to avoid regenerating dynamic content unnecessarily.\n\nDoes Mason leak memory?\nMason 1.10 and 1.11 do have a memory leak. This is fixed with 1.12. Earlier versions of Mason\nmay leak some memory when using the \"modperl\" argsmethod, due to what is arguably a bug in\nApache::Request.\n\nIf you do find other memory leaks that are traceable to Mason, please check the known bugs list\nto make sure it hasn't already been reported. If it hasn't, simplify your handler.pl (if you\nhave one) and the offending component as much as possible, and post your findings to the\nmason-users mailing list.\n\nOf course it is always possible for your own component code to leak, e.g. by creating and not\ncleaning up global variables. And modperl processes do tend to grow as they run because of\n\"copy-on-write\" shared-memory management. The modperl documentation and performance faq make\ngood bedtime reading.\n\nIf you are using RedHat's modperl RPM, or another DSO modperl installation, you will leak\nmemory and should switch to a statically compiled modperl.\n\nSERVER CONFIGURATION\n\nWhy are my config file changes not taking effect?\n1. After changing an httpd.conf or handler.pl or other server configuration file, make sure to\ndo a FULL stop and start of the server. By default, the server will not reread Perl scripts or\nconfiguration when using \"apachectl restart\" or when sending a HUP or USR1 signal to the server.\n\nFor more details see \"Server Stopping and Restarting\" in the modperl guide.\n\n2. Note that you cannot use Mason httpd parameters (MasonCompRoot, MasonErrorMode, etc.) and a\nhandler.pl script that creates an ApacheHandler object at the same time. Depending on how you\ndeclare your PerlHandler, one or the other will always take precedence and the other will be\nignored. For more details see \"Site Configuration Methods\" in the Admin manual.\n\nWhat filename extensions should I use for Mason components?\nUnlike many templating systems, Mason comes with no obvious filenaming standards. While this\nflexibility was initially considered an advantage, in retrospect it has led to the proliferation\nof a million different component extensions (.m, .mc, .mhtml, .mcomp, ...) and has made it more\ndifficult for users to share components and configuration.\n\nThe Mason team now recommends a filenaming scheme with extensions like .html, .txt, .pl for\ntop-level components, and .mhtml, .mtxt, .mpl for internal (non-top-level) components.\n\nWhatever naming scheme you choose should ideally accomplish three things:\n\n* Distinguish top-level from internal components. This is obviously crucial for security.\n\n* Distinguish output components from those that compute and return values. This improves\nclarity, and forces the component writer to decide between outputting and returning, as it is\nbad style to do both.\n\n* Indicate the type of output of a component: text, html, xml, etc. This improves clarity, and\nhelps browsers that ignore content-type headers (such as IE) process non-HTML pages correctly.\n\nCan I serve images through a HTML::Mason server?\nIf you put images in the same directories as components, you need to make sure that the images\ndon't get handled through HTML::Mason. The reason is that HTML::Mason will try to parse the\nimages and may inadvertently find HTML::Mason syntax (e.g. \"<%\"). Most images will probably pass\nthrough successfully but a few will cause HTML::Mason errors.\n\nThe simplest remedy is to have HTML::Mason decline image and other non-HTML requests, thus\nletting Apache serve them in the normal way.\n\nAnother solution is to put all images in a separate directory; it is then easier to tell Apache\nto serve them in the normal way. See the next question.\n\nFor performance reasons you should consider serving images from a completely separate\n(non-HTML::Mason) server. This will save a lot of memory as most requests will go to a thin\nimage server instead of a large modperl server. See Stas Bekman's modperl guide and Vivek\nKhera's performance FAQ for a more detailed explanation. Both are available at\nhttp://perl.apache.org/\n\nHow can I prevent a particular subdirectory from being handled by HTML::Mason?\nSuppose you have a directory under your document root, \"/plain\", and you would like to serve\nthese files normally instead of using the HTML::Mason handler. Use a Location directive like:\n\n<Location /plain>\nSetHandler default-handler\n</Location>\n\nOr suppose you have a \"/cgi-bin\" that you want to process via CGI:\n\n<Location /cgi-bin>\nSetHandler cgi-script\n</Location>\n\nWhen you have multiple Location directives, the latest ones in the configuration have the\nhighest precedence. So to combine the previous directive with a typical Mason directive:\n\n<Location />\nSetHandler perl-script\nPerlHandler HTML::Mason\n</Location>\n\n<Location /cgi-bin>\nSetHandler cgi-script\n</Location>\n\nMore generally, you can use various Apache configuration methods to control which handlers are\ncalled for a given request. Ken Williams uses a FilesMatch directive to invoke Mason only on\nrequests for \".html\" files:\n\n<FilesMatch  \"\\.html$\">\nSetHandler perl-script\nPerlHandler HTML::Mason\n</FilesMatch>\n\nOr you could reverse this logic, and write FilesMatch directives just for gifs and jpegs, or\nwhatever.\n\nIf you are using a handler.pl, you can put the abort decision in your handler() routine. For\nexample, a line like the following will produce the same end result as the <Location /plain>\ndirective, above.\n\nreturn -1 if $r->uri() =~ m|^/plain|;\n\nHowever, performance will not be as good as the all-Apache configuration.\n\nWhy am I getting 404 errors for pages that clearly exist?\nThe filename that Apache has resolved to may not fall underneath the component root you\nspecified when you created the interpreter in handler.pl. HTML::Mason requires the file to fall\nunder the component root so that it can call it as a top-level component. (For various reasons,\nsuch as object file creation, HTML::Mason cannot treat files outside the component root as a\ncomponent.)\n\nIf you believe the file is in fact inside the component root and HTML::Mason is in error, it may\nbe because you're referring to the Apache document root or the HTML::Mason component root\nthrough a symbolic link. The symbolic link may confuse HTML::Mason into thinking that two\ndirectories are different when they are in fact the same. This is a known \"bug\", but there is no\nobvious fix at this time. For now, you must refrain from using symbolic links in either of these\nconfiguration items.\n\nThe same thing could also happen in any context with more than one way to specify a canonical\nfilename. For example, on Windows, if your document root starts with \"C:\" and your component\nroot starts with \"c:\", you might have this problem even though both paths should resolve to the\nsame file.\n\nWith Mason 0.895 and above, if you set Apache's LogLevel to warn, you will get appropriate\nwarnings for these Mason-related 404s.\n\nSome of my pages are being served with a content type other than text/html.  How do I get HTML::Mason to properly set the content type?\nHTML::Mason doesn't actually touch the content type -- it relies on Apache to set it correctly.\nYou can affect how Apache sets your content type in the configuration files (e.g. srm.conf). The\nmost common change you'll want to make is to add the line\n\nDefaultType text/html\n\nThis indicates that files with no extension and files with an unknown extension should be\ntreated as text/html. By default, Apache would treat them as text/plain.\n",
            "subsections": [
                {
                    "name": "Microsoft Internet Explorer displays my page just fine, but Netscape or other browsers just display the raw HTML code.",
                    "content": "The most common cause of this is an incorrect content-type. All browsers are supposed to honor\ncontent-type, but MSIE tries to be smart and assumes content-type of text/html based on filename\nextension or page content.\n\nThe solution is to set your default content-type to text/html. See previous question.\n\nMy configuration prevents HTML::Mason from processing anything but html and text extensions, but I want to generate a dynamic image using HTML::Mason.  How can I get HTML::Mason to set the correct MIME type?\nUse modperl's $r->contenttype function to set the appropriate MIME type. This will allow you\nto output, for example, a GIF file, even if your component is called dynamicImage.html. However\nthere's no guarantee that every browser (e.g. Internet Explorer) will respect your MIME type\nrather than your file extension. Make sure to test on multiple browsers.\n\nHow do I bring in external modules?\nUse the PerlModule directive in your httpd.conf, or if you have a startup.pl file, put the 'use\nmodule' in there. If you want components to be able to refer to symbols exported by the module,\nhowever, you'll need to use the module inside the HTML::Mason::Commands package. See the\n\"External modules\" section of the Administrator's Guide.\n\nHow do I adjust Perl's INC path so it can find my modules?\nYou can do this:\n\n<Perl>\nuse lib ...\n</Perl>\n\nor this:\n\nPerlSetEnv PERL5LIB /path/one:/path/two:...\n\nHow do I use Mason in conjunction with UserDir to support Mason in user's home directories?\nThe idea is to create one ApacheHandler for each user, dynamically. You will need to use a\nhandler.pl or other wrapper code (see \"Writing a Wrapper\" in the Adminstrator's Manual).\n\nOutside your handler subroutine:\n\n# $userregexp: a regexp that matches the root directory of Mason.\n#               Make sure there is one arg in parens that represents\n#               the actual username--the handler uses this.\nmy $userregexp = qr'/Users/([^/]*)/(?:publichtml|Sites)';\nmy %userhandlers;\n\n# Create base ApacheHandler object at startup.\nmy $baseah = new HTML::Mason::ApacheHandler( comproot => $comproot,\ndatadir  => $datadir );\n\nInside your handler subroutine:\n\nsub handler\n{\nmy $r=$[0];\n...\n#\n# Have a different handler for each home directory\n#\nmy $currah;\nmy $filename = $r->filename();\nif($filename =~ m!$userregexp!) {\nmy $username = $1;\n$currah = $userhandlers{$username};\nif(!$currah) {\n$filename =~ m!($userregexp)!;\nmy $userdir = $1;\n$currah = new HTML::Mason::ApacheHandler(comproot=>[[$username => $userdir]],\ndatadir=>$datadir);\n$userhandlers{$1} = $currah;\n}\n} else {\n$currah = $baseah;\n}\nmy $status = $currah->handlerequest($r);\n\nreturn $status;\n}\n\nHow do I connect to a database from Mason?\nThe short answer is that most any perl code that works outside Mason, for connecting to a\ndatabase, should work inside a component. I sometimes do draft development and quick debugging\nwith something like:\n\n<%once>\nuse DBI;\n</%once>\n\n<%init>\nmy $dbh = DBI->connect ( blah, blah );\n...\n</%init>\n\nThe long answer is, of course, longer. A good deal of thought should be put into how a web\napplication talks to databases that it depends on, as these interconnections can easily be both\nperformance bottlenecks and very un-robust.\n\nMost people use some sort of connection pooling -- opening and then re-using a limited number of\ndatabase connections. The Apache::DBI module provides connection pooling that is reliable and\nnearly painless. If Apache::DBI has been use'd, DBI->connect() will transparently reuse an\nalready open connections, if it can.\n\nThe \"right\" place to ask Apache::DBI for database handles is often in a top level autohandler.\n\nFor example:\n\n<%init>\nmy $dbh = DBI->connect('dbi:mysq:somedb', 'user', 'pw');\n... # other processing\n$m->callnext( %ARGS, dbh => $dbh );\n</%init>\n\nAlternately, $dbh could be a global variable which you set via MasonAllowGlobals.\n\nYou can use Apache::DBI in your httpd.conf file quite easily simply by adding:\n\nPerlModule Apache::DBI\n\nIf you want to do more with Apache::DBI, like call connectoninit, you can use a <Perl> section\n\n<Perl>\nuse Apache::DBI;\nApache::DBI->connectoninit('dbi:mysql:somedb', 'user', 'pw');\nApache::DBI->setPingTimeOut('dbi:mysql:somedb', 0);\n</Perl>\n\nOthers may simply use a handler.pl file. Georgiou Kiriakos writes:\n\nYou can connect in the handler.pl - I find it convenient to setup a\nglobal $dbh in it.  You just need to make sure you connect inside\nthe handler subroutine (using Apache::DBI of course).  This way a)\neach httpd gets it's own connection and b) each httpd reconnects if\nthe database is recycled.\n\nRegardless of whether you set up global $dbh variables in handler.pl, the static sections of\nhandler.pl should set up Apache::DBI stuff:\n\n# List of modules that you want to use from components (see Admin\n# manual for details)\n{\npackage HTML::Mason::Commands;\nuse Apache::DBI;\n# use'ing Apache::DBI here lets us connect from inside components\n# if we need to.\n# --\n# declare global variables, like $dbh, here as well.\n}\n\n# Configure database connection stuff\nmy $datasource = \"DBI:blah:blah\";\nmy $username = \"user\";\nmy $password = \"pass\";\nmy $attr = { RaiseError=>1 ,AutoCommit=>1 };\nApache::DBI->connectoninit($datasource, $username, $password, $attr);\nApache::DBI->setPingTimeOut($datasource, 0);\n\nHow come a certain piece of Perl code runs fine under \"regular\" perl, but fails under Mason?\nMason is usually a red herring in this situation. Mason IS \"regular\" perl, with a very simple\nsystem to translate Mason component syntax to Perl code. You can look at the object files Mason\ncreates for your components (in the obj/ subdirectory of the Mason data directory) to see the\nactual Perl code Mason generates.\n\nIf something suddenly stops working when you place it in a Mason environment, the problem is far\nmore likely to rest with the following environmental changes than with Mason itself:\n\n* With modperl, the server is running under a different user/group and thus has different\npermissions for the resource you're trying to access\n\n* With modperl, code can stay resident in the perl interpreter for a long time.\n\n* Your headers may be sent differently under modperl than under your previous CGI situation (or\nwhatever it was)\n\nMason does not have anything to do with sending mail, or accessing a database, or maintaining\nuser accounts, or server authentication, so if your problems are in areas like these, your time\nwill be better spent looking at other environmental changes like the ones mentioned above.\n\nI'm using HTML::Mason::!ApacheHandler and I have declinedirs disabled and am using a dhandler to handle directory requests. But when a request comes in without the final slash after the directory name, relative links are broken. What gives?\nMason has always incorrectly handled such directory requests; this issue will be resolved in the\n1.3 release. The reason it will only be fixed in the next major version is that some folks may\nhave come to rely on this functionality. So it's considered breaking backwards compatibility.\nBut if you need it to do the right thing now, fear not! There are a number of workarounds to\nensure that Apache adds a slash and redirects the browser to the appropriate URL. See\nHandlingDirectoriesWithDhandlers for all the juicy details.\n\nUPGRADING TO 1.1x\n\nAfter upgrading, I see this error whenever I load a page: \"The following parameter was passed in the call to HTML::Mason::Component::FileBased->new() but was not listed in the validation options: createtime\"\nDelete all of your object files.\n\nWhen I try to start my server I see an error like: \"The resolver class your Interp object uses does not implement the apacherequesttocomppath' method.\nThis means that ApacheHandler cannot resolve requests.\n\nAre you using a handler.pl file created before version 1.10? Please see the handler.pl sample\nthat comes with the latest version of Mason.\n\nYou are explicitly creating an Interp object in your handler.pl and then passing that to\nApacheHandler->new.\n\nInstead, simply pass all of your Interp parameters to ApacheHandler->new directly. The\nparameters will end up going where they belong.\n\nWhen I start Apache (or try to use Mason) I get an error like this: \"The Parser module is no longer a part of HTML::Mason.  Please see the Lexer and Compiler modules, its replacements.\"\nThe Parser module is no longer used.\n\nI get an error like: \"The following parameters were passed in the call to HTML::Mason::Container::new but were not listed in the validation options: errorformat errormode requestclass resolverclass\" when using ApacheHandler\nDo you have PerlFreshRestart turned on? Turn it off.\n\nSee http://perl.apache.org/docs/1.0/guide/troubleshooting.html - \"Evil things might happen when\nusing PerlFreshRestart\".\n\nI get an error like this: 'Can't locate object method \"makeah\"\npackage \"Apache\"' === We're not kidding. PerlFreshRestart is evil. Turn it off. See question\nabove.\n\nI get: \"Unknown config item 'comproot'\" or \"Unknown config item 'comproot'\" or something similar with ApacheHandler.\nTurn PerlFreshRestart off. Really.\n\nI get this with a custom handler.pl: 'Can't call method \"handlerequest\" on an undefined value at ...'\nJust in case you weren't convinced that PerlFreshRestart is a bad idea, this should help\nconvince you.\n\nAfter upgrading, I get this error for all my components: '<%' without matching '%>' ...\nThe \"perl' prefix for Mason tags, like <%perlargs>, is no longer supported. Remove this\nprefix.\n"
                }
            ]
        },
        "WHERE TO FIND INFORMATION": {
            "content": "Where do I obtain HTML::Mason?\nHTML::Mason is available from CPAN (the Comprehensive Perl Archive Network). Details about CPAN\nare available at http://www.perl.com/. See the [FAQ:Installation] section of this document for\ntips on obtaining and installing Mason.\n\nWhere can I ask questions about HTML::Mason?\nSee ContactUs and MailingLists.\n",
            "subsections": []
        }
    },
    "summary": "HTML::Mason::FAQ - Frequently asked questions  AUTOHANDLERS, METHODS, ATTRIBUTES, INHERITANCE Can I set a page's inheritance dynamically at request time (e.g. based on URL arguments)? No. Inheritance is a fixed property of a component, determined once when the component is loaded. Dynamic inheritance is on the todo list.  How can I tell Mason to use autohandlers or dhandlers when calling one component from another component (i.e. internal redirect)? Usually this situation arises when a top-level component makes a run-time decision to use a second component as the \"real\" page, and calls it via <& &> or $m->comp.  Autohandlers and dhandlers are only triggered for the top-level component of a request. In 1.1, you can use an Apache internal redirect or a Mason subrequest ($m->subexec) to solve the problem.  I added a simple autohandler to a directory and now my pages don't appear. Make sure to include a call to $m->callnext somewhere in the autohandler.  Where does a dhandler inherit from? Can I change it to inherit based on the URL path? A dhandler's inheritance is determined by its location in the hierarchy, not by the URL that invoked it.  Consider a site with the following components:  /autohandler /dhandler /products/autohandler  and suppose a request comes in for /products/index.html. /dhandler will handle the request but will still inherit from /autohandler.  This is not always the desired behavior, but there is no easy way to change it. If you want /products/* requests to use /products/autohandler, you'll need to create /products/dhandler as well.  Can I change the value of an attribute dynamically, based on the request? No, attributes are static. The closest thing to a dynamic attribute is a method. If you've been using an attribute widely and don't want to change it to a method everywhere, consider using an attribute/method combination. Suppose your attribute is called 'bgcolor'. Create a default method called 'bgcolor' in the autohandler:  <%method bgcolor> <%init> return $m->basecomp->attr('bgcolor'); <%init> </%method>  Then replace every other  $m->basecomp->attr('bgcolor');  with  $m->basecomp->callmethod('bgcolor')  or  <& SELF:bgcolor &>  Now you can leave the attribute definitions alone, but define a method if and when you need a dynamically computed value.",
    "flags": [],
    "examples": [],
    "see_also": []
}