Sponsored Content
Top Forums Shell Programming and Scripting Perl Array Variables to be returned to main Post 302330377 by Raynon on Wednesday 1st of July 2009 04:26:32 AM
Old 07-01-2009
Hi prasperl,

May i know if the below code is added , will it set all the rest of the base array index to 1 or does it just apply to the particular array @Marks only ?

Code:
$[ = 1;

Another question is that my "reports_${counting}_${_[0]}.txt" file has the below contents, however if i put the index to be the below in red, i would NOT be able to capture the correct $lotsuffix variable ? Why is this so ?

Code:
LOTSUFFIX1= AAAAA
LOTSUFFIX2= BBBBBB
LOTSUFFIX3= NIL
LOTSUFFIX4= NIL
LOTSUFFIX5= NIL
LOTSUFFIX6= NIL
LOTSUFFIX7= NIL
LOTSUFFIX8= NIL
LOTSUFFIX9= NIL
LOTSUFFIX10= NIL

DATE1= 29-Jun
DATE2= 29-Jun
DATE3=
DATE4=
DATE5=
DATE6=
DATE7=
DATE8=
DATE9=
DATE10=

Code:
my @Fld = split(' ', $line );
if ( $Fld[0] eq 'LOTSUFFIX=' ) {
          $lotsuffix[$counting] = $Fld[1];
          print "$lotsuffix[$counting]\n";
}


Last edited by Raynon; 07-01-2009 at 05:41 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl: storing regex in array variables trouble

hi this is an example of code: use strict; use warnings; open FILE, "/tmp/result_2"; my $regex="\\ Starting program ver. (.*)"; my $res="Program started, version <$1> - OK.\n"; while (<FILE>) { if ($_ =~ /($regex)/) { print "$res"; } } close FILE; This finds $regex and print... (3 Replies)
Discussion started by: xist
3 Replies

2. Shell Programming and Scripting

'who' command -- getting data returned into variables (in bash)

Anyone know how to get the data out of the "who" command? I'm still in lukewarm pursuit of creating an OS X-like welcome message at the start of any Terminal session, sans having to use either bash login or calling up ssh. My trials & errors and surfing around have narrowed it down for me... (1 Reply)
Discussion started by: SilversleevesX
1 Replies

3. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

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)
Discussion started by: jimmy_y
0 Replies

4. Shell Programming and Scripting

Perl, searching multiple files and printing returned line to new file

I am trying to find a way to utilise the full potential of my cpu cores and memory on my windows machine. Now, I am quite familiar with grep, however, running a Unix based OS is not an option right now. Unfortunately, the 32 bit grep for windows that I am running, I cannot run multiple... (1 Reply)
Discussion started by: Moloch
1 Replies

5. Shell Programming and Scripting

How to get the main node name in xml using perl?

Hi, I am having an conf file like this: <Main> <NODE> <NODENAME>FRUITS</NODENAME> <NAME>APPLE</NAME> <COLOUR>RED</COLOUR> <NODE> <IsWrapper/> <NODENAME>SEASONAL</NODENAME> <NODE> <NAME>MANGO</NAME> <COLOUR>GREEN</COLOUR> </NODE> </NODE>... (4 Replies)
Discussion started by: vanitham
4 Replies

6. Shell Programming and Scripting

Help in separating variables declared in the main function

Hi! I've a C program as shown below.. The line numbers and the statements of the program are separated by a space.. 1 #include<stdio.h> 2 char a,b,c; 3 float x,y,z; 4 int main() 5 { 6 int d,e,f; 7 // further declarations 8 // further declarations 9 /* body*/ 10 } 11 void fun1() 12... (1 Reply)
Discussion started by: abk07
1 Replies

7. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

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)
Discussion started by: irudayaraj
2 Replies

8. UNIX for Dummies Questions & Answers

[ksh93+] Array fed by function is empty when used in main.

I feel that i am missing something obvious but i can't find what is wrong. I have a script that is launching some functions with "&" and each call is feeding the array with a value. When all calls are finished I just want to retrieve the values of that array. It is looking like that : ... (5 Replies)
Discussion started by: bibou25
5 Replies

9. Shell Programming and Scripting

Perl: How to avoid warnings for superfluous values returned?

Hi all, a question for the Perl knowledgeable: I have use warnings; enabled. I use something like: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); In the further code I only work with some of the returned variables, as the others I have no need for. Though the... (1 Reply)
Discussion started by: zaxxon
1 Replies

10. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies
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)
All times are GMT -4. The time now is 04:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy