"\nthis is my message\n\n" #### #!/usr/bin/perl -w use strict; ## declare a pid for forking my $pid; ## loop through devices for my $node(@devices) { ## if child process exists, move to next device if ($pid = fork) { next; ## begin actions within the child process } elsif(defined($pid)) { ## print a message &log_action($node); ## explicit exit for child process exit; } else { die "Cant fork for some reason! : $!\n"; ## endif } ## end of for loop } sub log_action { my $i = shift; print "\nThis message if for node $i.\n\n"; }