[Bps-public-commit] r10225 - bpsbuilder/BPB/lib/BPB

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Jan 2 15:33:19 EST 2008


Author: sunnavy
Date: Wed Jan  2 15:33:09 2008
New Revision: 10225

Added:
   bpsbuilder/BPB/lib/BPB/Util.pm

Log:
added Util.pm, I'd like the sub which actually exec outer program to live in this

Added: bpsbuilder/BPB/lib/BPB/Util.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Util.pm	Wed Jan  2 15:33:09 2008
@@ -0,0 +1,60 @@
+package BPB::Util;
+
+use warnings;
+use strict;
+use Carp;
+use IPC::Run qw//;
+
+sub run {
+    my $class          = shift;
+    my $cmd            = shift;
+    my $ignore_failure = shift;
+
+    my ( $in, $out, $err );
+    use Data::Dumper;
+    print Dumper $cmd;
+    IPC::Run::run( $cmd, \$in, \$out, \$err );
+    if ($?) {
+        if ($ignore_failure) {
+            return;
+        }
+        else {
+            die "command " . join( ' ', @$cmd ) . "failed: $?, $err";
+        }
+    }
+    else {
+        return ( $out, $err );
+    }
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+BPB::Util - 
+
+=head1 DESCRIPTION
+
+=head1 INCOMPATIBILITIES
+
+None reported.
+
+
+=head1 BUGS AND LIMITATIONS
+
+No bugs have been reported.
+
+=head1 AUTHOR
+
+sunnavy  C<< <sunnavy at bestpractical.com> >>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright 2007 Best Practical Solutions.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+



More information about the Bps-public-commit mailing list