Now that I have the earlier snippet working (and thank you to all who
helped), I am working on shuffling my array. Basically, the array is
a list of names in the order they will receive a job assignment.
Every third week, I want to shuffle the order. I have tested the
basics of shuffling the array, and it works just fine. In this code
snippet, my @group has already been defined:
---begin snippet---
my @oddgroup = @group[1,3];
my @evengroup = @group[0,2];
my @newgroup = (@oddgroup, @evengroup);
open CONTROL2, '>test.cont';
print CONTROL2 "Group: @group\n";
print CONTROL2 "OddGroup: @oddgroup\n";
print CONTROL2 "EvenGroup: @evengroup\n";
print CONTROL2 "NewGroup: @newgroup\n";
close CONTROL2;
---end snippet---
This works just fine. But when I add the mechanism to shuffle every
third week, I have problems. The code, which has already set my
@group and my $switch is
---begin snippet
if ($switch % 3 == 0)
{
my @oddgroup = @group[1,3];
my @evengroup = @group[0,2];
my @newgroup = (@oddgroup, @evengroup);
}
else
{my @newgroup = @group};
open CONTROL2, '>test.cont';
print CONTROL2 "Group: @group\n";
print CONTROL2 "NewGroup: @newgroup\n";
close CONTROL2;
---end snippet---
When I run this, I get two error messages:
Possible unintended interpolation of @newgroup
Global symbol "@newgroup" requires explicit package name
>From reading man perldiag, I understand that the last message is
telling me that I either need to lexically scope @group, or declare
it beforehand or explicitly qualify it. But haven't I already
lexically scoped it? (My guess is that I haven't done that properly,
since I'm getting the error message; but I cannot figure out what is
wrong with my syntax.) And the other message I didn't find in
perldiag.
Please help.
Doug
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>