Skip to content

Instantly share code, notes, and snippets.

@frioux
Created March 7, 2009 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frioux/75293 to your computer and use it in GitHub Desktop.
Save frioux/75293 to your computer and use it in GitHub Desktop.
module Ghetto;
sub run($cmd) {
# create a random filename to store output in
my $tmp = ".tmp-{(1..100).pick}-ghetto";
# use the real run command, :: means root namespace
::run("$cmd > '$tmp'");
# open the file
my $data_file = open($tmp, :r);
# put the data from the file into a variable
my $val;
for =$data_file { $val ~= "$_\n"; }
# delete the file
unlink($tmp);
#gimme my data!
return $val;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment