#!/usr/bin/perl -w package mypackage; use Data::Alias; our $local_varnames = 'qw( $a $b $c )'; our $len_local_varnames; { $len_local_varnames= eval "local @_=($local_varnames)" } sub mysub { my $this=shift; my @localspace; $#localspace = $len_local_varnames-1; # <-doesn't work to pre-allocate array $this->{localvars}= \@localspace; alias my ($a, $b, $c) = @localspace; ($a, $b, $c) = (1, 2, 3); # (fails because no space alloc'ed to localspace) #both print wrong/bad values printf "lsp[1]=%d\n",$localspace[1]; printf "b=%d\n",$this->{localvars}->[1]; } &mysub;