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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:21:47+00:00 2026-05-13T17:21:47+00:00

I have 2 files, one is the master file and the other is a

  • 0

I have 2 files, one is the master file and the other is a subset of this file, with some additional data. Both the files are in the form of fields with a ^A separator. My job comes in that, from the master file, I wish to create the subset files. The subset files already have some data, which I can duplicate, but I want the fields available in the master file to be also available in the subset file.

Example:

subset file format:
1234^A56^A78^A910^A1112^A13^A14^A151617^A18^A192021.000000^A22.000000

master file format:
1242^A2282^A2^A1^A0
1234^A78^A910^A4^A4
1380^A2594^A2^A25^A3
1404^A2447^A6^A44^A9

In the above example, the master file has 4 rows, while the subset file has 1 row. The values of the 2nd row of the master file match the row in the subset file.

I want to create the additional lines in the master file, into the subset file too. Basically, the first, third and fourth fields in the subset file should match the first 3 fields of the master file, the rest can be any randomly generated values.

Also, I wish to retain the ^A separators in the subset file.

  • 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-13T17:21:47+00:00Added an answer on May 13, 2026 at 5:21 pm

    Assuming you want to append all records to the same subset file, use

    #! /usr/bin/perl -l
    
    use warnings;
    use strict;
    
    # demo only
    my $buf = join "" =>
              map "$_\n" =>
              "1242\cA2282\cA2\cA1\cA0",
              "1234\cA78\cA910\cA4\cA4",
              "1380\cA2594\cA2\cA25\cA3",
              "1404\cA2447\cA6\cA44\cA9";
    open my $master, "+<", \$buf or die "$0: open: $!";
    
    open my $subset, ">>", "subset.dat" or die "$0: open: $!";
    
    while (<$master>) {
      chomp;
      my($id,$x,$y) = (split /\cA/)[0..2];
    
      print $subset join "\cA" =>
        $id, 56, $x, $y, 
        1112, 13, 14, 151617, 18, 192021.000000, 22.000000;
    }
    
    close $subset or warn "$0: close: $!";
    

    As documented in perlop, the escape sequence \cA produces the Ctrl-A (ASCII SOH) separator you’re using. To keep the demo self-contained, the code above reads $buf as though it were a file, but of course you’d open the master file in production.

    Output viewed through less where again bolded ^A indicates ASCII SOH:

    1242^A56^A2282^A2^A1112^A13^A14^A151617^A18^A192021^A22
    1234^A56^A78^A910^A1112^A13^A14^A151617^A18^A192021^A22
    1380^A56^A2594^A2^A1112^A13^A14^A151617^A18^A192021^A22
    1404^A56^A2447^A6^A1112^A13^A14^A151617^A18^A192021^A22
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Master Page which has an associated css file. On one of
I have two template files: one for the form (loginFormTemplate) and one for the
At some point I must have moved files from one location to another using
I have this code to open multiple files one at a time that is
How do I define multiple media queries in one file? I have this .styl-file:
I have two branches one is called master the other is called dev I
I have a form with field <input type=file name=file size=100 value=> if this field
I have three files: one called sql.php witch has a class db that I
I have two files one with senators who are retiring and one of complete
Here I am trying to implement the jQuery I have two main files one

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.