Maybe this way:

@bet1 = (0,0,0,0);
@bet2 = (0,0,0,1);
@bet3 = (0,0,1,0);

 $random_bet_position = int(rand(3) + 1);

 $name = 'bet' . $random_bet_position;
 @selected_bet = @{$name};



-----Original Message-----
From: jj mahoney [mailto:itshardtoget...@hotmail.com] 
Sent: Monday, March 28, 2011 4:28 PM
To: beginners@perl.org
Subject: problem with naming of variables


Hi, How do I name this variable correctly, @{bet$random_bet_position);
With regards to the script below, @selected_bet is suppose to select either 
@bet1, @bet2 or @bet3 depending on the chosen number held by 
$random_bet_position, so how do I do this? Thanks
 
@bet1 = (0,0,0,0);
@bet2 = (0,0,0,1);
@bet3 = (0,0,1,0);
 
$random_bet_position = int(rand(3) + 1);
 
@selected_bet = @{bet$random_bet_position);                                     
  

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to