Using a 'Here Document' to build up a variable


from the "department of things for which I need working examples". Helps to avoid backlashing quotes and such, so a code readability "win".

Goal: the command line we'd like to build up

  ssh server1 "csession prdapp1 -U prd \"^ZTSS\""

Perl

  $svr = 'server1';
  $inst_prefix = 'prdapp';
  $inst_num = 1;
  $inst_db = 'prd';

  $cmd = <

Shell

  SVR='server1'
  INST_PREFIX='prdapp'
  INST_NUM=1
  INST_DB='prd'

  $CMD=`cat <


date: 01/30/2009