http://qs1969.pair.com?node_id=1086115

igoryonya has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am breaking my head, why this works:
if(@files && ! scalar keys %tree){$isChanged = 1;} else{foreach my $file (@files){$isChanged = 1 && last if( grep { $ +files_cached{'stats'}{$file}{$_} != $params->{'files'}{'stats'}{$file +}{$_} } ('mtime', 'ctime', 'size') );}}
, but this gives a syntax error:
(@files && ! scalar keys %tree)? ($isChanged = 1): (foreach my $file (@files){$isChanged = 1 && last if( grep { $file +s_cached{'stats'}{$file}{$_} != $params->{'files'}{'stats'}{$file}{$_ +} } ('mtime', 'ctime', 'size') )});
...?...
I checked and rechecked, but didn't find any paretacy or semicolon missing or extra.
Thanx in advance.
Here is an uncondenced version of the if code:
if(@files && ! scalar keys %tree){ $isChanged = 1; }else{ foreach my $file (@files){ $isChanged = 1 && last if( grep { $files_cached{'stats'}{$file +}{$_} != $params->{'files'}{'stats'}{$file}{$_} } ('mtime', 'ctime', +'size') ); } }

New question:
I tried to convert an expression to using map:

(@files && ! scalar keys %tree)? ($isChanged = 1): (map { my $file = $_; if( grep { $files_cached{'stats'}{$file}{$_} + != $params->{'files'}{'stats'}{$file}{$_} } ('mtime', 'ctime', 'size +') ){$isChanged = 1; last;} } @files);
Now I'm curious, I cannot break out of map execution in the middle, using last or some other means. It will process an entire list to the end? It appears that the last statement in the above code will break out of the loop, containing the map command, not from the map itself, so, I've had to remove last from the code above:
(@files && ! scalar keys %tree)? ($isChanged = 1): (map { my $file = $_; $isChanged = 1 if( grep { $files_cached{'sta +ts'}{$file}{$_} != $params->{'files'}{'stats'}{$file}{$_} } ('mtime', + 'ctime', 'size') ) } @files);
Am I correct, if so, is there actually a way to breakout of map?