Re: wantarray and Tied Hashed

2001-05-25 Thread Paul Makepeace
On Thu, May 24, 2001 at 04:35:52PM +0100, Cross David - dcross wrote: my @array = $h{two}; I bumped into this in 1997 and became convinced list contexts aren't propagated to the effective sub call. If you look at the above line, there's something very odd seeming about it anyway, and it's not

Re: wantarray and Tied Hashed

2001-05-25 Thread Simon Cozens
On Thu, May 24, 2001 at 11:28:27AM +0100, Cross David - dcross wrote: my @array = $h{two}; ^ In perl 5 at least, *this* is your scalar context. -- Little else matters than to write good code. -- Karl Lehenbauer

RE: wantarray and Tied Hashed

2001-05-25 Thread Cross David - dcross
From: Simon Cozens [mailto:[EMAIL PROTECTED]] Sent: Friday, May 25, 2001 12:02 PM On Thu, May 24, 2001 at 11:28:27AM +0100, Cross David - dcross wrote: my @array = $h{two}; ^ In perl 5 at least, *this* is your scalar context. Good point. But even if I change it to: my @array

Re: wantarray and Tied Hashed

2001-05-25 Thread David Cantrell
On Fri, May 25, 2001 at 12:15:44PM +0100, Cross David - dcross wrote: Anyway, as I said before, you can work around it with my @array = tied(%h)-FETCH('two'); If anyone is interested, Tie::Hash::Regex is currently winging its way to your favourite CPAN mirror. I wonder, could you do

Re: wantarray and Tied Hashed

2001-05-25 Thread David Cantrell
On Fri, May 25, 2001 at 12:36:59PM +0100, Cross David - dcross wrote: From: David Cantrell [EMAIL PROTECTED] I wonder, could you do some magic with the calling stack so that your FETCH can Do The Right Thing? Or, I could just accept that I'm a BAD MAN who is trying to PERVERT PERL in

Re: wantarray and Tied Hashed

2001-05-25 Thread Piers Cawley
David Cantrell [EMAIL PROTECTED] writes: On Fri, May 25, 2001 at 12:36:59PM +0100, Cross David - dcross wrote: From: David Cantrell [EMAIL PROTECTED] I wonder, could you do some magic with the calling stack so that your FETCH can Do The Right Thing? Or, I could just accept

wantarray and Tied Hashed

2001-05-24 Thread Cross David - dcross
Apologies for dragging us off-topic again... Am I missing something obvious here? #!/usr/bin/perl -w use strict; package Tie::Hash::Test; use Tie::Hash; use vars qw(@ISA); @ISA = 'Tie::StdHash'; sub FETCH { print wantarray is , wantarray ? true\n : false\n; return $_[0]-{$_[1]}; }

RE: wantarray and Tied Hashed

2001-05-24 Thread Cross David - dcross
[snip] An update - Calling FETCH like this: $scalar = tied(%h)-FETCH('one'); @array = tied(%h)-FETCH('two'); Does the 'right' thing. So it's certainly something in the tie interface. Dave... [contemplating searching the perl source code] -- The information contained in this

Re: wantarray and Tied Hashed

2001-05-24 Thread David Cantrell
On Thu, May 24, 2001 at 11:28:27AM +0100, Cross David - dcross wrote: package Tie::Hash::Test; sub FETCH { print wantarray is , wantarray ? true\n : false\n; return $_[0]-{$_[1]}; } package main; my %h; tie %h, 'Tie::Hash::Test'; %h = (one = 1, two = 2); my $scalar =

Re: wantarray and Tied Hashed

2001-05-24 Thread David Cantrell
On Thu, May 24, 2001 at 12:28:39PM +0100, Cross David - dcross wrote: Calling FETCH like this: $scalar = tied(%h)-FETCH('one'); @array = tied(%h)-FETCH('two'); Does the 'right' thing. So it's certainly something in the tie interface. Well yes, because you're just calling a plain ol'

RE: wantarray and Tied Hashed

2001-05-24 Thread Cross David - dcross
From: David Cantrell [EMAIL PROTECTED] Sent: Thursday, May 24, 2001 1:57 PM On Thu, May 24, 2001 at 11:28:27AM +0100, Cross David - dcross wrote: package Tie::Hash::Test; sub FETCH { print wantarray is , wantarray ? true\n : false\n; return $_[0]-{$_[1]}; } package main;