Hi all, We are in the process of changing UNIX and MS-DOS scripts into Perl, mostly UNIX scripts and there are a lot of codes that uses the <<EOF and EOF pair. Am just wanting to know if there are better alternative to what I've been doing so far.
Example of these are as below: Example 01: UNIX script version: num_records=`sqlplus -S "/as sysdba" << EOF | sed 's# *##g' set heading off set feedback off set pages 0 set echo off set trimspool on select count(1) from all_tables where owner = '${owner}'; exit EOF` Changed to Perl - this work alright, is there a better way of doing this? $owner = 'SYSMAN'; $num_records=`sqlplus -S "/as sysdba" << EOF | sed 's# *##g' set heading off set feedback off set pages 0 set echo off set trimspool on select count(1) from all_tables where owner = '${owner}'; exit EOF`; print $num_records; exit 0; Example 02: UNIX script version: sqlplus -S "/as sysdba" << EOF REM SET SPACE 0; REM SET LINESIZE 1000; REM SET PAGESIZE 500; REM SET ECHO OFF; REM SET TRIMSPOOL OFF; REM SET FEEDBACK OFF; REM SET VERIFY OFF; REM SET COLSEP "^"; alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'; set trimspool on set pagesize 300 set linesize 250 col instance format a10 col owner format a10 col segment_name format a30 col segment_type format a15 col created format a20 col last_ddl_time format a20 col mbytes format 999999.99 spool ${tmpfile_01} set heading off select '<--START--> Today is ==> ' || sysdate from dual ; set heading on prompt prompt - MAX DATETIME prompt select max(datetime), max(ackdatetime), max(time), max(fst) from genco_owner.dispatch; prompt prompt - MIN DATETIME prompt select min(datetime), min(ackdatetime), min(time), min(fst) from genco_owner.dispatch; set heading off select '<--END--> Today is ==> ' || sysdate from dual ; spool off EOF Changed to Perl - this work alright, is there a better way of doing this? `sqlplus -S "/as sysdba" << EOF REM SET SPACE 0; REM SET LINESIZE 1000; REM SET PAGESIZE 500; REM SET ECHO OFF; REM SET TRIMSPOOL OFF; REM SET FEEDBACK OFF; REM SET VERIFY OFF; REM SET COLSEP "^"; alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'; set trimspool on set pagesize 300 set linesize 250 col instance format a10 col owner format a10 col segment_name format a30 col segment_type format a15 col created format a20 col last_ddl_time format a20 col mbytes format 999999.99 spool tmpfile.01 set heading off select '<--START--> Today is ==> ' || sysdate from dual ; set heading on prompt prompt - MAX DATETIME prompt select max(datetime), max(ackdatetime), max(time), max(fst) from genco_owner.dispatch; prompt prompt - MIN DATETIME prompt select min(datetime), min(ackdatetime), min(time), min(fst) from genco_owner.dispatch; set heading off select '<--END--> Today is ==> ' || sysdate from dual ; spool off EOF` Example 03: UNIX script version: cat /dev/null > eol_unix.out cat >> eol_unix.out << EOF `( ls ; echo ; echo "+----------------------------------------------+" ; echo ; df ; echo ; echo "+----------------------------------------------+" ; echo ; uname -a )` EOF Changed to Perl - this work alright, is there a better way of doing this? open(OUTPUT, " > eol_unix.out") or die $!; print OUTPUT <<`EOL`; ls echo echo "+----------------------------------------------+" echo df echo echo "+----------------------------------------------+" echo uname -a EOL Any feedback will be very much appreciated. Thanks in advance