When debugging it is often useful to have a way to output data in a human readable format.
use Data::Dumper; print Dumper($foo);
In var_export(), the 2nd argument sets whether to return the result instead of printing it
print var_export($foo, true);
You can also trigger a notice, so it'll show up in your logging, instead of on the generated page (NB: trigger_error() truncates the message to 1024 bytes if it's larger than that):
trigger_error(var_export($foo, true), E_USER_NOTICE);