[Perl] Split lines into array - variable line items - variable no of lines.
Hi,
I have the following lines that I would like to see in an array for easy comparisons and printing:
Example 1:
Example 2:
So, the number of lines, the number of fields and the field order can differ.
As output I would like to see:
Those to be printed fields and values are always present, independent from the number of fields and the field order.
And field1 and value1 are always on the first place.
The background is that has to run on different systems and those different systems will deliver different field numbers and field order.
I started with something like this, but got stuck somehow due to a lack of Perl knowledge.
Would it have been a more static input then I it would be a bit more easier.
I would appreciate any kind of assistance.
ejdv
Last edited by Scott; 09-27-2011 at 10:54 AM..
Reason: Please use code tags for code
i have these values inside variable $blah
BUNGA TERATAI 3 5055 ITH 1 0 0 0 1 1
JADE TRADER 143W ITH 4 0 0 0 4 4
MOL SPLENDOR 0307A ITH 3 0 0 0 3 3
so how do I split them into array with the... (4 Replies)
Hi all,
I have a file with little blocks beginning with a number 761XXXXXX, and 0, 1, 2 or 3 lines below of it beginning with STUS as follow:
761625820
STUS ACTIVE 16778294
STUS NOT ACTIVE
761157389
STUS ACTIVE 16778294
761554921
STUS ACTIVE 16778294
STUS NOT ACTIVE
STUS ACTIVE OP... (4 Replies)
Dear All,
I want to split single line into two line or three lines wherever “|” separated values comes using
Input line
test,DEMTEMPUT20100404010012,,,,,,,,|0070086|0070087,
output shoule be
test,DEMTEMPUT20100404010012,,,,,,,,0070086,
test,DEMTEMPUT20100404010012,,,,,,,,0070087, (14 Replies)
Hi,
I have a file which contains 1000's of lines. Each line is a log which is pretty long. So i want to split the each line based on 3 category.
1> Date
2><REQUEST>
3><RESPONSE>
So below is the example of a line.
2010-11-16 00:45:12,314<REQUEST><VALIDATION-ERROR><soapenv:Envelope... (16 Replies)
im having an array @check which contains text ..i want to open the array and i have to delete lines starting from a word called "check1" till "check2"
for eg:-
check1 Use descriptive titles when posting. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt".... (0 Replies)
Hi
I have stored a command output in an array like below
@a = `xyz`;
actually xyz comnad will give the output like this
tracker
date
xxxxxxx
xxxxxxx
---------------------
1 a
2 b
----------------------
i have stored the "xyz" output to an... (3 Replies)
Hi, This might be simple question. But i couldn't find the answer.
#$ra is having a value which i have got from some other file
I want the first occurrence of the line having the value that is in variable "$ra"
This is what i have tried.
while ( $iop = <TST>)
{
if($iop =~ /$ra/)
{
... (6 Replies)
Example input:
John:Shepherd:770-767-4040:U.S.A:New York
Mo Jo:Jo Jo: 666-666-6666:U.S.A:Townsville
Expected Output:
First Name: John
Last Name: Shepherd
Phone Number: 770-767-4040
Country: U.S.A
State: New York
First Name: Mo Jo
Last Name: Jo Jo
Phone Number: 666-666-6666... (10 Replies)
Hi,
I need help to split any lines that contain ; or ,
input.txtAc020 Not a good chemical process
AC030 many has failed, 3 still maintained
AC040 Putative; epithelial cells
AC050 Predicted binding activity
AC060 rodC Putative; upregulated in 48;h biofilm vs planktonic
The output... (8 Replies)
Hi All,
Greetings everyone !!!
I have a file which has many lines, out of which one line is as below.
I need to search for pattern "varchar(30) Select" and if exists, then split the line as below.
I am trying to achieve this in ksh. Can anyone help me on this. (8 Replies)
Discussion started by: Pradhikshan
8 Replies
LEARN ABOUT OSX
comm
COMM(1) BSD General Commands Manual COMM(1)NAME
comm -- select or reject lines common to two files
SYNOPSIS
comm [-123i] file1 file2
DESCRIPTION
The comm utility reads file1 and file2, which should be sorted lexically, and produces three text columns as output: lines only in file1;
lines only in file2; and lines in both files.
The filename ``-'' means the standard input.
The following options are available:
-1 Suppress printing of column 1.
-2 Suppress printing of column 2.
-3 Suppress printing of column 3.
-i Case insensitive comparison of lines.
Each column will have a number of tab characters prepended to it equal to the number of lower numbered columns that are being printed. For
example, if column number two is being suppressed, lines printed in column number one will not have any tabs preceding them, and lines
printed in column number three will have one.
The comm utility assumes that the files are lexically sorted; all characters participate in line comparisons.
ENVIRONMENT
The LANG, LC_ALL, LC_COLLATE, and LC_CTYPE environment variables affect the execution of comm as described in environ(7).
EXIT STATUS
The comm utility exits 0 on success, and >0 if an error occurs.
SEE ALSO cmp(1), diff(1), sort(1), uniq(1)STANDARDS
The comm utility conforms to IEEE Std 1003.2-1992 (``POSIX.2'').
The -i option is an extension to the POSIX standard.
HISTORY
A comm command appeared in Version 4 AT&T UNIX.
BUGS
Input lines are limited to LINE_MAX (2048) characters in length.
BSD January 26, 2005 BSD