in reply to Add Quotes to entries in a file

@chobra

when i try your line i just get Can't find string terminator "'" anywhere before EOF at -e line 1. Im probally doing something wrong but im just beginning with pearl so bear with me :)

@hippo

Would that work if i had different files with different content?

Replies are listed 'Best First'.
Re^2: Add Quotes to entries in a file
by AnomalousMonk (Archbishop) on Jul 12, 2018 at 15:24 UTC
    Would that work if i had different files with different content?

    niseus: That's exactly why hippo presented his solution in the Test::More format: so that you can add all the extra test cases (content) you feel you need (and you're encouraged to add many). See How to ask better questions using Test::More and sample data. The Test::More module family is very useful in general development. Testing with different files I leave to you to work out.


    Give a man a fish:  <%-{-{-{-<

Re^2: Add Quotes to entries in a file
by choroba (Cardinal) on Jul 12, 2018 at 14:19 UTC
    Are you on MSWin? Quoting is different there, single quotes don't work. Have you used copy/paste or retyped the command? Also note that @name doesn't work on PerlMonks. To get the author alerted about a reply, reply to their node.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      Hi, i now did it with " instead if ' but now all it does is copy my File in a new one but no quotes are added.
Re^2: Add Quotes to entries in a file
by davies (Monsignor) on Jul 12, 2018 at 14:20 UTC
    when i try your line i just get Can't find string terminator "'" anywhere before EOF at -e line 1. Im probally doing something wrong but im just beginning with pearl so bear with me :)

    If you are using Losedows you will need to change the surrounding single quotes to double quotes and escape all the double quotes in the Perl. You may find it easier to put the solution in a file. One liners in Losedows are more awkward than in *u*x.

    Regards,

    John Davies

Re^2: Add Quotes to entries in a file
by hippo (Archbishop) on Jul 12, 2018 at 14:27 UTC
    Would that work if i had different files with different content?

    Yes, but only if the different content follows the same pattern of course. Feel free to expand @rec with your extra data sets and see.