snehit.ar has asked for the wisdom of the Perl Monks concerning the following question:
It might be simple logic for someone ,but for me its not.So please bare with me.
Please consider array with 14 records .In FOR loop want to Add wait condition of (10sec), if my array count reach 10 push record(10)to print and then wait for 10sec and then push only remaining 4 records to print.Now i am just displaying all records in one shot.Below is my code with json
#!/usr/bin/env perl use warnings; use strict; use Data::Dumper; binmode STDOUT, ":utf8"; use utf8; use JSON; my @records; my $json; { local $/; open my $fh, "<", "reddataout.json"; $json = <$fh>; close $fh; } @records = @{decode_json($json)}; #sort the array @records and assign line number # @records = sort{ $b->{event_age} <=> $a->{event_age} } @records; for my $i (0 .. $#records) { $records[$i]->{line} = $i + 1; } #End# print Dumper \@records;
reddataout.json
[{"ticketnum":"123","event_age":1,"visible":"Yes"},{"ticketnum":"32"," +event_age":2,"visible":"Yes"},{"ticketnum":"98","event_age":3,"visibl +e":"Yes"},{"ticketnum":"45","event_age":4,"visible":"Yes"},{"ticketnu +m":"65","event_age":5,"visible":"Yes"},{"ticketnum":"67","event_age": +6,"visible":"Yes"},{"ticketnum":"56","event_age":7,"visible":"Yes"},{ +"ticketnum":"123","event_age":8,"visible":"Yes"},{"ticketnum":"123"," +event_age":9,"visible":"Yes"},{"ticketnum":"09","event_age":10,"visib +le":"Yes"},{"ticketnum":"16","event_age":11,"visible":"Yes"},{"ticket +num":"32","event_age":12,"visible":"Yes"},{"ticketnum":"123","event_a +ge":13,"visible":"Yes"},{"ticketnum":"123","event_age":14,"visible":" +Yes"}]
Thank you
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Break Array loop
by hippo (Archbishop) on Nov 02, 2017 at 12:12 UTC | |
|
Re: Break Array loop
by Discipulus (Canon) on Nov 02, 2017 at 12:12 UTC | |
|
Re: Break Array loop
by 1nickt (Canon) on Nov 02, 2017 at 12:49 UTC |