#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use List::Util qw{ shuffle }; my @acc = qw( AX1 AX2 AX3 ); my @sec = qw( PB6 PB7 PB8 ); my @third = qw( XC2 XC8 XC1 ); my @options = @ARGV; # i.e. run as "script.pl 1 0 1" to set options 1 and 3 say join ' ', $options[0] ? (shuffle(@acc) )[ 0, 1 ] : (), # Output 2 random values from @acc. $options[1] ? (shuffle(@sec, @third))[ 0, 1 ] : (), # Output 2 random values from @sec and @third. $options[2] ? ('?') : (); # Replace ? by the expected output for option 3.