in reply to eval & variable names?
Slightly off topic but you can also use an anonymous function rather than the eval. This is what I quickly came up with:
#!/bin/env perl use strict; use warnings; use 5.012; my ($a, $b, $c); $a = $b = $c = 0; foreach my $v (qw/a b c/) { func($v); } sub func { my $in = shift; say "passed in: $in"; print "returned: "; return sub { my $in = shift; say $in x 2; }->($in); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: eval & variable names?
by ricDeez (Scribe) on Jan 21, 2012 at 01:50 UTC |