{
    "mode": "perldoc",
    "parameter": "CGI::FormBuilder::Source",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/CGI%3A%3AFormBuilder%3A%3ASource/json",
    "generated": "2026-07-05T13:45:23Z",
    "synopsis": "# Define a source adapter\npackage CGI::FormBuilder::Source::Whatever;\nsub new {\nmy $self  = shift;\nmy $class = ref($self) || $self;\nmy %opt   = @;\nreturn bless \\%opt, $class;\n}\nsub parse {\nmy $self = shift;\nmy $file = shift || $self->{source};\n# open the file and parse it, or whatever\nmy %formopt;\nopen(F, \"<$file\") || die \"Can't read $file: $!\";\nwhile (<F>) {\n# ... do stuff to the line ...\n$formopt{$fboption} = $fbvalue;\n}\n# return hash of $form options\nreturn wantarray ? %formopt : \\%formopt;\n}",
    "sections": {
        "NAME": {
            "content": "CGI::FormBuilder::Source - Source adapters for FormBuilder\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "# Define a source adapter\n\npackage CGI::FormBuilder::Source::Whatever;\n\nsub new {\nmy $self  = shift;\nmy $class = ref($self) || $self;\nmy %opt   = @;\nreturn bless \\%opt, $class;\n}\n\nsub parse {\nmy $self = shift;\nmy $file = shift || $self->{source};\n\n# open the file and parse it, or whatever\nmy %formopt;\nopen(F, \"<$file\") || die \"Can't read $file: $!\";\nwhile (<F>) {\n# ... do stuff to the line ...\n$formopt{$fboption} = $fbvalue;\n}\n\n# return hash of $form options\nreturn wantarray ? %formopt : \\%formopt;\n}\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This documentation describes the usage of FormBuilder sources, as well as how to write your own\nsource adapter.\n\nAn external source is invoked by using the \"source\" option to the top-level \"new()\" method:\n\nmy $form = CGI::FormBuilder->new(\nsource => 'sourcefile.conf'\n);\n\nThis example points to a filename that contains a file following the\n\"CGI::FormBuilder::Source::File\" layout. Like with the \"template\" option, you can also specify\n\"source\" as a reference to a hash, allowing you to use other source adapters:\n\nmy $form = CGI::FormBuilder->new(\nfields => \\@fields,\nsource => {\ntype => 'File',\nsource => '/path/to/source.conf',\n}\n);\n\nThe \"type\" option specifies the name of the source adapter. Currently accepted types are:\n\nFile  -  CGI::FormBuilder::Source::File\n\nIn addition to one of these types, you can also specify a complete package name, in which case\nthat module will be autoloaded and its \"new()\" and \"parse()\" routines used. For example:\n\nmy $form = CGI::FormBuilder->new(\nfields => \\@fields,\nsource => {\ntype => 'My::Source::Module',\nsomefile => '/path/to/source.conf',\n}\n);\n\nAll other options besides \"type\" are passed to the constructor for that source module verbatim,\nso it's up to you and/or the source module on how these additional options should be handled.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "CGI::FormBuilder, CGI::FormBuilder::Source::File,\n",
            "subsections": []
        },
        "REVISION": {
            "content": "$Id: Source.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::Source - Source adapters for FormBuilder",
    "flags": [],
    "examples": [],
    "see_also": []
}