title: print out email on terminal using data::dumper
body: <p>I am not understanding how to use Data::Dumper even after reading the Perl doc and looking at other scripts in git. I see lots of examples online dealing with hashes, but I didn't think that quite fit with what I need to do.</p>
  
  <p>I am creating a script to send emails to managers or teams regarding terminated employees. I was told to add <code>print Dumper $email</code> to my code so that when --dry_run option is used, we could see on the terminal a printout of what the email would look like. --dry_run would also ensure that the email isn't actually sent. When I run <code>perl &lt;script&gt; --dry_run</code>, nothing happens. Maybe I need to do something along the lines of <code>$d = Data::Dumper-&gt;new(</code>?</p>
  
  <p>Here is a snippet of my code:</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  use NIE::Email;
  use Data::Dumper;
  use List::Util qw(any);
  use Getopt::Long;
  Getopt::Long::Configure qw(gnu_getopt);
  my ($qa, $verbose, $dry_run, $help, $dbh);
  
  GetOptions(
      'qa' =&gt; \$qa,
      'verbose|v' =&gt; \$verbose,
      'dry_run' =&gt; \$dry_run,
      'help|h' =&gt; \$help
  );
  
  #Generate email here
  sub mail_func {
      print "Prepare email\n" if $verbose;
      my $n = shift;    #user
      my $i = shift;    #ips
      my $t = shift;    #testnets
      my $m = shift;    #managers (multiple if owner is undef)
      my @to_list;      # send to field
      foreach my $value (values %{$t}) {
          if ($value ne 'lab@abc.com') {    #don't send this email to lab@
              if (any { $value eq $_ } @to_list) { #check not already listed
                  next;
              }
              else { push(@to_list, $value); }
          }
      }
      foreach my $key (keys %{$m}) {
          if ($key ne 'def') {
              if (any { $key eq $_ } @to_list) {
                  next;
              }
              else { push(@to_list, $key . '@abc.com'); }
          }
      }
      my @body;
      while (my ($key, $value) = each %{$i}) {
          my $b = "IP " . $key . " : Testnet " . $value . "\n";
          push(@body, $b);
      }
      my $sub1 = "Ownership needed!";
      my $sub2 = "Ownership needed script special case";
      my $email;
  
      #Email testnet group (if not lab) as well as manager of term employee
      if (@to_list) {
          $email = NIE::Email-&gt;new(
              From       =&gt; 'do-not-reply@abc.com',
              To         =&gt; join(',', @to_list),
              'Reply-to' =&gt; 'def@abc.com',
              Subject    =&gt; $sub1,
              );
          $email-&gt;data(
              "Good Day, \n\n The below machines need claimed as their previous"
                . " owner, $n, is showing up as no longer with the company. \n"
                . "Please visit website to change"
                . " ownership of these machhines. \n\n"
                . "@body \n\n"
                . "If you have already requested an ownership change for these"
                . " machines, please disregard this message."
                . "\n\n Thank you \n -Lab team \n\n"
                . "This script is under active development and could contain"
                . " bugs, so please speak up if you have doubts or something "
                . "looks strange."
                . "\n Script name: lab_ownership_needed_email");
          if ($dry_run) {print Dumper($email);}
          else {$email-&gt;send();}
      }
  </code></pre>
  
  <p>Any help in understanding how to use this for my purpose would be greatly appreciated. Thank you.</p>