in reply to Set::Scalar saves you from hash acrobatics

somebody to remember this article about overloading at perl.com?

i patched Set::Scalar a little bit some time ago to support '{1 2 3}' and '{1 .. 3}' notions. code is broken, but should suffice for some own experiments ... just put it somewhere at the top of it, and off you go. beware to throw code far, far away afterwards ;-) (where no code has gone before)

use overload; my %_const_handlers = ( q => sub { if ($_[0] =~ m/^\{.*\}$/) { my $str = substr $_[0], 1, length ($_[0]) - 2; my @elems = split /\s+/, $str; if (defined $elems[1] and $elems[1] eq "..") { @elems = $elems[0] .. $elems[2]; } return __PACKAGE__->new (@elems) || $_[1]; } else { return $_[1]; } }, ); sub import { overload::constant %_const_handlers; }

kabel@linux:~> perl -w -MSet::Scalar my $some_ints = '{1 .. 4}'; my $other_ints = '{3 .. 8}'; my $all_ints = $some_ints + $other_ints; print '[', join( ', ', sort $all_ints->members ), "]\n"; print $Set::Scalar::VERSION, " ", $], $/; [1, 2, 3, 4, 5, 6, 7, 8] 1.17 5.008 kabel@linux:~>