in reply to Returning an array in a specific way for csv

Like so?

#!/usr/bin/perl # http://perlmonks.org/?node_id=1184431 use strict; use warnings; for ( split /^BEGIN_TAG\nX\d+ /m, do { local $/; <DATA> } ) { s/\n */ /g; # combine lines s/ X\d+/;/g; # change Xn to ; s/\s*\z/\n/; # make sure \n at end of line print; } __DATA__ BEGIN_TAG X1 test test test X2 no no no no X3 yes yes yes BEGIN_TAG X1 test test test tes test test X2 no no no no no nono non no no nononono no no no X3 hi hi hi hi hi hi hi hi hi hi hi hi

ignoring what seems to be a typo in the output you show.

Replies are listed 'Best First'.
Re^2: Returning an array in a specific way for csv
by Arengin (Novice) on Mar 14, 2017 at 08:28 UTC
    Interesting way to do it and yes the result is what I was looking for. Thank you very much.