I am lost in how to "variablize" this.
Working code:
use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new("demo.xls"); my $worksheet_BOB = $workbook->add_worksheet('BOB'); my $worksheet_SUE = $workbook->add_worksheet('SUE'); $worksheet_BOB->write('A2', "Bob is here"); $worksheet_SUE->write('A2', "Sue is here"); __END__
What I want do do is make the _BOB a variable and loop through and array to build the worksheets. and then be able to reference the writes with the variable names.Below may not be syntactically correct but functional what I want to do
use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new("demo.xls"); my @PEOPLE = ("BOB" , "SUE", "JOHN" ); foreach (@PEOPLE) { my $worksheet_$_ = $workbook->add_worksheet('$_'); } $NAME = "BOB" $worksheet_$NAME->write('A2', "$NAME is here"); $NAME= "SUE" $worksheet_$NAME->write('A2', "$NAME is here"); __END__
In reply to variable in variables by ohgary
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |