SI/tools.pm
changeset 13 2e3ad71484ea
parent 12 a1aee1136609
child 15 4e3753b998a9
--- a/SI/tools.pm	Mon Jan 18 20:35:27 2010 +0100
+++ b/SI/tools.pm	Sun Jan 17 13:54:10 2010 +0100
@@ -7,7 +7,7 @@
 use File::Find;
 use base "Exporter";
 
-our @EXPORT = qw(&run &verbose &find_by_devid);
+our @EXPORT = qw(&run &verbose &find_by_devid &cat);
 
 sub run(@) {
 	system(@_);
@@ -15,6 +15,13 @@
 	if $?;
 }
 
+sub cat($) {
+    my $fh = new IO::File $_[0] 
+	or die "Can't open $_[0]: $!\n";
+    return(<$fh>) if wantarray;
+    return join "", <$fh>;
+}
+
 my $last = "\n";
 sub verbose(@) { 
     print $last eq "\n" ? "" : " "