# Return multiple values using for loop in perl

**URL:** <https://community.unix.com/t/return-multiple-values-using-for-loop-in-perl/320148>\
**Category:** Shell Programming and Scripting\
**Created:** [November 20, 2012, 11:49pm UTC](https://community.unix.com/t/return-multiple-values-using-for-loop-in-perl/320148 "2012-11-20T23:49:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liyakathali](https://community.unix.com/letter_avatar/liyakathali/32/6_22734026db12803ebb3e059622ac3534.png) [@liyakathali](https://community.unix.com/u/liyakathali)\
**Post date:** [November 20, 2012, 11:49pm UTC](https://community.unix.com/t/return-multiple-values-using-for-loop-in-perl/320148/1 "2012-11-20T23:49:45Z")

</div>

I am using a for loop to copy files from say DIR1 and DIR2 to DIR3.I have to check whether files are copied from DIR1 and DIR2 and print the respective message.

```nohighlight
@path=("$DIR1","$DIR2");
foreach (@path) {
$rc=system("cp $_/*xml $DIR3");
if ($rc == 0)
        {
print "Files were copied successfully from $_\n";
        }
else
        {
print "Files were not copied successfully from $_\n";
        }
 }

```

The above script works fine in perl but not working in perl web service.In perl web service the copy commands are executing but I am not able to print message for each directory individually.

Any help would be appreciated.

Thanks,  
Liyakath.

---

<div class="post-metadata">

**Author:** ![DGPickett](https://community.unix.com/letter_avatar/dgpickett/32/6_22734026db12803ebb3e059622ac3534.png) [@DGPickett](https://community.unix.com/u/DGPickett)\
**Post date:** [November 23, 2012, 4:15pm UTC](https://community.unix.com/t/return-multiple-values-using-for-loop-in-perl/320148/2 "2012-11-23T16:15:11Z")

</div>

Did you write all the header lines for the http and chosen content-type for the web service. A CGI web server and browser is not a terminal ! You might just, first, do the perl equivalent of:

```nohighlight
echo "Content-type: text/plain
 
"

```

Or is there more to the web aspect?
