diff options
Diffstat (limited to 'perl/lib/Nix/Utils.pm')
-rw-r--r-- | perl/lib/Nix/Utils.pm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/perl/lib/Nix/Utils.pm b/perl/lib/Nix/Utils.pm index 1e7e0b5afb2f..bc180e2a55b9 100644 --- a/perl/lib/Nix/Utils.pm +++ b/perl/lib/Nix/Utils.pm @@ -1,5 +1,8 @@ package Nix::Utils; +our @ISA = qw(Exporter); +our @EXPORT = qw(checkURL uniq writeFile readFile); + $urlRE = "(?: [a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*]+ )"; sub checkURL { @@ -17,3 +20,19 @@ sub uniq { } return @res; } + +sub writeFile { + my ($fn, $s) = @_; + open TMP, ">$fn" or die; + print TMP "$s" or die; + close TMP or die; +} + +sub readFile { + local $/ = undef; + my ($fn) = @_; + open TMP, "<$fn" or die; + my $s = <TMP>; + close TMP or die; + return $s; +} |