Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 751925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:43:22+00:00 2026-05-14T14:43:22+00:00

Requirement:- File1 has contents like – ABCD00000001,\some\some1\ABCD00000001,Y,,5 (this indicates there are 5 file in

  • 0

Requirement:-

File1 has contents like –

ABCD00000001,\some\some1\ABCD00000001,Y,,5 (this indicates there are 5 file in total in unit)

File2 has contents as ABCD00000001

So what i need to do is check if ABCD00000001 from File2 exist in File1 –
if yes{

print the output to Output.txt till it finds another ‘,Y,,X’}

else{ No keep checking}

Anyone? Any help is greatly appreciated.

Hi Arkadiy Output should be :- any filename from file 2 -ABCD00000001 in file1 and from Y to Y .
for ex :- file 1 structure will be :-

ABCD00000001,\some\some1\ABCD00000001,Y,,5
ABCD00000001,\some\some1\ABCD00000002
ABCD00000001,\some\some1\ABCD00000003
ABCD00000001,\some\some1\ABCD00000004
ABCD00000001,\some\some1\ABCD00000005
ABCD00000001,\some\some1\ABCD00000006,Y,,2
so out put should contain all line between 
ABCD00000001,\some\some1\ABCD00000001,Y,,5 and

ABCD00000001,\some\some1\ABCD00000006,Y,,2

#!/usr/bin/perl -w
use strict;


my $optFile = "C:\\Documents and Settings\\rgolwalkar\\Desktop\\perl_scripts\\SampleOPT1.opt";
my $tifFile = "C:\\Documents and Settings\\rgolwalkar\\Desktop\\perl_scripts\\tif_to_stitch.txt";
print "Reading OPT file now\n";
open (OPT, $optFile);
my @opt_in_array = <OPT>;
close(OPT);

foreach(@opt_in_array){
    print();
}

print "\nReading TIF file now\n";

open (TIF, $tifFile);
my @tif_in_array = <TIF>;
close(TIF);

foreach(@tif_in_array){
    print();
}

so all it does it is reads 2 files “FYI -> I am new to programming”

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:43:23+00:00Added an answer on May 14, 2026 at 2:43 pm

    OK, I’ll bite (partially)…

    First general comments. Use strict and -w are good, but you are not checking for the results of open or explicitly stating your desired read/write mode.

    The contents of your OPT file kinda sorta looks like it is CSV and the second field looks like a Windows path, true? If so, use the appropriate library from CPAN to parse CSV and verify your file names. Misery and pain can be the result otherwise…

    As Ether stated earlier, you need to read the file OPT then match the field you want. If the first file is CSV, first you need to parse it without destroying your file names.

    Here is a small snippet that will parse your OPT file. At this point, all it does is print the fields, but you can add logic to match to the other file easily. Just read (slurp) the entire second file into a single string and match with your chosen field from the first:

    #!/usr/bin/perl
    use strict;
    use warnings;
    use Text::CSV;
    
    my $csv = Text::CSV->new();
    my @opt_fields;
    
    
    while (<DATA>) {
        if ($csv->parse($_)) {
            push @opt_fields, [ $csv->fields() ];
        } else {
            my $err = $csv->error_input;
            print "Failed to parse line: $err";
        }
    }
    
    
    foreach my $ref (@opt_fields) {
    #   foreach my $field (@$ref) { print "$field\n"; }
        print "The anon array: @$ref\n";
        print "Use to match?: $ref->[0]\n";
        print "File name?: $ref->[1]\n";
    }
    
    __DATA__
    ABCD00000001,\some\some1\ABCD00000001,Y,,5
    ABCD00000001,\some\some1\ABCD00000002
    ABCD00000001,\some\some1\ABCD00000003
    ABCD00000001,\some\some1\ABCD00000004
    ABCD00000001,\some\some1\ABCD00000005
    ABCD00000001,\some\some1\ABCD00000006,Y,,2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My requirement is simple. At the beginning of each file there should be a
I have the following requirement. Ex: There is a transaction table where it has
In a web project using jsp, I have following requirement Upload a file (say
I have a requirement to combine 4 xml files into one. They are like
According to current requirement,user will upload files with large size,which he may like to
My requirement is to work on some interface .h files. Right now I have
I have got the requirement to find the core file in multiple box/machine and
I have a specific requirement to read a resource from jar file and then
I have a requirement to write HTML to the file system and I was
I am working on an Android Honeycomb (v3.0) application that has a requirement of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.