########################################################################### # Copyright (c) Nate Wiger http://nateware.com. All Rights Reserved. # Please visit http://formbuilder.org for tutorials, support, and examples. ########################################################################### package CGI::FormBuilder::Source; =head1 NAME CGI::FormBuilder::Source - Source adapters for FormBuilder =head1 SYNOPSIS # Define a source adapter package CGI::FormBuilder::Source::Whatever; sub new { my $self = shift; my $class = ref($self) || $self; my %opt = @_; return bless \%opt, $class; } sub parse { my $self = shift; my $file = shift || $self->{source}; # open the file and parse it, or whatever my %formopt; open(F, "<$file") || die "Can't read $file: $!"; while () { # ... do stuff to the line ... $formopt{$fb_option} = $fb_value; } # return hash of $form options return wantarray ? %formopt : \%formopt; } =cut use strict; use warnings; no warnings 'uninitialized'; our $VERSION = '3.10'; warn __PACKAGE__, " is not a real module, please read the docs\n"; 1; __END__ =head1 DESCRIPTION This documentation describes the usage of B sources, as well as how to write your own source adapter. An external source is invoked by using the C option to the top-level C method: my $form = CGI::FormBuilder->new( source => 'source_file.conf' ); This example points to a filename that contains a file following the C layout. Like with the C