Guest User

Untitled

a guest
Dec 7th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.52 KB | None | 0 0
  1.         my $loader = sub {
  2.             my $slurp = '';
  3.  
  4.             {
  5.                 local $/ = undef;
  6.                 open my $config, '<', $self->configfile;
  7.                 $slurp = <$config>;
  8.                 close $config;
  9.             }
  10.  
  11.             return $slurp;
  12.         };
  13.  
  14.         # try json
  15.         try {
  16.             my $json = JSON->new;
  17.             $self->config( $json->decode( $loader->() ));
  18.         }
  19.         # try yaml
  20.         catch {
  21.             $self->config( Load $loader->() );
  22.         }
Add Comment
Please, Sign In to add comment