[tpm] String matching at start or middle or end of list
Shlomi Fish
shlomif at shlomifish.org
Mon Apr 29 09:13:59 PDT 2013
Hi Mike,
On Mon, 29 Apr 2013 11:56:37 -0400
Mike Stok <mike at stok.ca> wrote:
> In terms of clarity I think that splitting the concerns doesn't add that much
> code
>
> @list = split /,/, $s;
> @matches = grep { $_ =~ /\Afoo\z/ } @list;
«$_ =~ /\Afoo\z/» can also be written as «/\Afoo\z/» or better yet as
«$_ eq 'foo'».
Regards,
Shlomi Fish
>
> @list could be eliminated if you like.
>
> Mike
>
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Original Riddles - http://www.shlomifish.org/puzzles/
There’s no point in keeping an idea to yourself since there’s a 10 to 1 chance
that somebody already has it and will share it before you.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
More information about the toronto-pm
mailing list