Your question is unclear.

But your desire to add two new columns after the first without writing a new file needs more thought.

Your language suggests you think there's some way to change the content of a file (on disk, in RAM) without writing it out to storage again. Sure, you could overwrite the existing file (for some types of changes) but doing so would destroy the original file (and under most OSen write the new version would be written in a different spot on the disk or at a different set of addresses in RAM, anyway). So take advantage of Perl's capabilities (and no, I don't mean the "edit in place" operation, which merely disguises the fact that you are writing a new file).

One standard technique is to write the revised material to a temp file, and, when complete, renamethe original to original.bak (or delete the original) and rename the temp file to the original name. Alternately, write the revised material to a file with a name that indicates its status.

Leaving the actual code for file opening, reading, writing as an exercise, the options above lead to how the question of how to do the insert_processing : Here's one (iterative for clarity) possibility.

#!/usr/bin/perl use strict; use warnings; use 5.012; my @array = qw (a c e); for my $item(@array) { say $item; } say "-" x 10; my $save = $array[1]; my $insert = "b"; splice @array,1,1, ($insert, $save); for my $item(@array) { say $item; } say "-" x 10; $save = $array[3]; $insert = "d"; splice @array,3,1, ($insert, $save); for my $item(@array) { say $item; }

All that said, if what it is you plan to insert and the meaning of "Age to FullName" have any real bearing on your problem, you need to clarify your SOPW.


In reply to Re: How to add Rows/Columns in .csv using Tie::Handle:CSV by ww
in thread How to add Rows/Columns in .csv using Tie::Handle:CSV by shubham.at8

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.