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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:37:53+00:00 2026-05-16T00:37:53+00:00

I need help about how to numeration text in file. I have also linux

  • 0

I need help about how to numeration text in file.

I have also linux machine and I need to write the script with perl

I have file name: file_db.txt

In this file have parameters like name,ParameterFromBook,NumberPage,BOOK_From_library,price etc
Each parameter equal to something as name=elephant

My question How to do this by perl

I want to give number for each parameter (before the “=”) that repeated (unique parameter) in the file , and increase by (+1) the new number of the next repeated parameter until EOF

lidia

For example

file_db.txt before numbering

    parameter=1
    name=one

    parameter=2
    name=two

file_db.txt after parameters numbering

    parameter1=1
    name1=one

    parameter2=2
    name2=two
  • other examples

Example1 before

    name=elephant
    ParameterFromBook=234
    name=star.world
    ParameterFromBook=200
    name=home_room1
    ParameterFromBook=264

Example1 after parameters numbering

    name1=elephant
    ParameterFromBook1=234
    name2=star.world
    ParameterFromBook2=200
    name3=home_room1
    ParameterFromBook3=264

Example2 before

file_db.txt before numbering

       lines_and_words=1
       list_of_books=3442

       lines_and_words=13
       list_of_books=344224

       lines_and_words=120
       list_of_books=341

Example2 after

file_db.txt after parameters numbering

        lines_and_words1=1
        list_of_books1=3442

        lines_and_words2=13
        list_of_books2=344224

        lines_and_words3=120
        list_of_books3=341
  • 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-16T00:37:53+00:00Added an answer on May 16, 2026 at 12:37 am

    It can be condensed to a one line perl script pretty easily, though I don’t particularly recommend it if you want readability:

    #!/usr/bin/perl
    s/(.*)=/$k{$1}++;"$1$k{$1}="/e and print while <>;
    

    This version reads from a specified file, rather than using the command line:

    #!/usr/bin/perl
    open IN, "/tmp/file";
    s/(.*)=/$k{$1}++;"$1$k{$1}="/e and print while <IN>;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

need ask you about some help. I have web app running in Net 2.0.
i need help with disk_total_space function.. i have this on my code <?php $sql=select
I have a regex call that I need help with. I haven't posted my
I need help to make decision. I have a need to transfer some data
I need help on how to validate Xml file simply? I googled and found
Hello I need help with displaying data from 2 table. So i Have 2
I need to read line by line from text file (log files from server)
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help understanding some C++ operator overload statements. The class is declared like
I need help with this route map routes.MapRoute(Blog_Archive, Blog/Archive/{year}/{month}/{day}, new { controller = Blog,

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.