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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:39:53+00:00 2026-06-06T17:39:53+00:00

I am writing data in a file. The file will look like this. [section1]

  • 0

I am writing data in a file. The file will look like this.

[section1] [section2] [section3]
[section1] [section2] [section3]

I am not writing data to the file directly.
I am first appending rows in a string and then writing to a file.

$str .= "section1_data  section2_data   section3_data\n";
$str .= "section1_more_data   section2_more_data   section3_more_data\n";

Now what I want is that all the sections should be 30 chars long.
The data inside all sections will always be less than or equal to 30 chars.

Is there a way to do this in perl?

I am using following syntax to write to file

open FH,">>filename";
print FH $str;
close FH;
  • 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-06T17:39:55+00:00Added an answer on June 6, 2026 at 5:39 pm
    $str .= sprintf("[%-30s] [%-30s] [%-30s]\n",
        $section1_data,
        $section2_data,
        $section3_data,
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whats the best approach for writing data to a file that will be picked
How do I read data from a file if my file is like this
So I have been writing to Environment.SpecialFolder.ApplicationData this data file, that upon uninstall needs
I'm having trouble reading and writing QByteArray data to a file. My goal is
I'm exporting some data, making a file and writing the data to the file...
I am writing a lot of data to a file, and while keeping my
I'm writing a program that passes data from a file into an array, but
How can I write data to stdout instead of writing file? I'm using GPG
I'm writing a bash script that encrypts the data of a folder or file
I am writing a Silverlight application that will be both reading and writing data

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.