igoryonya has asked for the wisdom of the Perl Monks concerning the following question:
, but this gives a syntax error: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') );}}
...?...(@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') )});
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:
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 = $_; if( grep { $files_cached{'stats'}{$file}{$_} + != $params->{'files'}{'stats'}{$file}{$_} } ('mtime', 'ctime', 'size +') ){$isChanged = 1; last;} } @files);
Am I correct, if so, is there actually a way to breakout of map?(@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);
|
---|