in reply to Avoiding reference of sub optimization
UPDATE: I'm still not sure if this should be considered a feature or a bug. It's not the same as with other "data" structures:A subroutine isn't a data structure. Note that the same happens with other literals:
If you really must create different addresses, use eval:#!/usr/bin/perl -l sub gen_arr { my $inner =shift; print my $outer = \"foo"; return $outer; } gen_arr gen_arr; __END__ SCALAR(0x9400bc4) SCALAR(0x9400bc4)
my $outer = eval "sub {1;}"; # Different address each time.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Avoiding reference of sub optimization
by LanX (Saint) on Mar 21, 2011 at 15:30 UTC | |
|
Re^2: Avoiding reference of sub optimization
by LanX (Saint) on Mar 21, 2011 at 15:05 UTC |