in reply to passing arguments to a shell script in a here document passed to system() ?

I propose using set builtin function of bash before pasting your code. You can adjust this code to receive a list of args, I guess:
#! /usr/bin/perl sub whatever { my ($arg1,$arg2)=@_; system << "ARGS" . <<'SCRIPT'; if [ -n "$arg1" ] then set $arg1 $arg2 fi ARGS date echo "what about this?" echo $1 $2 SCRIPT } whatever $ARGV[0], $ARGV[1];
Or more generic :
#! /usr/bin/perl sub whatever { system << "ARGS" . <<'SCRIPT'; if [ -n "@_" ] then set @_ fi ARGS date echo "what about this?" echo $* SCRIPT } whatever @ARGV;