in reply to Re^5: Tidy up conditions
in thread Tidy up conditions
I've incorporated the // in my code like this:
Unfortunately, when the regex doesn't match, it seems to short-circuit, and this is printed:$item = 'Test'; $level = $access{$item} // ($item =~ /^([^:]+):/ && $access{"$1:*"}) // $access{'*'} // 999; print "level='$level'\n";
Any ideas why? I assume it's something to do with the line which contains the regex not being 'defined', but I'm not sure.
Meanwhile, I've worked around it by putting the regex first, like this:
And I think that's working (i.e. it prints "level='30'" in the above case).$access{'*'} = 30; $item = 'Test'; $item =~ /^([^:]+):/; $level = $access{$item} // $access{"$1:*"}) // $access{'*'} // 999; print "level='$level'\n";
Thanks again.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Tidy up conditions (false)
by tye (Sage) on Mar 21, 2015 at 03:28 UTC | |
by tel2 (Pilgrim) on Mar 21, 2015 at 04:26 UTC | |
|
Re^7: Tidy up conditions
by martin (Friar) on Mar 22, 2015 at 02:33 UTC | |
by tel2 (Pilgrim) on Jul 07, 2015 at 23:31 UTC | |
|
Re^7: Tidy up conditions
by Anonymous Monk on Mar 21, 2015 at 02:53 UTC | |
by tel2 (Pilgrim) on Mar 21, 2015 at 04:25 UTC |