Hi, any help here would be greatly appreciated. I'm new to programming and am unable to test anything while I'm at work.
Basically, I'm sending 400 people to a questionairre but I need each sequential person to get a different html page from a predefined array (1st user to A1.html, 2nd to A2.html etc.) until all elements in the array are exhausted, then reset the counter to 0. I've got the following code, but I'm afraid that since $n=0 is always executed, it will send all users to A1.html.
#!/usr/bin/perl
print "content-type: text/html \n\n";
print "<a href=";
#array of pages
@pages = qw(A1.html A2.html A3.html A4.html B1.html B2.html B3.html B4.html C1.html C2.html C3.html C4.html D1.html D2.html D3.html D4.html);
#element index counter
$n = 0;
#page delivered is sequential element in array
$deliver_page = @pages[$n]
#one iteration through the array
if ($n <= 15 {
print "$deliver_page>Click Here</a>";
$n++;
}
#end of array, start again
else {
$n = 0;
print "$deliver_page>Click Here</a>";
$n++;
}
}
Does anyone know if this will work? Or do I need to store and increase a number in a .txt file each time the script is called? I really appreciate any feedback. Thanks.
Basically, I'm sending 400 people to a questionairre but I need each sequential person to get a different html page from a predefined array (1st user to A1.html, 2nd to A2.html etc.) until all elements in the array are exhausted, then reset the counter to 0. I've got the following code, but I'm afraid that since $n=0 is always executed, it will send all users to A1.html.
#!/usr/bin/perl
print "content-type: text/html \n\n";
print "<a href=";
#array of pages
@pages = qw(A1.html A2.html A3.html A4.html B1.html B2.html B3.html B4.html C1.html C2.html C3.html C4.html D1.html D2.html D3.html D4.html);
#element index counter
$n = 0;
#page delivered is sequential element in array
$deliver_page = @pages[$n]
#one iteration through the array
if ($n <= 15 {
print "$deliver_page>Click Here</a>";
$n++;
}
#end of array, start again
else {
$n = 0;
print "$deliver_page>Click Here</a>";
$n++;
}
}
Does anyone know if this will work? Or do I need to store and increase a number in a .txt file each time the script is called? I really appreciate any feedback. Thanks.