in reply to Re^12: Compare 2 XML files
in thread Compare 2 XML files

hello, I have an array to store event ids ,But on my dashboard rows are restricted to 6. So if my array returns 10 eventid, i want to set line 7-10 as blank . ..Similarly if event id have only 3 records set remaining 4-10 as blank

expected output

{ 'line' => 1, 'eventid' => 2667 }, { 'line' => 2, 'eventid' => 2667 }, { 'eventid' => 2666, 'line' => 3 }, { 'eventid' => 2666, 'line' => 4 }, { 'line' => 5, 'eventid' => 2666 }, { 'line' => 6, 'eventid' => 2666 }, { 'eventid' => "", 'line' => 7 }, { 'line' => 8, 'eventid' => "" }, { 'eventid' => "", 'line' => 9 }, { 'eventid' => "", 'line' => 10 },

Replies are listed 'Best First'.
Re^14: Compare 2 XML files
by poj (Abbot) on Jul 13, 2017 at 09:00 UTC
    Try
    #!perl use strict; use Data::Dump 'pp'; # test data my @AoH = map{ { line => $_, eventid => int rand(2000) } } 1..8; my $max = 6; for (@AoH){ if ($_->{'line'} > $max){ $_->{'eventid'} = ''; } } for (@AoH+1..$max){ push @AoH, { line => $_, eventid => '' }; } pp \@AoH;
    poj
      @poj, Thank you so much for sample code... same i have applied in my program ...