[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: exists $foo[7] and delete $foo[7]



Martyn Pearce wrote:

> The fact that pseudo-hashes have an implicit ordering could be useful
> here.  Would we define each/keys/values on a pseudo-hash to return the
> elements _in array order_ ?  Also, we could potentially utilize a next
> operator (okay, using the name C<next> would be bad, but...); something
> of the form: next @array, 7 to get the next existent element after /
> at-or-after element #7.  I could make use of that.

I would find use for this also. An ordered hash is something I
frequently need (I end up doing the likes of:

  %keys=map {push @keys, $_->[0]; @$_} (
    [COUNTRY			=> \&normaliseValue],
    [SERVICE			=> \&normaliseValue],
	...
    [REFERENCE			=> \&normaliseValue]
  );

which lacks elegance. The keys refer to fields in a tab-delimited file,
hence the need for ordering for transput).

C<next> and C<previous> are clearly not options, but how about defining
>> and << to apply to ordered aggregates?

	$foo[0]='bar';
	$foo[5]='baz';
	@foo >> 0 == 5

Pete
-- 
use Disclaimer::Standard;	# Motorola GSM Software Factory
my $phone='+44 1793 564450';	# "'Not twisted,' Salzy once said of
my $fax='+44 1793 566918';	#  her own passion, 'it is helical.
my $mobile='+44 7973 725120';	#  That sounds better.'"


Follow-Ups from:
Pete Jordan <pjordan1@email.mot.com>
References to:
John Macdonald <jmm@pickering.elegant.com>
Martyn Pearce <m.pearce@inpharmatica.co.uk>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]