return1=`/path/to/script.pl arg1 arg2` return2=$(/path/to/script.pl arg1 arg2) #### return_newlines="$(/path/to/script.pl arg1 arg2)" #### #!/usr/bin/perl print $_, $/ for @ARGV; #### #!/bin/bash value=0 echo "value starts from $value" ./script.pl arg1 arg2 | while read line ; do value=$line echo "value is $value" done echo "after first while, value is $value" while read line ; do value=$line echo "value is $value" done <<<"$(./script.pl arg1 arg2)" echo "finally, value is $value" #### value starts from 0 value is arg1 value is arg2 after first while, value is 0 value is arg1 value is arg2 finally, value is arg2