Return multiple values using for loop in perl

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.

@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.

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:

echo "Content-type: text/plain
 
"

Or is there more to the web aspect?