Hi Monks!
I am stuck on this code. This is the best way to describe what I am trying to do.
I have a form with 3 options.
First option will select just random 2 elements of array @acc.
Second option I could attach a random 2 values either from array @sec or @third or from both and print the result.
I am hoping to get something like this:
e.g. AX1 - AX3 ( random 2 elements from array @acc.)
or AX1PB7 AX2PB8 ( 2 random values of the array @acc with 2 random values from array @sec, and so on if I add the option to add 2 more random element from @third.
I hope it explains, here if a test code:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
# Any Choice or combination coming from a form:
my $test1 = "1";
my $test2 = "";
my $test3 = "";
my @acc = ('AX1', 'AX2', 'AX3',);
my @sec = ('PB6', 'PB7', 'PB8',);
my @third = ('XC2', 'XC8', 'XC1',);
my $result;
for (my $l = 0; $l < @acc; ++$l) {
$result = $acc[rand @acc];
if($test2){
for (my $k = 0; $k < @sec; ++$k) {
my$c2 = $acc[$l];
my$week2 = $sec[$k];
$result = $acc[$l].$sec[$k];
}
}
=code
if($test3){
for (my $y = 0; $y < @third; ++$y) {
my $days = $acc[$l];
my $week = $sec[$k];
my $holy = $third[$y];
$result = $acc[$l].$sec[$k].$third[$y];
}
}
=cut
}
print " $result\n";
Thanks for looking!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.