in reply to creating dynamically named 'my' variables
Wait a minute! You want to create variables given names by the user?!?!! That's pretty dangerous, unless you trust the user wholeheartedly.
Use a hash instead.
You can use symbolic references to do this:
my $bar="fred"; no strict refs; $$bar="ethel"; print $fred, "\n"; print $$bar, "\n";
but it doesn't work as a "my variable". In part I think because the scope is limited to within the eval. Ooutside the eval, the variable goes way.
I really don't recommend you do this, though.
|
|---|