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

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,

Replies are listed 'Best First'.
Re^4: Need help with node names for creating header line
by vlturner (Sexton) on Dec 30, 2015 at 21:08 UTC

    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.
Re^4: Need help with node names for creating header line
by vlturner (Sexton) on Dec 30, 2015 at 21:19 UTC

    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?

Re^4: Need help with node names for creating header line
by vlturner (Sexton) on Dec 30, 2015 at 21:28 UTC

    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,