$output = $cli->cmd("/usr/mysql/bin/mysql -E -uuser -ppass -D targetdb -e \"select * from table;\" | tail -2"); $temp = $output; print "\ntemp\n----------------\n$temp\n"; my ($LSV, $LSN) = $temp =~ m/^.*: (\w+).*: (\w+)/s; print "LSV: $LSV\nLSN: $LSN\n"; #### temp ---------------- version_name: dsmgt_03_03 schema_name: dsmgt_03 LSV: dsmgt_03_03 LSN: dsmgt_03