Created
June 23, 2010 17:34
-
-
Save hinrik/450259 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/POE/Quickie.pm b/lib/POE/Quickie.pm | |
index 9ea4307..6f67550 100644 | |
--- a/lib/POE/Quickie.pm | |
+++ b/lib/POE/Quickie.pm | |
@@ -266,11 +266,16 @@ POE::Quickie - A lazy way to wrap blocking programs | |
=head1 SYNOPSIS | |
- use POE::Quickie; | |
+ use POE::Quickie 'quickie'; | |
sub handler { | |
my $heap = $_[HEAP]; | |
+ # the really lazy interface | |
+ my ($stdout, $stderr, $exit) = quickie(Program => ['foo', 'bar']); | |
+ print $output, "\n"; | |
+ | |
+ # the more involved interface | |
my $heap->{quickie} = POE::Quickie->new(); | |
$heap->{quickie}->run( | |
Program => ['foo', 'bar'], | |
@@ -297,6 +302,11 @@ It has some convenience features, such as killing processes after a timeout, | |
and storing process-specific context information which will be delivered with | |
every event. | |
+There is also an even lazier API which suspends the execution of your event | |
+handler and gives control back to POE while your task is running, the same | |
+way L<LWP::UserAgent::POE|LWP::UserAgent::POE> does. This is provided by the | |
+L<C<quickie_*>|/FUNCTIONS> functions which you can import. | |
+ | |
=head1 METHODS | |
=head2 C<new> | |
@@ -395,6 +405,42 @@ to the options to L<C<run>|/run>. | |
=back | |
+=head1 FUNCTIONS | |
+ | |
+These usage of these functions is modeled after the ones provided by | |
+L<Capture::Tiny|Capture::Tiny>, except we also give you the exit code. | |
+ | |
+All functions take the same arguments as the L<C<run>|/run> method, except | |
+for the B<'*Event'> and B<'Context'> arguments. As a special case, you can | |
+also call these functions with a single argument (a scalar or an arrayref). | |
+ | |
+ # these are equivalent | |
+ ($stdout, $stderr, $exit) = quickie('foo.pl'); | |
+ ($stdout, $stderr, $exit) = quickie(Program => 'foo.pl'); | |
+ | |
+ # ditto | |
+ ($stdout, $stderr, $exit) = quickie([qw(foo.pl bar)]); | |
+ ($stdout, $stderr, $exit) = quickie(Program => qw(foo.pl bar)]); | |
+ | |
+=head2 C<quickie> | |
+ | |
+Returns 3 values: the stdout, stderr, and exit code of the program. | |
+ | |
+=head2 C<quickie_tee> | |
+ | |
+Returns 3 values: the stdout, stderr, and exit code of the program. In | |
+addition, it will echo the stdout/stderr to your program's stdout/stderr. | |
+ | |
+=head2 C<quickie_merged> | |
+ | |
+Returns 2 values: the merged stdout & stderr, and exit code of the program. | |
+ | |
+=head2 C<quickie_tee_merged> | |
+ | |
+Returns 2 values: the merged stdout & stderr, and exit code of the program. | |
+In addition, it will echo the merged stdout & stderr to your program's | |
+stdout. | |
+ | |
=head1 AUTHOR | |
Hinrik E<Ouml>rn SigurE<eth>sson, [email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment