Re: combine hashes

2015-11-07 Thread Moritz Lenz
On 11/07/2015 10:17 AM, Marc Chantreux wrote:
> hello Moritz, 
> 
> On Sat, Nov 07, 2015 at 08:17:21AM +0100, Moritz Lenz wrote:
>> my %x = < login jdoe first john last doe >;
>> my %y = flat (:enable, %x< login first >:p);
> 
> i tried :p but the thing is i was searching for something straight as
> the perl5 
> 
> my %y = (%x, qw( enable 1 ));
> 
> si i really loved  
> 
> my %x = < login jdoe first john last doe >;
> my %y = ( :enable, %x< login first >:p);  
> 
> to work. thanks for showing me this working code. 
> 
> actually, it rises a new question to me: why the parenthesis around
> flat are mandatory?
> 
> my %x = < login jdoe first john last doe >;
> my %y = flat (:enable, %x< login first >:p);
> 
> is ok but 
> 
> my %x = < login jdoe first john last doe >;
> my %y = flat :enable, %x< login first >:p;
> 
> give me 
> 
>> first => john, last => doe, login => jdoe
>> Unexpected named parameter 'enable' passed

Because some of the pair literal syntaxes (:enable, :enable(1), enable
=> 1, but for example not "enable" => 1) are also used for named
arguments, and sub flat doesn't want a named argument.

Putting the parens around it force it not be a named argument.

Cheers,
Moritz


Re: combine hashes

2015-11-07 Thread Marc Chantreux
hello, 

> Putting the parens around it force it not be a named argument. 

ok .. to make sure i understand: if flat had a :enable named parameter,
the way to use it to get

{:enable{True}, :ok }

with the named parameter to False, would it be 

my %x = :ok;
flat ( enable => True, %x ) :!enable;   


regards 


-- 
Marc Chantreux (eiro on github and freenode)
http://eiro.github.com/
http://eiro.github.com/atom.xml
"Don't believe everything you read on the Internet"
-- Abraham Lincoln


Re: combine hashes

2015-11-07 Thread Marc Chantreux
that one is crap too. again: i'm sorry 

On Sat, Nov 07, 2015 at 10:13:17AM +0100, Marc Chantreux wrote:
> hello Moritz, 
> 
> On Sat, Nov 07, 2015 at 08:17:21AM +0100, Moritz Lenz wrote:
> > my %x = < login jdoe first john last doe >;
> > my %y = flat (:enable, %x< login first >:p);
> 
> i tried :p but the thing is i was searching for something straight as
> the perl5 
> 
> my %y = (%x, qw( enable 1 ));
> 
> si i really loved  
> 
> my %x = < login jdoe first john last doe >;
> my %y = ( :enable, %x< login first >:p);  
> 
> to work.
> 
> > first => john, last => doe, login => jdoe
> > Odd number of elements found where hash initializer expected
>   in block  at :1
> 
> 
> 
> 
> > ===SORRY!=== Error while compiling 
> Variable '%x' is not declared
> at :1
> --> my %y = :enable, ⏏%x< login first >:p; 
> 
> my %x = < login jdoe first john last doe >;
> 
> 
> > say %y.perl;# {:enable, :first("john"), 
> > :login("jdoe")}
> > 
> > Cheers,
> > Moritz
> 
> -- 
> Marc Chantreux (eiro on github and freenode)
> http://eiro.github.com/
> http://eiro.github.com/atom.xml
> "Don't believe everything you read on the Internet"
> -- Abraham Lincoln

-- 
Marc Chantreux (eiro on github and freenode)
http://eiro.github.com/
http://eiro.github.com/atom.xml
"Don't believe everything you read on the Internet"
-- Abraham Lincoln


Re: combine hashes

2015-11-07 Thread Marc Chantreux
hello Moritz, 

On Sat, Nov 07, 2015 at 08:17:21AM +0100, Moritz Lenz wrote:
> my %x = < login jdoe first john last doe >;
> my %y = flat (:enable, %x< login first >:p);

i tried :p but the thing is i was searching for something straight as
the perl5 

my %y = (%x, qw( enable 1 ));

si i really loved  

my %x = < login jdoe first john last doe >;
my %y = ( :enable, %x< login first >:p);  

to work. thanks for showing me this working code. 

actually, it rises a new question to me: why the parenthesis around
flat are mandatory?

my %x = < login jdoe first john last doe >;
my %y = flat (:enable, %x< login first >:p);

is ok but 

my %x = < login jdoe first john last doe >;
my %y = flat :enable, %x< login first >:p;

give me 

> first => john, last => doe, login => jdoe
> Unexpected named parameter 'enable' passed

regards 


-- 
Marc Chantreux (eiro on github and freenode)
http://eiro.github.com/
http://eiro.github.com/atom.xml
"Don't believe everything you read on the Internet"
-- Abraham Lincoln