summaryrefslogtreecommitdiffabout
path: root/lib/SlackBuild/Request/Loader/file.pm
blob: 2a8cae64bd8143b443a220b3b3429e085e45d161 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package SlackBuild::Request::Loader::file;
use strict;
use warnings;
use JSON;
use YAML ();
use Carp;

our $PRIORITY = 10;

sub Load {
    my ($class, $reqname) = @_;
    if (-f $reqname) {
	local $/ = undef;
	open(my $fd, $reqname) or croak "can't open file $reqname: $!";
	my $string = <$fd>;
	close $fd;
	if ($string =~ /^\{/) {
	    return decode_json($string);
	}
	return YAML::Load($string);
    }
}   

1;

Return to:

Send suggestions and report system problems to the System administrator.