in reply to change value in run time
{ 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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: change value in run time
by xiaoyafeng (Deacon) on Oct 23, 2008 at 16:52 UTC |