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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:04:19+00:00 2026-06-10T18:04:19+00:00

I need store each element in the first column where are the privileges in

  • 0

I need store each element in the first column where are the privileges in keys and value in the file, i did this but I do not understand.

it’s content in my file “file-privilege”

-rw-rw-r--. file-privilege
-rw-rw-r--. file-selinux
-rwxrwxrwx. funcion-split-join.pl
-rwxrwxr-x. hash2.pl
-rw-rw-r--. hash3.pl
-rwxrwxr-x. hash.pl
-rwxrwxr-x. inthashfile.pl
-rw-rw-r--. ls
-rwx------. probando.pl

the code in perl.

%pr_file = ();
open(WHO, "file-privilege");
while (<WHO>) {
    ($privilege, $file) = split ;
    push( @{$pr_file{$privilege}}, $file );
}

this output.

-rwx------. = ARRAY(0x83bb7f0)
-rw-rw-r--. = ARRAY(0x83a06f8)
-rwxrwxr-x. = ARRAY(0x83bb780)
-rwxrwxrwx. = ARRAY(0x83bb750)

I need:

key = value

-rw-rw-r--. = file-privilege

etc…

any idea?

  • 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-10T18:04:20+00:00Added an answer on June 10, 2026 at 6:04 pm

    The same key maps to multiple values. You need to dereference the array reference just like when you add a value; or use a scalar which only remembers the last (or first, or a random) value.

    Anyway, the code you have shown us is correct; the problem is in the code which prints out the values, which you have not provided. But something like this:

    for my $priv (keys %pr_file) {
        for my $file (@{$pr_file{$priv}}) {
            print "$priv => $file"; # Already contains trailing newline
        }
    }
    

    By the by, you should probably use Perl’s built-in stat() function rather than try to parse ls output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to store the dom index of each element on the page. The
I need to extract each pixel color from a png image and store it
I need store just 10 arrays in my app, which I can change from
I have id values for products that I need store. Right now they are
I need to store a very large amount of instances of my class, and
I need to store a login session when the user is login and remove
I need to store GPS coordinates in a database. I've heard that floats are
I need to store user credentials in my app. I can store and retrieve
I need to store locally on android devices some images I get from the
I need to store lotto numbers in a SQL database. There are 8 separate

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.