Sponsored Content
Full Discussion: Perl file comparison
Top Forums Shell Programming and Scripting Perl file comparison Post 302419515 by gpaulose on Friday 7th of May 2010 11:37:49 AM
Old 05-07-2010
Perl file comparison

Hi,
I'm a newbie in perl scripting. I want to compare first 18 characters of two files using perl and write output if they matches.

FileA;
Code:
835100000000000020000000001000000.000000000.000
835100000000000120000000001000000.000000000.000
835100000000000230000000001000000.000000000.000
835100000000000300000000001000000.000000000.000
835100000000000320000000001000000.000000000.000
835100000000000380000000001000000.000000000.000
835100000000000550000000001000000.000000000.000
835100000000000570000000001000012.000000001.000

FileB:
Code:
83510000000000002020100504000002.659000002.109000002.405000002.322
83510000000000012020100504000003.838000001.563000003.157000003.183
83510000000000019020100504000012.318000006.568000013.284000012.532
83510000000000020020100504000017.733000011.877000016.389000015.547
83510000000000023020100504000016.682000007.235000016.806000016.305
83510000000000030020100504000007.200000003.739000005.465000005.673
83510000000000032020100504000007.808000004.831000007.109000007.305
83510000000000038020100504000003.857000002.357000004.302000004.302
83510000000000050800000000000000.000000000.000000000.000000000.000
83510000000000051800000000000000.000000000.000000000.000000000.000
83510000000000055020100504000002.033000002.049000001.242000001.212
83510000000000057020100504000011.232000004.801000008.807000008.978

If the first 18 characters matches, output file B.

OutputFileB:
Code:
83510000000000002020100504000002.659000002.109000002.405000002.322
83510000000000012020100504000003.838000001.563000003.157000003.183
83510000000000023020100504000016.682000007.235000016.806000016.305
83510000000000030020100504000007.200000003.739000005.465000005.673
83510000000000032020100504000007.808000004.831000007.109000007.305
83510000000000038020100504000003.857000002.357000004.302000004.302
83510000000000055020100504000002.033000002.049000001.242000001.212
83510000000000057020100504000011.232000004.801000008.807000008.978

Any help would be much appreciated.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

perl: string comparison as numbers

$name = 'Mark'; $goodguy = 'Tody'; if ($name == $goodguy) { print "Hello, Sir.\n"; } else { print "Begone, evil peon!\n"; } The output is Hello, Sir...... Even if the Mark is made to MarkSpencer.....then also it shows as Hello, Sir.... Can any one explain the... (7 Replies)
Discussion started by: bishweshwar
7 Replies

2. Shell Programming and Scripting

file comparison

hi I have 2 files to comapre ,in file a sible column it is numbers,in file b2 numbers and other values with coma separated. i want compare numbers in file a with file b,and the out put put should be in C with numbers in both file a and b along with other columns of file b. i used folowing... (7 Replies)
Discussion started by: satish.res
7 Replies

3. Shell Programming and Scripting

File Comparison- Need help

I have two text files which have records of thousand rows. Each row is having around 40 columns. Each column is tab delimited. Each row is delimited by newline character. My requirement is to find for each row i need to find whether any column is different between the two files. For each row i... (8 Replies)
Discussion started by: uihnybgte
8 Replies

4. Shell Programming and Scripting

Comparison of two files which contains strings using Shell scripting or PERL

Hi, I need sample code to compare the two files line by line which contains text strings and to print the difference in the third file. Thanks in advance (1 Reply)
Discussion started by: sudhakaryadav
1 Replies

5. Shell Programming and Scripting

Comparison of command line argument in perl

Hello All, I have passed one command line argument in my script. I want to compare that value in the script itself. Is there any way to compare the command line variable....... (3 Replies)
Discussion started by: suvenduperl
3 Replies

6. Shell Programming and Scripting

two file comparison

now i have a different file zoo.txt with content 123|zoo 234|natan 456|don and file rick.txt with contents 123|dog|pie|pep 123|tail|see|newt 456|som|sin|sim 234|pay|rat|cat i want to look for lines in file zoo.txt column1 that has same corresponding lines in column 1 of... (6 Replies)
Discussion started by: dealerso
6 Replies

7. Shell Programming and Scripting

file comparison

Dear All, I would really appreciate if you can help me to resolve this file comparison I have two files: file1: chr start end ID gene_name chr1 2020 3030 1 test1 chr1 900 5000 2 test1 chr2 5000 8000 3 test2 chr3 6000 12000 4 test3 chr3 6000 15000 5 test3 file2:... (2 Replies)
Discussion started by: paolo.kunder
2 Replies

8. Shell Programming and Scripting

File Comparison: Print Lines not present in another file

Hi, I have fileA.txt like this. B01B02 D0011718 B01B03 D0012540 B01B04 D0006145 B01B05 D0004815 B01B06 D0012069 B01B07 D0004064 B01B08 D0011988 B01B09 D0012071 B01B10 D0005596 B01B11 D0011351 B01B12 D0004814 B01C01 D0011804 I want to compare this against another file (fileB.txt)... (3 Replies)
Discussion started by: genehunter
3 Replies

9. Shell Programming and Scripting

Array elements comparison using perl

Experts, I am looking to compare elements of 2 array using perl. Below is not the actual code but logic wise something like this. my $version = "MYSQlcl-5.2.4-264.x86_64"; <-- split this word into array as (5 2 4 264) ( which is to extract only the version number from the package name) my... (1 Reply)
Discussion started by: solaix14
1 Replies

10. Shell Programming and Scripting

File Comparison

HI, I have two files and contains many Fields with | (pipe) delimitor, wanted to compare both the files and get only unmatched perticular fields. this i wanted to use in shell scriting. ex: first.txt 111 |abc| 230| hbc231 |bbb |210 |bbd405 |ghc |555 |cgv second.txt 111 |abc |230 |hbc231... (1 Reply)
Discussion started by: prawinmca
1 Replies
Purple(3)						User Contributed Perl Documentation						 Purple(3)

NAME
Purple - Perl extension to the libpurple instant messenger library. SYNOPSIS
use Purple; ABSTRACT
This module provides the interface for using perl scripts as plugins in libpurple. DESCRIPTION
This module provides the interface for using perl scripts as plugins in Purple. With this, developers can write perl scripts that can be loaded in Purple as plugins. The scripts can interact with IMs, chats, accounts, the buddy list, libpurple signals, and more. The API for the perl interface is very similar to that of the Purple C API, which can be viewed at http://developer.pidgin.im/doxygen/ or in the header files in the Purple source tree. FUNCTIONS
@accounts = Purple::accounts Returns a list of all accounts, online or offline. @chats = Purple::chats Returns a list of all chats currently open. @connections = Purple::connections Returns a list of all active connections. @conversations = Purple::conversations Returns a list of all conversations, both IM and chat, currently open. @conv_windows = Purple::conv_windows Returns a list of all conversation windows currently open. @ims = Purple::ims Returns a list of all instant messages currently open. SEE ALSO
Purple C API documentation - http://developer.pidgin.im/doxygen/ Purple website - http://pidgin.im/ AUTHOR
Christian Hammond, <chipx86@gnupdate.org> COPYRIGHT AND LICENSE
Copyright 2003 by Christian Hammond This library is free software; you can redistribute it and/or modify it under the terms of the General Public License (GPL). For more information, see http://www.fsf.org/licenses/gpl.txt perl v5.12.1 2010-02-16 Purple(3)
All times are GMT -4. The time now is 05:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy