in reply to Appending string to all lines

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!

Replies are listed 'Best First'.
Re^2: Appending string to all lines
by bentrim (Initiate) on Nov 11, 2016 at 15:51 UTC

    Reading about Bareword errors helped me to figure out that I need to pursue your suggestion in using Text::CSV module. I will move in that direction.

    Thank you for the assistance.

      Frankly, IMHO, using Text::CSV for such a simple problem is overkill, since it can be done without any regard to the fact that your file contains CSV data. only need to add a trailer to each line.

      Update: see my post below for a simple solution.