Hello bentrim,

Ideally, you should be using a well-tested module like Text::CSV for these kind of activities. Since this is an one-time activity, I'm going to show you the simplest way. Why not do something like:

$ cat > somestuff.csv 10004,Able,Baker,able.baker@notrealemail.com 14634,Charley,Delta,charley.delta@notrealemail.com 12886,Echo,Foxtrot,echo.foxtrot@notrealemail.com 14366,Golf,Hotel,golf.hotel@notrealemail.com 10178,India,Juliet,india.juliet@notrealemail.com 10164,Kilo,Lima,kilo.lima@notrealemail.com 10124,Mike,November,mike.november@notrealemail.com $ perl -pi -e 's/\Z/,UF,A,Y,9,U/' somestuff.csv $ cat somestuff.csv 10004,Able,Baker,able.baker@notrealemail.com,UF,A,Y,9,U 14634,Charley,Delta,charley.delta@notrealemail.com,UF,A,Y,9,U 12886,Echo,Foxtrot,echo.foxtrot@notrealemail.com,UF,A,Y,9,U 14366,Golf,Hotel,golf.hotel@notrealemail.com,UF,A,Y,9,U 10178,India,Juliet,india.juliet@notrealemail.com,UF,A,Y,9,U 10164,Kilo,Lima,kilo.lima@notrealemail.com,UF,A,Y,9,U 10124,Mike,November,mike.november@notrealemail.com,UF,A,Y,9,U $

Doing things like calling perl to do AWK is just overkill, since perl was meant to take in all the goodness of sed, awk and shell scripting, wiping away the pain of all other scripting stuff!

Do read more of perl "pie-ness" in perlrun and CSV handling in Text::CSV. Have fun!


In reply to Re: Appending string to all lines by robby_dobby
in thread Appending string to all lines by bentrim

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.