a2p
accept
access
acct
addftinfo
addr2line
adjtime
afmtodit
after
aio_cancel
aio_error
aio_read
aio_return
aio_suspend
aio_waitcomplete
aio_write
alias
aliases
alloc
anvil
append
apply
apropos
ar
array
as
asa
asn1parse
at
atq
atrm
attemptckalloc
attemptckrealloc
authlib
authtest
autopoint
awk
b64decode
b64encode
basename
batch
bc
bdes
bell
bg
bgerror
biff
big5
binary
bind
bindkey
bindtags
bindtextdomain
bio
bitmap
blowfish
bn
bootparams
bootptab
bounce
brandelf
break
breaksw
brk
bsdiff
bsdtar
bsnmpd
bspatch
bthost
btsockstat
buffer
builtin
builtins
bunzip2
button
byacc
bzcat
bzegrep
bzfgrep
bzgrep
bzip2
c2ph
c89
c99
ca
cal
calendar
canvas
cap_mkdb
case
cat
catch
catman
cc
cd
cdcontrol
chdir
checkbutton
checknr
chflags
chfn
chgrp
chio
chkey
chmod
chown
chpass
chroot
chsh
ci
ciphers
ckalloc
ckdist
ckfree
ckrealloc
cksum
cleanup
clear
clipboard
clock
clock_getres
clock_gettime
clock_settime
close
cmp
co
col
colcrt
colldef
colors
colrm
column
comm
command
compile_et
complete
compress
concat
config
connect
console
continue
core
courierlogger
couriertcpd
cp
cpan
cpio
cpp
creat
crl
crontab
crunchgen
crunchide
crypt
crypto
csh
csplit
ctags
ctm
ctm_dequeue
ctm_rmail
ctm_smail
cu
cursor
cursors
cut
cvs
date
dbiprof
dbiproxy
dc
dcgettext
dcngettext
dd
dde
default
defer
deliverquota
des
destroy
devfs
df
dgettext
dgst
dh
dhparam
dialog
diff
diff3
dig
dir
dirent
dirname
dirs
discard
disktab
dngettext
do
domainname
done
dprofpp
dsa
dsaparam
dtmfdecode
du
dup
dup2
eaccess
ec
ecdsa
echo
echotc
ecparam
ed
edit
editrc
ee
egrep
elf
elfdump
elif
else
enc
enc2xs
encoding
end
endif
endsw
engine
enigma
entry
env
envsubst
eof
eqn
err
errno
error
errstr
esac
ethers
euc
eui64
eval
event
evp
ex
exec
execve
exit
expand
export
exports
expr
extattr
extattr_delete_fd
extattr_delete_file
extattr_get_fd
extattr_get_file
extattr_set_fd
extattr_set_file
f77
false
famm
famx
fblocked
fbtab
fc
fchdir
fchflags
fchmod
fchown
fcntl
fconfigure
fcopy
fdescfs
fdformat
fdread
fdwrite
fetch
fg
fgrep
fhopen
fhstat
fhstatfs
fi
file
file2c
fileevent
filename
filetest
find
find2perl
finger
flex
flock
flush
fmt
focus
fold
font
fontedit
for
foreach
fork
format
forward
fpathconf
frame
from
fs
fstab
fstat
fstatfs
fsync
ftp
ftpchroot
ftpusers
ftruncate
futimes
g711conv
gb2312
gb18030
gbk
gcc
gcore
gcov
gdb
gencat
gendsa
genrsa
gensnmptree
getconf
getdents
getdirentries
getdtablesize
getegid
geteuid
getfacl
getfh
getfsstat
getgid
getgroups
getitimer
getlogin
getopt
getopts
getpeername
getpgid
getpgrp
getpid
getppid
getpriority
getresgid
getresuid
getrlimit
getrusage
gets
getsid
getsockname
getsockopt
gettext
gettextize
gettimeofday
gettytab
getuid
glob
global
gmake
goto
gperf
gprof
grab
grep
grid
grn
grodvi
groff
groff_font
groff_out
groff_tmac
grog
grolbp
grolj4
grops
grotty
group
groups
gunzip
gzcat
gzexe
gzip
h2ph
h2xs
hash
hashstat
hd
head
help2man
hesinfo
hexdump
history
host
hostname
hosts
hosts_access
hosts_options
hpftodit
http
hup
i386_get_ioperm
i386_get_ldt
i386_set_ioperm
i386_set_ldt
i386_vm86
iconv
id
ident
idprio
if
ifnames253
ifnames259
image
imapd
incr
indent
indxbib
info
infokey
inode
install
instmodsh
interp
intro
introduction
ioctl
ipcrm
ipcs
ipf
ipftest
ipnat
ippool
ipresend
issetugid
jail
jail_attach
jobid
jobs
join
jot
kbdcontrol
kbdmap
kcon
kdestroy
kdump
kenv
kevent
keycap
keylogin
keylogout
keymap
keysyms
kgdb
kill
killall
killpg
kinit
kldfind
kldfirstmod
kldload
kldnext
kldstat
kldsym
kldunload
klist
kpasswd
kqueue
kse
kse_create
kse_exit
kse_release
kse_switchin
kse_thr_interrupt
kse_wakeup
ktrace
label
labelframe
lam
lappend
last
lastcomm
lastlog
lchflags
lchmod
lchown
ld
ldap
ldapadd
ldapcompare
ldapdelete
ldapmodify
ldapmodrdn
ldappasswd
ldapsearch
ldapwhoami
ldd
leave
less
lesskey
lex
lgetfh
lhash
libnetcfg
library
limit
limits
lindex
link
linprocfs
linsert
lint
lio_listio
list
listbox
listen
lj4_font
lkbib
llength
lmtp
ln
load
loadfont
local
locale
locate
lock
lockf
log
logger
login
logins
logname
logout
look
lookbib
lorder
lower
lp
lpq
lpr
lprm
lptest
lrange
lreplace
ls
lsearch
lseek
lset
lsort
lstat
lsvfs
lutimes
lynx
m4
madvise
magic
mail
maildiracl
maildirkw
maildirmake
mailq
mailx
make
makeinfo
makewhatis
man
manpath
master
mc
mcedit
mcview
md2
md4
md5
mdc2
memory
menu
menubar
menubutton
merge
mesg
message
mincore
minherit
minigzip
mkdep
mkdir
mkfifo
mkimapdcert
mklocale
mknod
mkpop3dcert
mkstr
mktemp
mlock
mlockall
mmap
mmroff
modfind
modfnext
modnext
modstat
moduli
more
motd
mount
mprotect
mptable
msdos
msdosfs
msgattrib
msgcat
msgcmp
msgcomm
msgconv
msgen
msgexec
msgfilter
msgfmt
msggrep
msginit
msgmerge
msgs
msgunfmt
msguniq
mskanji
msql2mysql
msync
mt
munlock
munlockall
munmap
mv
myisamchk
myisamlog
myisampack
mysql
mysqlaccess
mysqladmin
mysqlbinlog
mysqlcheck
mysqld
mysqldump
mysqld_multi
mysqld_safe
mysqlhotcopy
mysqlimport
mysqlshow
mysql_config
mysql_fix_privilege_tables
mysql_zap
namespace
nanosleep
nawk
nc
ncal
ncplist
ncplogin
ncplogout
neqn
netconfig
netgroup
netid
netstat
networks
newaliases
newgrp
nex
nfsstat
nfssvc
ngettext
nice
nl
nm
nmount
nohup
nologin
notify
nroff
nseq
nslookup
ntp_adjtime
ntp_gettime
nvi
nview
objcopy
objdump
objformat
ocsp
od
onintr
open
openssl
opieaccess
opieinfo
opiekey
opiekeys
opiepasswd
option
options
oqmgr
pack
package
packagens
pagesize
palette
pam_auth
panedwindow
parray
passwd
paste
patch
pathchk
pathconf
pawd
pax
pbm
pcre
pcreapi
pcrebuild
pcrecallout
pcrecompat
pcrecpp
pcregrep
pcrematching
pcrepartial
pcrepattern
pcreperform
pcreposix
pcreprecompile
pcresample
pcretest
perl
perl56delta
perl58delta
perl561delta
perl570delta
perl571delta
perl572delta
perl573delta
perl581delta
perl582delta
perl583delta
perl584delta
perl585delta
perl586delta
perl587delta
perl588delta
perl5004delta
perl5005delta
perlaix
perlamiga
perlapi
perlapio
perlapollo
perlartistic
perlbeos
perlbook
perlboot
perlbot
perlbs2000
perlbug
perlcall
perlcc
perlce
perlcheat
perlclib
perlcn
perlcompile
perlcygwin
perldata
perldbmfilter
perldebguts
perldebtut
perldebug
perldelta
perldgux
perldiag
perldoc
perldos
perldsc
perlebcdic
perlembed
perlepoc
perlfaq
perlfaq1
perlfaq2
perlfaq3
perlfaq4
perlfaq5
perlfaq6
perlfaq7
perlfaq8
perlfaq9
perlfilter
perlfork
perlform
perlfreebsd
perlfunc
perlglossary
perlgpl
perlguts
perlhack
perlhist
perlhpux
perlhurd
perlintern
perlintro
perliol
perlipc
perlirix
perlivp
perljp
perlko
perllexwarn
perllinux
perllocale
perllol
perlmachten
perlmacos
perlmacosx
perlmint
perlmod
perlmodinstall
perlmodlib
perlmodstyle
perlmpeix
perlnetware
perlnewmod
perlnumber
perlobj
perlop
perlopenbsd
perlopentut
perlos2
perlos390
perlos400
perlothrtut
perlpacktut
perlplan9
perlpod
perlpodspec
perlport
perlqnx
perlre
perlref
perlreftut
perlrequick
perlreref
perlretut
perlrun
perlsec
perlsolaris
perlstyle
perlsub
perlsyn
perlthrtut
perltie
perltoc
perltodo
perltooc
perltoot
perltrap
perltru64
perltw
perlunicode
perluniintro
perlutil
perluts
perlvar
perlvmesa
perlvms
perlvos
perlwin32
perlxs
perlxstut
perror
pfbtops
pftp
pgrep
phones
photo
pic
pickup
piconv
pid
pipe
pkcs7
pkcs8
pkcs12
pkg_add
pkg_check
pkg_create
pkg_delete
pkg_info
pkg_sign
pkg_version
pkill
pl2pm
place
pod2html
pod2latex
pod2man
pod2text
pod2usage
podchecker
podselect
poll
popd
popup
posix_madvise
postalias
postcat
postconf
postdrop
postfix
postkick
postlock
postlog
postmap
postqueue
postsuper
pr
pread
preadv
printcap
printenv
printf
proc
procfs
profil
protocols
prove
proxymap
ps
psed
psroff
pstruct
ptrace
publickey
pushd
puts
pwd
pwrite
pwritev
qmgr
qmqpd
quota
quotactl
radiobutton
raise
rand
ranlib
rcp
rcs
rcsclean
rcsdiff
rcsfile
rcsfreeze
rcsintro
rcsmerge
read
readelf
readlink
readonly
readv
realpath
reboot
recv
recvfrom
recvmsg
red
ree
refer
regexp
registry
regsub
rehash
remote
rename
repeat
replace
req
reset
resolver
resource
return
rev
revoke
rfcomm_sppd
rfork
rhosts
ripemd
ripemd160
rlog
rlogin
rm
rmd160
rmdir
rpc
rpcgen
rs
rsa
rsautl
rsh
rtld
rtprio
rup
ruptime
rusers
rwall
rwho
s2p
safe
sasl
sasldblistusers2
saslpasswd2
sbrk
scache
scale
scan
sched
sched_getparam
sched_getscheduler
sched_get_priority_max
sched_get_priority_min
sched_rr_get_interval
sched_setparam
sched_setscheduler
sched_yield
scon
scp
script
scrollbar
sdiff
sed
seek
select
selection
semctl
semget
semop
send
sendbug
sendfile
sendmail
sendmsg
sendto
services
sess_id
set
setegid
setenv
seteuid
setfacl
setgid
setgroups
setitimer
setlogin
setpgid
setpgrp
setpriority
setregid
setresgid
setresuid
setreuid
setrlimit
setsid
setsockopt
settc
settimeofday
setty
setuid
setvar
sftp
sh
sha
sha1
sha256
shar
shells
shift
shmat
shmctl
shmdt
shmget
showq
shutdown
sigaction
sigaltstack
sigblock
sigmask
sigpause
sigpending
sigprocmask
sigreturn
sigsetmask
sigstack
sigsuspend
sigvec
sigwait
size
slapadd
slapcat
slapd
slapdn
slapindex
slappasswd
slaptest
sleep
slogin
slurpd
smbutil
smime
smtp
smtpd
socket
socketpair
sockstat
soelim
sort
source
spawn
speed
spinbox
spkac
splain
split
squid
squid_ldap_auth
squid_ldap_group
squid_unix_group
sscop
ssh
sshd_config
ssh_config
stab
startslip
stat
statfs
stop
string
strings
strip
stty
su
subst
sum
suspend
swapoff
swapon
switch
symlink
sync
sysarch
syscall
sysconftool
sysconftoolcheck
systat
s_client
s_server
s_time
tabs
tail
talk
tar
tbl
tclsh
tcltest
tclvars
tcopy
tcpdump
tcpslice
tcsh
tee
tell
telltc
telnet
term
termcap
terminfo
test
texindex
texinfo
text
textdomain
tfmtodit
tftp
then
threads
time
tip
tk
tkerror
tkvars
tkwait
tlsmgr
tmac
top
toplevel
touch
tput
tr
trace
trafshow
trap
troff
true
truncate
truss
tset
tsort
tty
ttys
type
tzfile
ui
ul
ulimit
umask
unalias
uname
uncomplete
uncompress
undelete
unexpand
unhash
unifdef
unifdefall
uniq
units
unknown
unlimit
unlink
unmount
unset
unsetenv
until
unvis
update
uplevel
uptime
upvar
usbhidaction
usbhidctl
users
utf8
utimes
utmp
utrace
uudecode
uuencode
uuidgen
vacation
variable
verify
version
vfork
vgrind
vgrindefs
vi
vidcontrol
vidfont
view
virtual
vis
vt220keys
vwait
w
wait
wait3
wait4
waitpid
wall
wc
wget
what
whatis
where
whereis
which
while
who
whoami
whois
window
winfo
wish
wm
write
writev
wtmp
x509
xargs
xgettext
xmlwf
xstr
xsubpp
yacc
yes
ypcat
ypchfn
ypchpass
ypchsh
ypmatch
yppasswd
ypwhich
yyfix
zcat
zcmp
zdiff
zegrep
zfgrep
zforce
zgrep
zmore
znew
_exit
__syscall
 
FreeBSD/Linux/UNIX General Commands Manual
Hypertext Man Pages
perlform
 
PERLFORM(1)	       Perl Programmers Reference Guide 	   PERLFORM(1)



NAME
       perlform - Perl formats

DESCRIPTION
       Perl has a mechanism to help you generate simple reports and charts.
       To facilitate this, Perl helps you code up your output page close to
       how it will look when it's printed.  It can keep track of things like
       how many lines are on a page, what page you're on, when to print page
       headers, etc.  Keywords are borrowed from FORTRAN: format() to declare
       and write() to execute; see their entries in perlfunc.  Fortunately,
       the layout is much more legible, more like BASIC's PRINT USING state-
       ment.  Think of it as a poor man's nroff(1).

       Formats, like packages and subroutines, are declared rather than exe-
       cuted, so they may occur at any point in your program.  (Usually it's
       best to keep them all together though.) They have their own namespace
       apart from all the other "types" in Perl.  This means that if you have
       a function named "Foo", it is not the same thing as having a format
       named "Foo".  However, the default name for the format associated with
       a given filehandle is the same as the name of the filehandle.  Thus,
       the default format for STDOUT is named "STDOUT", and the default format
       for filehandle TEMP is named "TEMP".  They just look the same.  They
       aren't.

       Output record formats are declared as follows:

	   format NAME =
	   FORMLIST
	   .

       If the name is omitted, format "STDOUT" is defined. A single "." in
       column 1 is used to terminate a format.	FORMLIST consists of a
       sequence of lines, each of which may be one of three types:

       1.  A comment, indicated by putting a '#' in the first column.

       2.  A "picture" line giving the format for one output line.

       3.  An argument line supplying values to plug into the previous picture
	   line.

       Picture lines contain output field definitions, intermingled with lit-
       eral text. These lines do not undergo any kind of variable interpola-
       tion.  Field definitions are made up from a set of characters, for
       starting and extending a field to its desired width. This is the com-
       plete set of characters for field definitions:

	  @    start of regular field
	  ^    start of special field
	  <    pad character for left adjustification
	  |    pad character for centering
	  >    pad character for right adjustificat
	  #    pad character for a right justified numeric field
	  0    instead of first #: pad number with leading zeroes
	  .    decimal point within a numeric field
	  ...  terminate a text field, show "..." as truncation evidence
	  @*   variable width field for a multi-line value
	  ^*   variable width field for next line of a multi-line value
	  ~    suppress line with all fields empty
	  ~~   repeat line until all fields are exhausted

       Each field in a picture line starts with either "@" (at) or "^"
       (caret), indicating what we'll call, respectively, a "regular" or "spe-
       cial" field.  The choice of pad characters determines whether a field
       is textual or numeric. The tilde operators are not part of a field.
       Let's look at the various possibilities in detail.

       Text Fields

       The length of the field is supplied by padding out the field with mul-
       tiple "<", ">", or "|" characters to specify a non-numeric field with,
       respectively, left justification, right justification, or centering.
       For a regular field, the value (up to the first newline) is taken and
       printed according to the selected justification, truncating excess
       characters.  If you terminate a text field with "...", three dots will
       be shown if the value is truncated. A special text field may be used to
       do rudimentary multi-line text block filling; see "Using Fill Mode" for
       details.

	  Example:
	     format STDOUT =
	     @<<<<<<   @||||||	 @>>>>>>
	     "left",   "middle", "right"
	     .
	  Output:
	     left      middle	 right

       Numeric Fields

       Using "#" as a padding character specifies a numeric field, with right
       justification. An optional "." defines the position of the decimal
       point. With a "0" (zero) instead of the first "#", the formatted number
       will be padded with leading zeroes if necessary.  A special numeric
       field is blanked out if the value is undefined.	If the resulting value
       would exceed the width specified the field is filled with "#" as over-
       flow evidence.

	  Example:
	     format STDOUT =
	     @###   @.###   @##.###  @###   @###   ^####
	      42,   3.1415,  undef,    0, 10000,   undef
	     .
	  Output:
	       42   3.142     0.000	0   ####

       The Field @* for Variable Width Multi-Line Text

       The field "@*" can be used for printing multi-line, nontruncated val-
       ues; it should (but need not) appear by itself on a line. A final line
       feed is chomped off, but all other characters are emitted verbatim.

       The Field ^* for Variable Width One-line-at-a-time Text

       Like "@*", this is a variable width field. The value supplied must be a
       scalar variable. Perl puts the first line (up to the first "\n") of the
       text into the field, and then chops off the front of the string so that
       the next time the variable is referenced, more of the text can be
       printed.  The variable will not be restored.

	  Example:
	     $text = "line 1\nline 2\nline 3";
	     format STDOUT =
	     Text: ^*
		   $text
	     ~~    ^*
		   $text
	     .
	  Output:
	     Text: line 1
		   line 2
		   line 3

       Specifying Values

       The values are specified on the following format line in the same order
       as the picture fields.  The expressions providing the values must be
       separated by commas.  They are all evaluated in a list context before
       the line is processed, so a single list expression could produce multi-
       ple list elements.  The expressions may be spread out to more than one
       line if enclosed in braces.  If so, the opening brace must be the first
       token on the first line.  If an expression evaluates to a number with a
       decimal part, and if the corresponding picture specifies that the deci-
       mal part should appear in the output (that is, any picture except mul-
       tiple "#" characters without an embedded "."), the character used for
       the decimal point is always determined by the current LC_NUMERIC
       locale.	This means that, if, for example, the run-time environment
       happens to specify a German locale, "," will be used instead of the
       default ".".  See perllocale and "WARNINGS" for more information.

       Using Fill Mode

       On text fields the caret enables a kind of fill mode.  Instead of an
       arbitrary expression, the value supplied must be a scalar variable that
       contains a text string.	Perl puts the next portion of the text into
       the field, and then chops off the front of the string so that the next
       time the variable is referenced, more of the text can be printed.
       (Yes, this means that the variable itself is altered during execution
       of the write() call, and is not restored.)  The next portion of text is
       determined by a crude line breaking algorithm. You may use the carriage
       return character ("\r") to force a line break. You can change which
       characters are legal to break on by changing the variable $: (that's
       $FORMAT_LINE_BREAK_CHARACTERS if you're using the English module) to a
       list of the desired characters.

       Normally you would use a sequence of fields in a vertical stack associ-
       ated with the same scalar variable to print out a block of text. You
       might wish to end the final field with the text "...", which will
       appear in the output if the text was too long to appear in its
       entirety.

       Suppressing Lines Where All Fields Are Void

       Using caret fields can produce lines where all fields are blank. You
       can suppress such lines by putting a "~" (tilde) character anywhere in
       the line.  The tilde will be translated to a space upon output.

       Repeating Format Lines

       If you put two contiguous tilde characters "~~" anywhere into a line,
       the line will be repeated until all the fields on the line are
       exhausted, i.e. undefined. For special (caret) text fields this will
       occur sooner or later, but if you use a text field of the at variety,
       the  expression you supply had better not give the same value every
       time forever! ("shift(@f)" is a simple example that would work.)  Don't
       use a regular (at) numeric field in such lines, because it will never
       go blank.

       Top of Form Processing

       Top-of-form processing is by default handled by a format with the same
       name as the current filehandle with "_TOP" concatenated to it.  It's
       triggered at the top of each page.  See "write" in perlfunc.

       Examples:

	# a report on the /etc/passwd file
	format STDOUT_TOP =
				Passwd File
	Name		    Login    Office   Uid   Gid Home
	------------------------------------------------------------------
	.
	format STDOUT =
	@<<<<<<<<<<<<<<<<<< @||||||| @<<<<<<@>>>> @>>>> @<<<<<<<<<<<<<<<<<
	$name,		    $login,  $office,$uid,$gid, $home
	.

	# a report from a bug report form
	format STDOUT_TOP =
				Bug Reports
	@<<<<<<<<<<<<<<<<<<<<<<<     @|||	  @>>>>>>>>>>>>>>>>>>>>>>>
	$system,		      $%,	  $date
	------------------------------------------------------------------
	.
	format STDOUT =
	Subject: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
		 $subject
	Index: @<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	       $index,			     $description
	Priority: @<<<<<<<<<< Date: @<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
		  $priority,	    $date,   $description
	From: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	      $from,			     $description
	Assigned to: @<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
		     $programmer,	     $description
	~				     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
					     $description
	~				     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
					     $description
	~				     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
					     $description
	~				     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<
					     $description
	~				     ^<<<<<<<<<<<<<<<<<<<<<<<...
					     $description
	.

       It is possible to intermix print()s with write()s on the same output
       channel, but you'll have to handle "$-" ($FORMAT_LINES_LEFT) yourself.

       Format Variables

       The current format name is stored in the variable $~ ($FORMAT_NAME),
       and the current top of form format name is in $^ ($FORMAT_TOP_NAME).
       The current output page number is stored in $% ($FORMAT_PAGE_NUMBER),
       and the number of lines on the page is in $= ($FORMAT_LINES_PER_PAGE).
       Whether to autoflush output on this handle is stored in $| ($OUT-
       PUT_AUTOFLUSH).	The string output before each top of page (except the
       first) is stored in $^L ($FORMAT_FORMFEED).  These variables are set on
       a per-filehandle basis, so you'll need to select() into a different one
       to affect them:

	   select((select(OUTF),
		   $~ = "My_Other_Format",
		   $^ = "My_Top_Format"
		  )[0]);

       Pretty ugly, eh?  It's a common idiom though, so don't be too surprised
       when you see it.  You can at least use a temporary variable to hold the
       previous filehandle: (this is a much better approach in general,
       because not only does legibility improve, you now have intermediary
       stage in the expression to single-step the debugger through):

	   $ofh = select(OUTF);
	   $~ = "My_Other_Format";
	   $^ = "My_Top_Format";
	   select($ofh);

       If you use the English module, you can even read the variable names:

	   use English '-no_match_vars';
	   $ofh = select(OUTF);
	   $FORMAT_NAME     = "My_Other_Format";
	   $FORMAT_TOP_NAME = "My_Top_Format";
	   select($ofh);

       But you still have those funny select()s.  So just use the FileHandle
       module.	Now, you can access these special variables using lowercase
       method names instead:

	   use FileHandle;
	   format_name	   OUTF "My_Other_Format";
	   format_top_name OUTF "My_Top_Format";

       Much better!

NOTES
       Because the values line may contain arbitrary expressions (for at
       fields, not caret fields), you can farm out more sophisticated process-
       ing to other functions, like sprintf() or one of your own.  For exam-
       ple:

	   format Ident =
	       @<<<<<<<<<<<<<<<
	       &commify($n)
	   .

       To get a real at or caret into the field, do this:

	   format Ident =
	   I have an @ here.
		   "@"
	   .

       To center a whole line of text, do something like this:

	   format Ident =
	   @|||||||||||||||||||||||||||||||||||||||||||||||
		   "Some text line"
	   .

       There is no builtin way to say "float this to the right hand side of
       the page, however wide it is."  You have to specify where it goes.  The
       truly desperate can generate their own format on the fly, based on the
       current number of columns, and then eval() it:

	   $format  = "format STDOUT = \n"
		    . '^' . '<' x $cols . "\n"
		    . '$entry' . "\n"
		    . "\t^" . "<" x ($cols-8) . "~~\n"
		    . '$entry' . "\n"
		    . ".\n";
	   print $format if $Debugging;
	   eval $format;
	   die $@ if $@;

       Which would generate a format looking something like this:

	format STDOUT =
	^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	$entry
		^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
	$entry
	.

       Here's a little program that's somewhat like fmt(1):

	format =
	^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
	$_

	.

	$/ = '';
	while (<>) {
	    s/\s*\n\s*/ /g;
	    write;
	}

       Footers

       While $FORMAT_TOP_NAME contains the name of the current header format,
       there is no corresponding mechanism to automatically do the same thing
       for a footer.  Not knowing how big a format is going to be until you
       evaluate it is one of the major problems.  It's on the TODO list.

       Here's one strategy:  If you have a fixed-size footer, you can get
       footers by checking $FORMAT_LINES_LEFT before each write() and print
       the footer yourself if necessary.

       Here's another strategy: Open a pipe to yourself, using "open(MYSELF,
       "|-")" (see "open()" in perlfunc) and always write() to MYSELF instead
       of STDOUT.  Have your child process massage its STDIN to rearrange
       headers and footers however you like.  Not very convenient, but doable.

       Accessing Formatting Internals

       For low-level access to the formatting mechanism.  you may use form-
       line() and access $^A (the $ACCUMULATOR variable) directly.

       For example:

	   $str = formline <<'END', 1,2,3;
	   @<<<  @|||  @>>>
	   END

	   print "Wow, I just stored `$^A' in the accumulator!\n";

       Or to make an swrite() subroutine, which is to write() what sprintf()
       is to printf(), do this:

	   use Carp;
	   sub swrite {
	       croak "usage: swrite PICTURE ARGS" unless @_;
	       my $format = shift;
	       $^A = "";
	       formline($format,@_);
	       return $^A;
	   }

	   $string = swrite(<<'END', 1, 2, 3);
	Check me out
	@<<<  @|||  @>>>
	END
	   print $string;

WARNINGS
       The lone dot that ends a format can also prematurely end a mail message
       passing through a misconfigured Internet mailer (and based on experi-
       ence, such misconfiguration is the rule, not the exception).  So when
       sending format code through mail, you should indent it so that the for-
       mat-ending dot is not on the left margin; this will prevent SMTP cut-
       off.

       Lexical variables (declared with "my") are not visible within a format
       unless the format is declared within the scope of the lexical variable.
       (They weren't visible at all before version 5.001.)

       Formats are the only part of Perl that unconditionally use information
       from a program's locale; if a program's environment specifies an
       LC_NUMERIC locale, it is always used to specify the decimal point char-
       acter in formatted output.  Perl ignores all other aspects of locale
       handling unless the "use locale" pragma is in effect.  Formatted output
       cannot be controlled by "use locale" because the pragma is tied to the
       block structure of the program, and, for historical reasons, formats
       exist outside that block structure.  See perllocale for further discus-
       sion of locale handling.

       Within strings that are to be displayed in a fixed length text field,
       each control character is substituted by a space. (But remember the
       special meaning of "\r" when using fill mode.) This is done to avoid
       misalignment when control characters "disappear" on some output media.



perl v5.8.8			  2006-01-07			   PERLFORM(1)
=19199
+517
(84)