#!/usr/local/perl510/bin/perl use strict; use warnings; use Data::Dumper; use IPC::Open3; my @plist = ( '/usr/bin/cat /etc/motd' ); sub ccmexec_nodie { my $command = $_[0]; my ($mystdin,$mystdout,$mystderr); my $pid = open3($mystdin,$mystdout,$mystderr,$command); my $myresult = ""; while(<$mystdout>){ $myresult = "$myresult$_"; } return $myresult; } print 'Before: ', Dumper \@plist; foreach ( @plist ) { print Dumper ccmexec_nodie $_; } print 'After: ', Dumper \@plist; #### Before: $VAR1 = [ '/usr/bin/cat /etc/motd' ]; $VAR1 = 'Sun Microsystems Inc. SunOS 5.10 Generic January 2005 '; After: $VAR1 = [ undef ]; #### #!/usr/local/perl510/bin/perl use strict; use warnings; use Data::Dumper; use IPC::Open3; my @plist = ( '/usr/bin/cat /etc/motd' ); sub ccmexec_nodie { my( $command )= @_; my ($mystdin,$mystdout,$mystderr); my $pid = open3($mystdin,$mystdout,$mystderr,$command); my $myresult = ""; while(my $in=<$mystdout>){ $myresult .= $in; } return $myresult; } print 'Before: ', Dumper \@plist; foreach my $cmd ( @plist ) { print Dumper ccmexec_nodie $cmd; } print 'After: ', Dumper \@plist;