in reply to storing result in variable

Try using backticks which enable you to execute a command and capture the output (STDOUT by default). e.g.
my $output = `ping $host`;

This is the simplest option and is probably OK for a command such as ping which will only take a short amount of time to run.