CGI::Fo...r::Util(3)
β¨ NAME β¨
okay so bestie, welcome to the manual page for CGI::FormBuilder::Util β your man viewer might squish it into CGI::Fo...r::Util(3) at the top, but that's just the header being extra π
. This module is utility functions for FormBuilder. that's the vibe.
πΈ SYNOPSIS πΈ
like, import it and then go off:
use CGI::FormBuilder::Util;
belch "Badness";
puke "Egads";
debug 2, "Debug message for level 2";
π¦ DESCRIPTION π¦
okay so this module exports some common utility functions for FormBuilder. These functions are intended for internal use, but ngl the author must admit that, from time to time, they just import this module and use some of the routines directly β like htmltag() to generate HTML. iconic honestly π
π USEFUL FUNCTIONS π
These can be used directly and are somewhat useful. Don't tell anyone I said that, though. π€«
β¨ debug($level, $string) β¨
This prints out the given string only if $DEBUG is greater than the $level specified. For example:
$CGI::FormBuilder::Util::DEBUG = 1;
debug 1, "this is printed";
debug 2, "but not this one";
A newline is automatically included, so don't provide one of your own. no cap, let it handle the line break.
π belch($string) π
A modified warn that prints out a better message with a newline added.
π puke($string) π
A modified die that prints out a useful message.
π escapeurl($string) π
Returns a properly escaped string suitable for including in URL params.
π¦ escapehtml($string) π¦
Returns an HTML-escaped string suitable for embedding in HTML tags.
β escapejs($string) β
Returns a string suitable for including in JavaScript. Minimal processing.
π htmltag($name, %attr) π
This generates an XHTML-compliant tag for the name $name based on the %attr specified. For example:
my $table = htmltag('table', cellpadding => 1, border => 0);
No routines are provided to close tags; you must manually print a closing "</table>" tag. so yes, you're printing that closing tag yourself π«Ά
π§ htmlattr($name, %attr) π§
This cleans any internal FormBuilder attributes from the specified tag. It is automatically called by htmltag().
π toname($string) π
This is responsible for the auto-naming functionality of FormBuilder. Since you know Perl, it's easiest to just show what it does:
$name =~ s!\.\w+$!!; # lose trailing ".suf"
$name =~ s![^a-zA-Z0-9.-/]+! !g; # strip non-alpha chars
$name =~ s!\b(\w)!\u$1!g; # convert _ to space/upper
This results in something like "cgi_script.pl" becoming "Cgi Script". slay.
π tovar($string) π
Turns a string into a variable name. Basically just strips "\W", and prefixes "fb_" on the front of it.
πΈ ismember($el, @array) πΈ
Returns true if $el is in @array
π USELESS FUNCTIONS π
These are totally useless outside of FormBuilder internals. rip.
π«Ά autodata($ref) π«Ά
This dereferences $ref and returns the underlying data. For example:
%hash = autodata($hashref);
@array = autodata($arrayref);
π
arghash(@_) π
This returns a hash of options passed into a sub:
sub field {
my $self = shift;
my %opt = arghash(@_);
}
It will return a hashref in scalar context.
π arglist(@_) π
This returns a list of args passed into a sub:
sub value {
my $self = shift;
$self->{value} = arglist(@_);
It will return an arrayref in scalar context.
π indent($num) π
A simple sub that returns 4 spaces x $num. Used to indent code.
β optalign(\@opt) β
This returns the options specified as an array of arrayrefs, which is what FormBuilder expects internally.
π optsort($sortref, @opt) π
This sorts and returns the options based on $sortref. It expects @opt to be in the format returned by optalign(). The $sortref spec can be the string "NAME", "NUM", or a reference to a &sub which takes pairs of values to compare.
π¦ optval($opt) π¦
This takes one of the elements of @opt and returns it split up. Useless outside of FormBuilder.
π rearrange($ref, $name) π
Rearranges arguments designed to be per-field from the global inheritor.
π§ basename π§
Returns the script name or $0 hacked up to the first dir
π SEE ALSO π
CGI::FormBuilder
π REVISION π
$Id: Util.pm 100 2007-03-02 18:13:13Z nwiger $
π AUTHOR π
Copyright (c) Nate Wiger <http://nateware.com>. All Rights Reserved.
This module is free software; you may copy this under the terms of the GNU General Public License, or the Artistic License, copies of which should have accompanied your Perl kit.
bye bestie π β source/version perl v5.42.2, date 2024-09-19, and the footer manual name is CGI::Fo...r::Util(3). mwah π
π¦ where this page comes from
- alpine 3.24: perl-cgi-formbuilder-doc 3.20-r0 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms