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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:03:34+00:00 2026-05-28T08:03:34+00:00

I have built an array, such as A = [a1,a2,…aN]. How to save this

  • 0

I have built an array, such as A = [a1,a2,…aN]. How to save this array into a data file, with each element to be placed at one row. In other words, for the array A, the file should look like

a1
a2
a3
...
  • 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-28T08:03:35+00:00Added an answer on May 28, 2026 at 8:03 am

    Very simple (this is assuming, of course, that your array is explicitly specified as an array data structure, which your question doesn’t quite make clear):

    #!/usr/bin/perl -w
    use strict;
    
    my @a = (1, 2, 3); # The array we want to save
    
    # Open a file named "output.txt"; die if there's an error
    open my $fh, '>', "output.txt" or die "Cannot open output.txt: $!";
    
    # Loop over the array
    foreach (@a)
    {
        print $fh "$_\n"; # Print each entry in our array to the file
    }
    close $fh; # Not necessary, but nice to do
    

    The above script will write the following to “output.txt”:

    1
    2
    3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an 'dictionary' array such as this: $arr['a']=5; $arr['b']=9; $arr['as']=56; $arr['gbsdfg']=89; And I
I have two arrays built while parsing a text file. The first contains the
I have built a number of asp.net servercontrols into a class library, & I
So I've built a custom array of users like such: [[user1,432],[user1,53],[user9,58],[user5,75],[user3,62]] I want to
I have a normal one dimensional array, let's call it $myarray , with several
Does GreaseMonkey have something built in so you can store data per-site or per-page?
I have to store about 10k text lines in an Array. Each line is
I have a multidimensional array built from Strings that is initially created with the
I have a numpy.array of 640x480 images, each of which is 630 images long.
If I have two byte[] arrays, is there a built-in function to compare them

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.