Re: lvalue hash slice

2003-10-03 Thread A. Pagaltzis
* Gaal Yahas [EMAIL PROTECTED] [2003-10-03 11:24]: Two points about this. First, the lvalue ?: is kinda, uh, Perlish to the extreme. Yeah. It tends to be a powerful obfuscant too. I had to look thrice at your code (then went oh, duh!). For more than two or maybe three lvalues to switch between,

Re: lvalue hash slice

2003-10-02 Thread Gaal Yahas
On Thu, Oct 02, 2003 at 09:39:53PM -, [EMAIL PROTECTED] wrote: Has this always worked? I coulda sworn I tried it in the past with no luck... It has always worked since I started Perl (sometime around 5.4). I'd make an educated guess that it has been available at least as long as

Re: lvalue hash slice

2003-10-01 Thread Tony Bowden
On Tue, Sep 30, 2003 at 11:11:17PM +0100, Dave Mitchell wrote: (I tried it on Perl 1.0.15, but unfortunately it didn't like it. I even managed to get it to coredump. Perhaps I should submit a bug report? :-) Well, Schwern is theoretically maintaining the 1.x track, so you probably should :)

lvalue hash slice

2003-09-30 Thread Gaal Yahas
I like hash slices: ($one, $two, $three) = @hash{ qw/aaa bbb ccc/ }; Sadly, this doesn't work as an lvalue: @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);# WRONG But this does: push @values, reverse @keys; $hash{ $values[$#values - $_] } = $values[$_] for 0 ..

Re: lvalue hash slice

2003-09-30 Thread Uri Guttman
GY == Gaal Yahas [EMAIL PROTECTED] writes: GY I like hash slices: GY ($one, $two, $three) = @hash{ qw/aaa bbb ccc/ }; GY Sadly, this doesn't work as an lvalue: GY @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);# WRONG works fine for me. perl -le '@h{ qw/aaa bbb/ }=

Re: lvalue hash slice

2003-09-30 Thread A. Pagaltzis
* Gaal Yahas [EMAIL PROTECTED] [2003-09-30 20:14]: Sadly, this doesn't work as an lvalue: @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three); I use that *all* the time. The problem is not with Perl here.. -- Regards, Aristotle If you can't laugh at yourself, you don't take life seriously

Re: lvalue hash slice

2003-09-30 Thread Gaal Yahas
On Tue, Sep 30, 2003 at 08:12:54PM -, I wrote: Sadly, this doesn't work as an lvalue: @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);# WRONG And evidently it does! Oops! :) Has this always worked? I coulda sworn I tried it in the past with no luck... Okay, score down for

Re: lvalue hash slice

2003-09-30 Thread Dave Mitchell
On Tue, Sep 30, 2003 at 11:53:01PM +0300, Gaal Yahas wrote: On Tue, Sep 30, 2003 at 08:12:54PM -, I wrote: Sadly, this doesn't work as an lvalue: @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);# WRONG And evidently it does! Oops! :) Has this always worked? I coulda

Re: lvalue hash slice

2003-09-30 Thread Ronald J Kimball
On Tue, Sep 30, 2003 at 11:07:24PM +0300, Gaal Yahas wrote: I like hash slices: ($one, $two, $three) = @hash{ qw/aaa bbb ccc/ }; Sadly, this doesn't work as an lvalue: @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);# WRONG That actually does work. Ronald

Re: lvalue hash slice

2003-09-30 Thread schwern
On Tue, Sep 30, 2003 at 11:07:24PM +0300, Gaal Yahas wrote: I like hash slices: ($one, $two, $three) = @hash{ qw/aaa bbb ccc/ }; Sadly, this doesn't work as an lvalue: @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);# WRONG It doesn't? $ perl -wle '$one=1; $two=2;

Re: lvalue hash slice

2003-09-30 Thread Jayaprakash Rudraraju
1:32pm, IP packets from [EMAIL PROTECTED] delivered: On Tue, Sep 30, 2003 at 11:07:24PM +0300, Gaal Yahas wrote: I like hash slices: ($one, $two, $three) = @hash{ qw/aaa bbb ccc/ }; Sadly, this doesn't work as an lvalue: @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);