File-handle or format variables

These are the special variables that are used for file or related operations. These need not be mentioned explicitly as they are initialized on successful file opening. Moreover each file-handle holds its own set of values.

Some File handle or format variables are listed below:

1. $|
2. $%
3. $=
4. $-
5. $~
6. $^
7. $:
8. $^L

1. $|
This variable is basically used for output buffering. This flag determines whether buffering should be performed on programs input/output and on file read/write operations. If value is set to 1 ($| = 1), then buffering is enabled.

2. $%
This variable holds the current page number of the output channel that is being selected.

3. $=
This variable holds the current page length. The default being set to 60. This is measured in number of printable lines. This variable is useful in page formatting operations. If the page length increases than the current size then page formatting is applied.

4. $-
This holds the number of lines left on a given page to be printed. It basically gives the number of blank lines. For every line print its value is internally decremented. One can continuously check its value for a page break.

5. $~
It holds the name of the current report format name. The default is the file-handle name.

6. $^
This variable holds the name at the top of the page format.

7. $:
Holds the set of characters by which a string may be broken to fill continuation fields in a format. The defaults is ‘\n-’ to break on white spaces or hyphens.

8. $^L
Holds a character that is used by a format’s output to request a form feed. Defaults is \f.

This entry was posted in Perl. Bookmark the permalink.

Leave a Reply