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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:46:36+00:00 2026-06-10T10:46:36+00:00

I have a file with different lines , each line has a repeated pattern.I

  • 0

I have a file with different lines , each line has a repeated pattern.I need a propper data structure to parse my file for example:

cluster1:gene1(genome1) gene2(genome2) gene3(genome3)
cluster2:gene4(genome4) gene5(genome5)

names are arbitary can be any thing .

I have thought a bout a hash of hash data structure

  %hoh=("cluster1" => {
        "gene1"=>"genome1"
        "gene2"=>"genome2"
        "gene2"=>"genome2"
                       },   "cluster2" => {
        "gene4"=>"genome4"
        "gene5"=>"genome5"
                       }
       )

I have 2 questions:
first:how do I look for repeated pattern in each line ?

Second ,how do I make hash of hashe?

EDIT: Posted upon Zaid’s request

#!/usr/bin/perl -w
use strict; use warnings;
    my %HoH;
while(<DATA>){
    my $line=$_;
    chomp($line);
    my ( $cluster, $genes ) = split (/:/,$line);

     $HoH{ $cluster } = { split/[( )]+/ , $genes };

  }  
foreach $cluster (keys %HoH){
    print "$cluster: ";
    foreach $genes (keys %{$HoH{$cluster}}){
        print "$genes = $HoH{$cluster}{$genes} ";
    }
    print "\n";
}                                               

__DATA__
cluster1:gene1(genome1) gene2(genome2) gene3(genome3)
cluster2:gene4(genome4) gene5(genome5)
  • 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-06-10T10:46:37+00:00Added an answer on June 10, 2026 at 10:46 am

    Explanation to follow when OP posts their attempt:

    my %HoH;
    
    while (<>) {
    
        chomp;
        my ( $cluster, $genes ) = split /:/;
    
        $HoH{ $cluster } = { split /[( )]+/, $genes };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In short, I have a 20,000,000 line csv file that has different row lengths.
I have a text file with several different sections. Each section has a header
I have a text file with lots of links-each line has a link (i.e
i'm reading file which has some number of columns each line has different number
I have a file that has fairly long lines. The longest line has length
I have a multi line text file where each line has the format .....
My test file has "n" number of lines and between each line there is
I have a solution file with has more than 30 projects in it. Different
I have a project that includes 49 folders, each one has a file called
I have a csv file where each column is a different test result, and

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.