Array::PrintCols(3pm)
π Array::PrintCols π
okay so bestie, welcome to Array::PrintCols β that's the Array::PrintCols(3pm) page from the User Contributed Perl Documentation section, and yes she is that girl. π This lil module prints or formats array elements in vertically sorted columns. Slay. β¨
πΈ NAME πΈ
Array::PrintCols β print or format array elements in vertically sorted columns. periodt. π
β¨ SYNOPSIS β¨
"use Array::PrintCols;"
"print_cols \@array;"
"print_cols \@array, $colspec;"
"print_cols \@array, $colspec, $total_width;"
"print_cols \@array, $colspec, $total_width, $indent;"
\@array may also be an ARRAYREF, HASH, or HASHREF. π
$output = "format_cols" <same arguments as "print_cols">;
"$Array::PrintCols::PreSorted = 0;"
π¦ DESCRIPTION π¦
So this module exports two subroutine names: print_cols and format_cols. Two icons, one module. π«Ά
The print_cols subroutine prints the items of @array in multiple, alphabetically & vertically sorted columns. the way that it sorts alphabetically AND vertically?? obsessed. π And heads up: if the first argument is a HASH or HASHREF, only the keys of the hash are considered. iykyk. π
One, two, or three optional arguments may be given to print_cols to control the width and number of the columns, the total width of the output, and indentation. Reasonable defaults apply in the absence of the optional arguments (or when given as the empty string or zero). Generally, the minimum width column is used when possible. defaults eating and leaving no crumbs fr fr. π
- If
$colspecis given as a non-negative number, it is treated as the minimum width of the column; the actual width will be the maximum of this value and the lengths of all array items. - If
$colspecis given as a negative number, its absolute value value is used to determine the total number of columns. However, it cannot exceed the total number of columns possible based on the maximum length of all the array elements. she has limits, bestie. π - If a third argument is supplied, it is used as the total width of the output. The default for this value is the value of the environment variable
$ENV{'COLUMNS'}, if defined, or80. - If the fourth argument is given, it is used as the indent for all lines printed, which subtracts from the total width of the output. This value defaults to
zero(ie: no indention of the output). π
The variable $Array::PrintCols::PreSorted controls whether or not the print_cols subroutine will expect its array argument to already be sorted. If this variable is nil or zero, print_cols will cause print out a sorted copy of the input array. main character energy: she'll sort it herself, no worries. β¨
The routine format_cols is called exactly like print_cols but returns the formatted result as a string, rather than printing it. print_cols actually invokes format_cols, which does the real work. π format_cols is the one doing the heavy lifting and print_cols is just the face of the operation, honestly iconic.
π EXAMPLES π
use Array::PrintCols;
@commands = sort qw( use list put get set quit help server );
# print in three columns with an indention of 1.
print_cols \@commands, -3, 0, 1;
# print the formatted result data to the result file
print RESULTFILE format_cols(\@result_data);
look at her go π
π§ REPOSITORY π§
<https://github.com/aks/array-printcols>
go say hi, she lives there π«Ά
π AUTHOR π
Copyright (C) 1996-2014 Alan K. Stebbens <aks@stebbens.org>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
bestie read the license, I'm begging π
π BUGS π
Perl will not default intervening empty arguments; instead, use zero or the empty-string ('').
fr fr, do NOT leave a gap in your args and expect Perl to be nice about it. she won't. pass0or''and move on. π
and that's the whole page!! π she's perl v5.36.0, dated 2022-12-07, and this was the Array::PrintCols(3pm) manual β tysm for reading, bestie, you ate. πβ¨π¦πΈπ
π¦ where this page comes from
- debian bookworm: libarray-printcols-perl 2.6-4 Β· GPL-3.0-or-later
- debian trixie: libarray-printcols-perl 2.6-4 Β· GPL-3.0-or-later
- ubuntu noble: libarray-printcols-perl 2.6-4 Β· GPL-3.0-or-later
- ubuntu resolute: libarray-printcols-perl 2.6-4 Β· GPL-3.0-or-later
- ubuntu stonking: libarray-printcols-perl 2.6-4 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms