package Foo; use strict; sub pdftotext { my $self = shift; my $args = join ' ', @_; my $output = qx{/usr/bin/pdftotext $args}; } 1; #### # Override the qx// operator to capture args to $qx_args my $qx_args; BEGIN { *CORE::GLOBAL::readpipe = sub { $qx_args = $_[0] } } # Load module that uses qx// use Foo; # Call method which will use our overridden qx// function Foo->pdftotext('/tmp/myfile.pdf'); # print arguments to qx// print "qx// args were: [$qx_args]\n";