sinnerFA has asked for the wisdom of the Perl Monks concerning the following question:

I have been having a heck of a time trying to modify a text output to conform to YAML standards so I can hash it quickly.. Here is the file format before (and it is repeating):

N <TEXT>
1: <TEXT>
2: <TEXT>
3: <TEXT>
4: <TEXT>
5: <TEXT>
6: <TEXT>
7: <TEXT>
8: <TEXT>
9: <TEXT>
10: <TEXT>
....

And here is what I need it to look like (post processed):

- N:
1: <TEXT>
2: <TEXT>
4: <TEXT>
5: <TEXT>
6: <TEXT>
7: <TEXT>
8: <TEXT>
9: <TEXT>
10: <TEXT>
....

Notice the 3rd line was also removed and the text behind the first line was removed... Can anyone help? TIA

Replies are listed 'Best First'.
Re: File Processing for YAWL...
by Corion (Patriarch) on Sep 08, 2010 at 20:05 UTC

    Hello and welcome to the monastery!

    You have written your question, but to help you help yourself, we'll need some more answers:

    What makes the third line special? Should every third line of every file be removed, or is there some criteria other than position in a file?

    What code have you already written?

      The third row has an "illegal" set of characters for YAML... i.e. 3: <bracket><some number><bracket> <some text> It causes issues when I run the following sample:
      use File::Slurp; use YAML::XS; use Data::Dumper; print Dumper Load scalar read_file('output.txt');
      Sorry, the rest of the code was cut off....
      #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @config; open FILE, "<output.txt" or die $!; while (<FILE>) { chomp; push @config, { split /[^N\n*]/ }; # push @config, $_; } print Dumper( @config );
      I am sure it has to do with the regexp... But I also think that I am not dealing with the file_read properly for the split to occur... TIA
        "The third row has an "illegal" set of characters for YAWL... i.e. 3: <bracket><some number><bracket> <some text>"

        Umm, yeah. We kind of needed to know that in the first place, since the data in your OP gives no hint that an illegal character creates the problem... and because it's just remotely possible that some of us who might offer (substantive) help might not be familiar with "YAWL."

        A reply falls below the community's threshold of quality. You may see it by logging in.