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 6475083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:39:48+00:00 2026-05-25T06:39:48+00:00

I am new to Perl and trying to learn it. I have two files,

  • 0

I am new to Perl and trying to learn it. I have two files, ‘file1’ and ‘file2’, I need to find which symbols in ‘file1’ are not in ‘file2’ for companyA and departments B and C.

File1

GTY
TTY 
UJK
TRE

File2

departmentA_companyA.try=675 UJK 88 KKR
departmentA_companyB.try=878 UJK 37 TAR
departmentA_companyC.try=764 UJK 92 PAM
departmentB_companyA.try=675 UJK 88 KKR
departmentB_companyB.try=878 UJK 37 TAR
departmentB_companyC.try=764 UJK 92 PAM
departmentC_companyA.try=675 UJK 88 KKR
departmentC_companyB.try=878 UJK 37 TAR
departmentC_companyC.try=764 UJK 92 PAM
  • 1 1 Answer
  • 0 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-25T06:39:48+00:00Added an answer on May 25, 2026 at 6:39 am
    1. Create a list of all the symbols in file1
    2. Go through file2. If the criteria matches, delete the symbol from the list.

    In this case, I’d suggest you use the keys of a hash to store this list ($symbols{$symbol} = 1;). This is because it’s easy and cheap to delete from a hash (delete $symbols{$symbol};).

    Spoiler:

    use strict;
    use warnings;
    use feature qw( say );
    
    my %symbols;
    {
       open(my $fh, '<', 'file1')
          or die("Can't open file1: $!\n");
    
       while (<$fh>) {
          chomp;
          ++$symbols{$_};
       }
    }
    
    {
       open(my $fh, '<', 'file2')
          or die("Can't open file2: $!\n");
    
       while (<$fh>) {
          chomp;
          my ($key, $val) = split /=/;
          my ($dept, $co) = split /[_\.]/, $key;
          if ($co eq 'companyA' || $dept eq 'departmentB' || 'departmentC') {
             my @symbols = split ' ', $val;
             delete @symbols{@symbols};
          }
       }
    }
    
    say for keys %symbols;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am relatively new to Perl.I have been trying to insert data to database
I'm trying to learn how to profile perl memory. I have a very simple
Regards, SO I am new to python and Perl. I have been trying to
I am trying to write new XS module for Perl. I have tested by
I am really new at Perl and have been trying to piece together a
I am new to Perl and I am trying to extract email from string
I am new to perl, and can't seem to find answers about this anywhere.
New to Perl, I'm trying to define a subset of characters and then output
I'm just learning perl and I'm trying to learn regular expressions at the same
(New to perl) I'm trying to update an existing perl script to store in

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.