Re: smart matching

2011-10-06 Thread John SJ Anderson
On Thu, Oct 6, 2011 at 03:10, Shlomi Fish wrote: > Furthermore, I think you can only put when inside given and not arbitrary > code, > and that "when()" operates on the datum that was given to given(). I don't think there's any restriction on what code can be inside the 'given' block -- at least

Re: smart matching

2011-10-06 Thread timothy adigun
Hi Chris, I think you will need to work on your code to make it better or maybe this is just a dirty codes for practice. If not, there are some stuff you may have to weed out...some of which Shlomi Fish mentioned. However, to make your code work as you suppose, please check this little addition a

Re: smart matching

2011-10-06 Thread Shlomi Fish
On Wed, 5 Oct 2011 23:44:21 -0500 Chris Stinemetz wrote: > trying to learn smart matching in an exercise. > > Why does this program output "odd" when I input an even number? > A few comments on your code. > Thank you, > > Chris > > #!/usr/bin/perl >

smart matching

2011-10-05 Thread Chris Stinemetz
trying to learn smart matching in an exercise. Why does this program output "odd" when I input an even number? Thank you, Chris #!/usr/bin/perl use warnings; use strict; use 5.010; say "Checking the number <$ARGV[0]>"; my $favorite = 62; given( $ARGV[0] ) {

Re: Smart matching

2011-01-18 Thread Vladimir D Belousov
19.01.2011 0:43, Brian Fraser пишет: The smart match is no longer commutative - That was removed after 5.10.1, I think. http://www.learning-perl.com/?p=32 http://perldoc.perl.org/perlsyn.html#Smart-matching-in-detail Brian. Thank you! -- To unsubscribe, e-mail: beginners-unsubscr

Re: Smart matching

2011-01-18 Thread Brian Fraser
The smart match is no longer commutative - That was removed after 5.10.1, I think. http://www.learning-perl.com/?p=32 http://perldoc.perl.org/perlsyn.html#Smart-matching-in-detail Brian.

Re: Smart matching

2011-01-18 Thread Vladimir D Belousov
19.01.2011 0:09, Uri Guttman пишет: but why don't you just call exists on the hash key? there is no win to using smart matching for that. it is included for consistancy but it isn't needed for hash keys. I just want to understand how does it work :) -- To unsubscribe, e-mail:

Re: Smart matching

2011-01-18 Thread Uri Guttman
>>>>> "VDB" == Vladimir D Belousov writes: VDB> I'm trying to check whether the given key exists in the hash. smart matching is powerful and cool but why don't you just call exists on the hash key? there is no win to using smart matching for that. it is

Smart matching

2011-01-18 Thread Vladimir D Belousov
I'm trying to check whether the given key exists in the hash. The simple example: use feature ':5.10'; my %a = (a => 1, b => 2); say %a ~~ 'a' ? 'YES' : 'NO';# says NO -- why? say %a ~~ 'c' ? 'YES' : 'NO';# says NO say 'a' ~~ %a ? 'YES' : 'NO';# says YES say 'c' ~~ %a ? 'YES' : 'NO';