Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Help Changing use into require/import

by Anonymous Monk
on Mar 08, 2018 at 17:14 UTC ( [id://1210520]=note: print w/replies, xml ) Need Help??


in reply to Help Changing use into require/import

Generally in a case like this I use either BEGIN blocks or fully-qualified names, whichever seems appropriate. In this case the latter seems a better fit:

#!/usr/bin/env perl use strict; use warnings; my ( $stdout, $stderr, $errcode ); if (eval { require Capture::Tiny } ) { print "Using Capture::Tiny\n"; ( $stdout, $stderr, $errcode ) = Capture::Tiny::capture( sub { system "echo Hello, World | cat"; } ) } elsif (eval { require IPC::Run } ) { print "Using IPC::Run\n"; no warnings qw{ qw }; # Otherwise Perl complains about the comm +a IPC::Run::run( [ qw{ echo Hello, World } ], \'', '|', [ 'cat' ], \$stdout, \$stderr ); } print "STDOUT: $stdout";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1210520]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found