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 Answer