in reply to Re: Need help with node names for creating header line
in thread Need help with node names for creating header line

So I used this and it runs, But still not what I was working to get. What I want is a CSV file with a header

COL_HDR1,COL_HDR2,COL_HDR3 DATA1, DATA2, DATA3

Replies are listed 'Best First'.
Re^3: Need help with node names for creating header line
by choroba (Cardinal) on Dec 30, 2015 at 20:43 UTC
    Keep a flag that tells you whether the header was already printed, if so, extract text, otherwise extract names:
    my $header_printed; for my $record (@sorted) { my @info_tags = $record->children; my @data; for my $info_tag (@info_tags) { my $extract = $header_printed ? 'text' : 'name'; push @data, $info_tag->$extract; } $header_printed = 1; say join ',', @data; }
    ($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,

      Got it, had typo. This code is part of an integration to Service Now CMDB Is there a way that I can add this to the Tutorials for dealing with this DATABASE as the code matures?

      Stupid me.... say join ',', map qq("$_"), @data;

        To output CSV, use Text::CSV. Your solution breaks if a field contains double quotes or newlines.
        ($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,

      Getting following error:

      perl CMDB_Sample.pl Can't use string ("change_request") as an ARRAY ref while "strict refs +" in use at CMDB_Sample.pl line 56.