Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Help Changing use into require/import

by Anonymous Monk
on Mar 08, 2018 at 17:14 UTC ( #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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210520]
and dust plays in a shaft of sunlight...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2018-07-21 21:44 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (450 votes). Check out past polls.