develooper Front page | perl.perl5.porters | Postings from November 2007

Re: [perl #46987] OO-call failures, autoviv-functions & testingtheir existence

Thread Previous
Josh Jore
November 1, 2007 17:45
Re: [perl #46987] OO-call failures, autoviv-functions & testingtheir existence
Message ID:
On Thu, Nov 01, 2007 at 10:08:58PM +0100, Dr.Ruud wrote:
} Linda W schreef:
} >      I would prefer Perl, continue to strive to be the (*usually*)
} > user-friendly language that it is, and try to do what the user
} > might have really been intending before throwing a fatal error.
} What do you think that "return \%data{@keys}" means? It pretty much
} looks to me like the user wants to return a reference to a hash slice.
} To make it sort of work, you could write it like I show below, but that
} involves copying, which might not be what the user wanted:
}     my %tmp;
}     @tmp{@keys} = @data{@keys};
}     return \%tmp;

To get what you want requires trickery. It's an array reference where
the elements are aliased back to the values in %data.

return sub { \@_ }->( @data{@keys } );


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About