#!/usr/bin/env perl use strict; use warnings; use autodie; use constant { TESTS => 5, WAIT_RAND => 3, }; use PM_1133400_Shared qw{:WEB}; my $total_steps = get_total_steps(); my @queue; { local $| = 1; for (1 .. TESTS) { sleep int rand WAIT_RAND; my $rand_step = int rand $total_steps; if (-p FIFO) { open my $pipe_writer, '>', FIFO; if (@queue) { for (@queue) { print "WEB_SIM: FIFO Available! Piping from queue [$_]\n"; print $pipe_writer "$_\n"; } @queue = (); } print "WEB_SIM: FIFO Available! Piping new step [$rand_step]\n"; print $pipe_writer "$rand_step\n"; close $pipe_writer; } else { print "WEB_SIM: FIFO Unavailable! Queueing step [$rand_step].\n"; push @queue, $rand_step; } } }