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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:29:31+00:00 2026-06-18T03:29:31+00:00

I’m pretty new to perl, but so far got to do pretty much everything

  • 0

I’m pretty new to perl, but so far got to do pretty much everything I needed to, until now.

I have a file formatted like so:

#IPAAS

@NX_iPaaS_AuthKey=dGstaG9zaGlub0BqcCasdpasdHN1LmNvbTppUGFhUzAw
@NX_iPaaS_href=live/661134565/process/75231

I’d like to read each line that begins with @NX_iPaaS into a similar named variable, e.g.
@NX_iPaaS_AuthKey would create a new variable called $NX_IPAAS_AUTHKEY and hold the value, NX_iPaaS_href would result in a new variable called $NX_IPAAS_HREF with a value and so on?

–Update–

Hey guys, I need a slight tweak required to the above solution…

So I’ve just discovered that the file I’m reading in will have ‘sections’, e.g.

----- SECTION=cr 
NX_NTF_PERSISTENT_ID=cr:400017 
NX_NTF_REF_NUM=45 
----- SECTION=cnt 
NX_NTF_PERSISTENT_ID=cnt:F9F342055699954C93DE36923835A182 

You can see that one of the variables appears in both sections, which (because I don’t have ‘next unless defined’) results in the previous value being overwritten. Is there a way to prefix the NX_NTF_ variable names with the value provided on the ‘section=’ line at the top of each section?

Thanks

  • 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-18T03:29:32+00:00Added an answer on June 18, 2026 at 3:29 am

    What you want to use is a hash. Something like:

    use strict;
    use warnings;
    
    my $input = "yourfilename.txt";
    open(my $IN, "<", $input) or die "$0: Can't open input file $input: $!\n";
    
    my %NX_iPaaS_vars;
    
    while (<$IN>) {
        chomp;
        if ($_ =~ /^\@NX_iPaaS/) {
            my ($key, $value) = split(/=/, $_);
            $NX_iPaaS_vars{$key} = $value;
        }
    }
    

    To use a variable later on, use $NX_iPaaS_vars{"name of variable you want"}, for example:

    my $href_path = $NX_iPaaS_vars{'@NX_iPaaS_href'};
    # Do something with $href_path here...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.