]> git.sur5r.net Git - i3/i3/blob - testcases/lib/i3test/Util.pm
remove debug.h from Makefile.am (#2581)
[i3/i3] / testcases / lib / i3test / Util.pm
1 package i3test::Util;
2 # vim:ts=4:sw=4:expandtab
3
4 use strict;
5 use warnings;
6 use v5.10;
7
8 use Exporter qw(import);
9 our @EXPORT = qw(
10     slurp
11 );
12
13 =encoding utf-8
14
15 =head1 NAME
16
17 i3test::Util - General utility functions
18
19 =cut
20
21 =head1 EXPORT
22
23 =cut
24
25 =head2 slurp($fn)
26
27 Reads the entire file specified in the arguments and returns the content.
28
29 =cut
30 sub slurp {
31     my ($file) = @_;
32     my $content = do {
33         local $/ = undef;
34         open my $fh, "<", $file or die "could not open $file: $!";
35         <$fh>;
36     };
37
38     return $content;
39 }
40
41 =head1 AUTHOR
42
43 Michael Stapelberg <michael@i3wm.org>
44
45 =cut
46
47 1