snehit.ar has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am working on a dashboard to display only 6 records(row) . In my array list i am passing a counter variable to set line number depends on the arrays count.To display the sorted records map with the line numbers in dashboard. If i have only 3 records in my array to display on dashboard ,i want to set others 3 records as blank . so my dashboard should show 3 records only and not the other 3 previously fetch records when my array had 6 records(row). Help me with the condition i can use for this ?
my @records; my $count=0; ...get the records from xml nodes foreach node ... in nodelist{ $count ++; #if ($count <= 6 ) { push @records, { line => $count, appname => $appname visible => "Yes", } #else #{ #push @records, { # line => $count, # appname => "", # visible => "No", #} } } print Dumper \@records;
Thank you!

Replies are listed 'Best First'.
Re: array splice to retrieve specific records
by Corion (Patriarch) on Jul 12, 2017 at 07:23 UTC

    How would you do this without a computer?

    Once you have written down the steps to do this without a computer, write these steps in Perl.

    Please, do not treat this site as a code writing service. We expect you to do your work yourself.

    You can improve the quality of answers you get by showing runnable code which sets up the data in a simple way. For example, instead of a comment or pseudocode, just initialize your data with dummy data:

    my @nodelist = ("dummy1", "dummy2", "dummy3", "dummy4");
Re: array splice to retrieve specific records
by huck (Prior) on Jul 12, 2017 at 07:32 UTC

    while (scalar(@records)<6){push @records,{...};}