If the
exec("/path/to/file.cgi") is meant to be called from a script that you run in a command-line shell, the easiest way to provide the cgi parameters to the cgi script that is being exec'd is to include them as a command-line arg, and in this case, it would be really important to use the "list" style invocation of exec():
my $cgiprog = '/path/to/filename.cgi';
my $cgiparams = 'action=task1&user=me';
exec( $cgiprog, $cgiparams );
Assuming that the cgi script being exec'd in this fashion is using the CGI module,
$ARGV[0] will automatically be treated as the QUERY_STRING.