Created
July 25, 2014 15:28
-
-
Save colomon/c3123119436ad6c7db71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
original code: | |
sub read-file($filename) { | |
my $file = from-json($filename.IO.slurp); | |
CATCH { | |
default { | |
$file = []; | |
$*ERR.say: colored("Unable to read file $filename", "red"); | |
} | |
} | |
$file.map({ format-object($_) }).hash; # this line not executed after exception caught | |
} | |
Current code: | |
sub read-file($filename) { | |
my $file; | |
{ | |
$file = from-json($filename.IO.slurp); | |
CATCH { | |
default { | |
$file = []; | |
$*ERR.say: colored("Unable to read file $filename", "red"); | |
} | |
} | |
} | |
$file.map({ format-object($_) }).hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment