#!/bin/perl # credentials / environment variables $ORACLE_HOME="/u01/app/oracle/product/10.2.0.4"; $ORACLE_SID=qaecom1; $sqlplus="/u01/app/oracle/product/10.2.0.4/bin/sqlplus"; $USERNAME=dbuser; $PASS=pass; $SID=${ORACLE_SID}; # Get all the data at once @TSPACES=`$sqlplus -s -l $USERNAME/$PASS@$SID \@/opt/bin/ops/mlb_tablespace.sql`; # Now split the 4 columns you want into separate arrays, # and then join those arrays in the order you want: { my (@col1, @col2, @col3, @col4); for (@TSPACES) { my @cols = split; push @col1, $cols[0]; push @col2, $cols[1]; push @col3, $cols[2]; push @col4, $cols[3]; } @TSPACES = (@col1, @col2, @col3, @col4); } # ... the rest of your script