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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:21:52+00:00 2026-05-15T20:21:52+00:00

My name is abbi My first perl script run on linux machine This script

  • 0

My name is abbi

My first perl script run on linux machine

This script read the INI file called (input) and print the values of val , param , name …..

How to create loop that print values of val1-valn OR loop to print values of param1-paramn… etc? (in place the print command’s in the script )

  • the loop must have option to match the parameter
    for example print only param1 until paramn values

n – Is the last number of each param

 #!/usr/bin/perl




 open(IN,"input") or die "Couldn't open input: $!\n"; 
 while(<IN>) { 
 chomp; 
 /^([^=]+)=(.*)$/; 
 $config{$1} = $2; 

 } 
 close(IN);


 print $config{val1};
 print $config{val2};
 print $config{val3};

 print $config{param1};
 print $config{param2};
 print $config{param3}; 

 print $config{name1};
 .
 .
 .
 .

example of the ini file from linux machine

cat input

  val1=1
  val2=2
  val3=3
  param1=a
  param2=b
  param3=c
  name1=abbi
  name2=diana
  name3=elena
  • 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-15T20:21:53+00:00Added an answer on May 15, 2026 at 8:21 pm

    According to your last comment, this will do what you want:

    use strict;
    use warnings;
    
    my %config;
    my $max_n = 0;
    my $input = 'input';
    open my $in, '<', $input
        or die "unable to open '$input' for reading: $!";
    while (<$in>) {
        chomp;
        if (/^(.*?(\d+))\s*=(.*)$/) { 
            $config{$1} = $3; 
            $max_n = $2 if $2 > $max_n;
        }
    }
    close $in or die "unable to close '$input': $!";
    
    for my $n(1..$max_n) {
        for my $param (qw/val param/) {
            print "$param.$n = $config{$param.$n}\n" if exists $config{$param.$n};
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is not pretty but it works: rm -R $(ls… May 16, 2026 at 12:45 pm
  • Editorial Team
    Editorial Team added an answer Yes. Override the base1 and base2 methods in Derived to… May 16, 2026 at 12:45 pm
  • Editorial Team
    Editorial Team added an answer No, you can't. Unfortunately, UIEvent doesn't expose any public way… May 16, 2026 at 12:45 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

if __name__=='__main__': parser = OptionParser() parser.add_option(-i, --input_file, dest=input_filename, help=Read input from FILE, metavar=FILE) (options,
Name of the file from where code is running Name of the class from
file name myServices.php <?php $gender = 'MALE'; ?> in another file lets say file.php
Name of the option tells something but what Visual Studio/compiler really do and what
Name the design considerations in deciding between use of a singleton versus a static
Name is not compliant? Layout? What? Do you have ideas what exactly could generate
Name: <%= Html.TextBox(txtName, 20, new { @class = hello }) %> I want that
[ { name: John Doe, location: { name: New York, New York, id: 12746342329
The name of a temporary table such as #t1 can be determined using select
Right now I can name the subroutine printargs as follows to get the dump.

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.