{
    "mode": "perldoc",
    "parameter": "CGI::FormBuilder::Util",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/CGI%3A%3AFormBuilder%3A%3AUtil/json",
    "generated": "2026-06-13T19:35:35Z",
    "synopsis": "use CGI::FormBuilder::Util;\nbelch \"Badness\";\npuke \"Egads\";\ndebug 2, \"Debug message for level 2\";",
    "sections": {
        "NAME": {
            "content": "CGI::FormBuilder::Util - Utility functions for FormBuilder\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use CGI::FormBuilder::Util;\n\nbelch \"Badness\";\npuke \"Egads\";\ndebug 2, \"Debug message for level 2\";\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module exports some common utility functions for FormBuilder. These functions are intended\nfor internal use, however I must admit that, from time to time, I just import this module and\nuse some of the routines directly (like \"htmltag()\" to generate HTML).\n",
            "subsections": []
        },
        "USEFUL FUNCTIONS": {
            "content": "These can be used directly and are somewhat useful. Don't tell anyone I said that, though.\n\ndebug($level, $string)\nThis prints out the given string only if $DEBUG is greater than the $level specified. For\nexample:\n\n$CGI::FormBuilder::Util::DEBUG = 1;\ndebug 1, \"this is printed\";\ndebug 2, \"but not this one\";\n\nA newline is automatically included, so don't provide one of your own.\n\nbelch($string)\nA modified \"warn\" that prints out a better message with a newline added.\n\npuke($string)\nA modified \"die\" that prints out a useful message.\n\nescapeurl($string)\nReturns a properly escaped string suitable for including in URL params.\n\nescapehtml($string)\nReturns an HTML-escaped string suitable for embedding in HTML tags.\n\nescapejs($string)\nReturns a string suitable for including in JavaScript. Minimal processing.\n\nhtmltag($name, %attr)\nThis generates an XHTML-compliant tag for the name $name based on the %attr specified. For\nexample:\n\nmy $table = htmltag('table', cellpadding => 1, border => 0);\n\nNo routines are provided to close tags; you must manually print a closing \"</table>\" tag.\n\nhtmlattr($name, %attr)\nThis cleans any internal FormBuilder attributes from the specified tag. It is automatically\ncalled by \"htmltag()\".\n\ntoname($string)\nThis is responsible for the auto-naming functionality of FormBuilder. Since you know Perl, it's\neasiest to just show what it does:\n\n$name =~ s!\\.\\w+$!!;                # lose trailing \".suf\"\n$name =~ s![^a-zA-Z0-9.-/]+! !g;    # strip non-alpha chars\n$name =~ s!\\b(\\w)!\\u$1!g;           # convert  to space/upper\n\nThis results in something like \"cgiscript.pl\" becoming \"Cgi Script\".\n\ntovar($string)\nTurns a string into a variable name. Basically just strips \"\\W\", and prefixes \"fb\" on the front\nof it.\n\nismember($el, @array)\nReturns true if $el is in @array\n",
            "subsections": []
        },
        "USELESS FUNCTIONS": {
            "content": "These are totally useless outside of FormBuilder internals.\n\nautodata($ref)\nThis dereferences $ref and returns the underlying data. For example:\n\n%hash  = autodata($hashref);\n@array = autodata($arrayref);\n\narghash(@)\nThis returns a hash of options passed into a sub:\n\nsub field {\nmy $self = shift;\nmy %opt  = arghash(@);\n}\n\nIt will return a hashref in scalar context.\n\narglist(@)\nThis returns a list of args passed into a sub:\n\nsub value {\nmy $self = shift;\n$self->{value} = arglist(@);\n\nIt will return an arrayref in scalar context.\n\nindent($num)\nA simple sub that returns 4 spaces x $num. Used to indent code.\n\noptalign(\\@opt)\nThis returns the options specified as an array of arrayrefs, which is what FormBuilder expects\ninternally.\n\noptsort($sortref, @opt)\nThis sorts and returns the options based on $sortref. It expects @opt to be in the format\nreturned by \"optalign()\". The $sortref spec can be the string \"NAME\", \"NUM\", or a reference to a\n&sub which takes pairs of values to compare.\n\noptval($opt)\nThis takes one of the elements of @opt and returns it split up. Useless outside of FormBuilder.\n\nrearrange($ref, $name)\nRearranges arguments designed to be per-field from the global inheritor.\n\nbasename\nReturns the script name or $0 hacked up to the first dir\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "CGI::FormBuilder\n",
            "subsections": []
        },
        "REVISION": {
            "content": "$Id: Util.pm 100 2007-03-02 18:13:13Z nwiger $\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Copyright (c) Nate Wiger <http://nateware.com>. All Rights Reserved.\n\nThis module is free software; you may copy this under the terms of the GNU General Public\nLicense, or the Artistic License, copies of which should have accompanied your Perl kit.\n",
            "subsections": []
        }
    },
    "summary": "CGI::FormBuilder::Util - Utility functions for FormBuilder",
    "flags": [],
    "examples": [],
    "see_also": []
}