Sponsored Content
Top Forums Shell Programming and Scripting Perl matching values in a file Post 302524148 by dynamax on Saturday 21st of May 2011 11:23:25 PM
Old 05-22-2011
Hi Chirel.

Here is the input format and expected output.

Input File -- mentioned in $chpdvlst
289B ship N-grp 123
289C ship N-grp 123
289D ship N-grp 123
2CE1 flight N-grp 123
2CE2 flight N-grp 123
2CE3 flight N-grp 123
2CE4 flight N-grp 123
2DAF flight N-grp 123
2DB0 air Y-Grp 123
299B ship N-grp 123
299C ship N-grp 123
29AD ship N-grp 123
29AB ship grp 123
29AC ship grp 123
29AD ship grp 123

OUTPUT Format
289B ===>Found in Free Pool
289C ===>Found in Free Pool
289D ===>Found in Free Pool
2DB0 ===>Found in Free Pool
299B ===>Found in Free Pool
299C ===>Found in Free Pool
29AD ===>Found in Free Pool
29AB ===>Not Found in free pool
29AC ===>Not Found in free pool
29AD ===>Not Found in free pool


I missed else statement in earlier code here is the code.

Code:
$memcnt = 5;
$passt = ship;
open (ADVOUT, "< $chpdvlst") || die ("can not open file: $chpdvlst!");
while ($LINEIN2 = <ADVOUT>)
 {
  chomp ($LINEIN2);
  ($advid, $vaht, $grp, $xsinfo) = split(' ',$LINEIN2);
   $cnt1 = 0;
  if (($passt = $grpt) && ($cnt1 < $memcnt ))
     {
    print " $advid ===>Found in Free Pool.\n";
    $cnt1++;
     }
   else
      {
        print "$adevid===>  NOT FOUND in Free Pool ---  Check Before Using\n";
      }

---------- Post updated at 11:23 PM ---------- Previous update was at 09:33 PM ----------

I mean in output I should see only first five lines

289B ===>Found in Free Pool
289C ===>Found in Free Pool
289D ===>Found in Free Pool
2DB0 ===>Found in Free Pool
299B ===>Found in Free Pool
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Identify matching data in a file and output to original line, in perl

Hi, I haven't done this for awhile, and further, I've never done it in perl so I appreciate any help you can give me. I have a file of lines, each with 5 data points that look like this: AB,N,ALLIANCEBERNSTEIN HLDNG L.P,AB,N ALD,N,ALLIED CAPITAL CORPORATION,ALD,N AFC,N,ALLIED CAPITAL... (4 Replies)
Discussion started by: Pcushing
4 Replies

2. Shell Programming and Scripting

using perl for matching one file with another file and print into new line

One file is fileA 0.0246*0.0068*0.0013*0.0023*0.0182*0.0028*0.0019*0.4750*0.0028*0.0812*0.0123*0.0018*0.0039*0.0020*0.0028*0.0047*0.0139*0.3330*0.0017*0.0072*0.4789... (4 Replies)
Discussion started by: cdfd123
4 Replies

3. Shell Programming and Scripting

PERL:How to convert numeric values txt file to PACKED DECIMAL File?

Is there any way to convert numeric values txt file to PACKED DECIMAL File using PERL. Regards, Alok (1 Reply)
Discussion started by: aloktiwary
1 Replies

4. Shell Programming and Scripting

perl -write values in a file to @array in perl

Hi can anyone suggest me how to write a file containing values,... say 19 20 21 22 .. 40 to an array @array = (19, 20, ... 40) -- Thanks (27 Replies)
Discussion started by: meghana
27 Replies

5. UNIX for Dummies Questions & Answers

PERL pattern matching in a file

Hi Gurus, I have a file like below.. I have to match each with predefined pattern. If matches then have to write the entire record to a separate file. If not make the value as NULL and write the entire record into another file. | is the delimiter ravi123|2344|M R123Vi|2345|F... (8 Replies)
Discussion started by: pvksandeep
8 Replies

6. Shell Programming and Scripting

Copy values from columns matching in those in second file.

Hi All, I have two sets of files. Set 1: 100 text files with extension .txt with names like 1.txt, 2.txt, 3.txt until 100.txt Set 2: One big file with extension .dat The text files have some records in columns like this: 0.7316431 82628 0.7248189 82577 0.7248182 81369 0.7222999... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

7. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

8. Shell Programming and Scripting

PERL: matching text between 2 values

Hi, I am trying to get a text value between 2 words in a string and assign it to a value. Basically the program should read each row in a file and return the text between 2 fields and print it to another file. My code: #!/usr/bin/perl open FAILED, "./AFile.txt"; while(<FAILED>) { ... (3 Replies)
Discussion started by: chris01010
3 Replies

9. Shell Programming and Scripting

How to find sum of any 'n' number of values from file matching target value?

I have a simple text file having payment amount value on each line. At the end of day 'n' number of payments created difference in amount that I need to match from this file. I have information about how many payments created difference and difference amount. Please help me to build shell... (3 Replies)
Discussion started by: swats007
3 Replies

10. UNIX for Beginners Questions & Answers

How do delete certain lines alone which are matching with start and end string values in file?

Hi, In my previous post ( How to print lines from a files with specific start and end patterns and pick only the last lines? ), i have got a help to get the last select statement from a file, now i need to remove/exclude the output from main file: Input File format: SELECT ABCD, DEFGH,... (2 Replies)
Discussion started by: nani2019
2 Replies
XkbKeySymEntry(3)						   XKB FUNCTIONS						 XkbKeySymEntry(3)

NAME
XkbKeySymEntry - Returns the keysym corresponding to shift level shift and group grp from the two-dimensional array of keysyms for the key corresponding to keycode SYNOPSIS
KeySym XkbKeySymEntry macro ( xkb, keycode, shift, grp ) XkbDescPtr xkb; KeyCode keycode; int shift; int grp; ARGUMENTS
- xkb Xkb description of interest - keycode keycode of interest - shift shift level of interest - grp group of interest DESCRIPTION
The key width and number of groups associated with a key are used to form a small two-dimensional array of KeySyms for a key. This array may be different sizes for different keys. The array for a single key is stored as a linear list, in row-major order. The arrays for all of the keys are stored in the syms field of the client map. There is one row for each group associated with a key and one column for each level. The index corresponding to a given group and shift level is computed as: idx = group_index * key_width + shift_level The offset field of the key_sym_map entry for a key is used to access the beginning of the array. XkbKeySymEntry returns the keysym corresponding to shift level shift and group grp from the two-dimensional array of keysyms for the key corresponding to keycode. X Version 11 libX11 1.2.1 XkbKeySymEntry(3)
All times are GMT -4. The time now is 04:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy