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

  • Home
  • SEARCH
  • 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 827433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:34:26+00:00 2026-05-15T03:34:26+00:00

My file contains a: b d: e f: a:b:c g: a b c d

  • 0

My file contains

a: b
d: e
f: a:b:c
g: a
   b
   c
   d
   f:g:h
h: d
   d:dd:d
J: g,j

How can I parse this file into lefthand side values into one array and right hand side to another array? I tried with split, but I am not able to get it back.

I want to store them into hash.

  • 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-15T03:34:27+00:00Added an answer on May 15, 2026 at 3:34 am

    Howzabout this:

    #!/usr/bin/perl
    use warnings;
    use strict;
    my $s = 
    q/a: b
    d: e
    f: a:b:c
    g: a
       b
       c
       d
       f:g:h
    h: d
       d:dd:d
       f
    /;
    open my $input, "<", \$s or die $!;
    my @left;
    my @right;
    while (<$input>) {
        chomp;
        my ($left, $right) = /^(.):?\s+(.*)$/;
        push @left, $left;
        push @right, $right;
    }
    print "left:", join ", ", @left;
    print "\n";
    print "right:", join ", ", @right;
    print "\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Spent many hours and still can't figure that out. sampleData.json file contains the following
Can anyone give me any pointers. I have a text file that contains dates
How can i create .KMZ (google earth file format) programmatically? .KMZ contains a .KML
I have a log file that I want to parse and load into a
I have a PDF file, which contains data that we need to import into
I can't get server side includes to work. I simply want to include one
I'm using ruby 1.9.2 I'm trying to parse a CSV file that contains some
I have an XML file in res/values. The file contains a list of people.
I have a .txt file which contains no of insert query like this. I
I am learning JPA. I read about persistence.xml file. It can contain more that

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.