Guest User

Untitled

a guest
Oct 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3.  
  4. my @comparanda;
  5. my @similar;
  6. my $opts = {};
  7.  
  8. @similar = grep { 0 == ($a->{$opts->{'name'}} cmp $b->{$opts->{'name'}}) } @comparanda; # case 1 - this is what I mean
  9. @similar = grep { (0 == $a->{$opts->{'name'}}) cmp $b->{$opts->{'name'}} } @comparanda; # case 2 - I can see why perl might think this
  10. @similar = grep { 0 == $a->{$opts->{'name'}} cmp $b->{$opts->{'name'}} } @comparanda; # case 3 is either 1 or 2
  11. # syntax error at parse-error.pl line 10, near "} cmp"
  12. # Is this because it is ambiguous, or because it thinks the grep ends at "} cmp"?
  13. # NB that cmp and == have same associativity
  14. # Testing with other operators indicates that associativity seems to be the problem.
  15. # So why does perl not indicate this? Syntax error seems to be an unhelpful way of saying "I can't determine the order of operations here".
Add Comment
Please, Sign In to add comment