Hello,
I am trying to output the values in an array to a file. The output needs to be formated such that each array value is left jusified in a field 8 character spaces long. Also, no more than 6 fields on a line. For example:
@array= 1..14;
Needs to be output to the file like so:
1 ... (4 Replies)
Hello everybody, I'm new in this forum.
I searched a long time for a solution for my problem but I didn't find the right thing.
I have to read from a file (content is "abngjm" without any other signs) and have to write this content in an array. But every sign has to be called by its own... (5 Replies)
Hi,
Is there any way I can grep an array against another array?
Basically here's what I need to do.
There will be an array containing some fixed texts and I have to check whether some files contain these lines. Reading the same files over and over again for each different pattern doesnt seem... (1 Reply)
Hi Everyone,
#!/usr/bin/perl
use strict;
use warnings;
my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d");
would like to split the @test array into two array:
@test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d");
means search for 3rd filed.
Thanks
find the... (0 Replies)
Iam trying to load the full path of multiplie files in the same directory to an array if the filenames matches a pattern. The following is the current code;
where $input=C:\test
# change to and open the comparison directory
chdir("$input2") || die "Cannot change dir: $!";
opendir(DIR2,... (2 Replies)
I have an array and two variables as below,
I need to check if $datevar is present in $filename.
If so, i need to replace $filename with the values in the array.
I need the output inside an ARRAY
How can this be done.
Any help will be appreciated. Thanks in advance. (2 Replies)
Hello Guru's
I want to read an array into a flatfile
Please let me know how to do the same
So far this the below code
use strict;
use warnings;
open (my $data , '<', $ARGV)|| die "could not open $ARGV:\n$!";
my @array=(<$data>);
my @sorted=sort... (8 Replies)
I wrote a simply perl that searched a file for a particualr value and if it found it, rite it and the next three lines to a file. Now I have been asked to check those next three lines for a different value and only write those lines if it finds the second value.
I was thinking the best way to... (1 Reply)
ok, so here is the issue, I have 2 arrays.
I need to be able to create a loop that will find ${ARRAY1 in the text doc, and replace it with ${ARRAY2 then write the results. I already have that working. The problem is, I need it to do that same result across however many items are in the 2... (2 Replies)
Discussion started by: gentlefury
2 Replies
LEARN ABOUT DEBIAN
array::printcols
PrintCols(3pm) User Contributed Perl Documentation PrintCols(3pm)NAME
print_cols, format_cols - Print or format array elements in vertically sorted columns.
SYNOPSIS
"use Array::PrintCols;"
"print_cols @array;"
"print_cols @array, $colspec;"
"print_cols @array, $colspec, $total_width;"
"print_cols @array, $colspec, $total_width, $indent;"
$output = "format_cols" <same arguments as "print_cols">;
"$Array::PrintCols::PreSorted = 0;"
DESCRIPTION
This module exports two subroutine names: "print_cols" and "format_cols".
The "print_cols" subroutine prints the items of "@array" in multiple, alphabetically sorted vertical columns. 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.
If "$colspec" is 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 "$colspec" is 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.
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, or 80.
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.
The routine "format_cols" is called exactly like "print_cols" but returns the formatted result as a string, rather than printing it.
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;
AUTHOR
Copyright (C) 1995-1998 Alan K. Stebbens <aks@sgi.com>
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 2 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, write to the Free Software Foundation,
Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
BUGS
With Perl, you cannot default intervening arguments by leaving them empty; you must supply a zero or empty-string ('').
perl v5.10.0 2008-05-12 PrintCols(3pm)