{ my $r = sub { my $count = shift; return 'A' . $count . ':B' . $count; }; for ( @{$retrieve_ref} ) { $sheet->Range( $r->( $count++ ) )->{'Value'} = $_; } }
The main idea here is to make a sub that makes the value you want out of the variable you have. Since the sub is of such little use anywhere else, I've put it in a lexical scoped to a small block. I personally don't like map in void context, so I changed the loop to a for loop. There are, as always, ways to go extra terse here, but I was shooting for a modicum of readability. Gum it up however you like in your own code.
In reply to Re: change value in run time
by kyle
in thread change value in run time
by xiaoyafeng
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |