title: Is there a way to force void context in Perl?
body: <p>I'm wondering this only out of geek curiosity on the way Perl works and how far you can go with things like this.</p>
  
  <p>There are some functions that are written to act differently on each one of the three contexts.</p>
  
  <p>With the following code as a very simple example:</p>
  
  <pre class="lang-perl prettyprint-override"><code>use 5.012;
  
  say context();
  say scalar context();
  
  sub context {
      if (wantarray) {
          return 'list';
      } elsif (defined wantarray) {
          return 'scalar';
      } else {
          return 'void'; # Destined to be discarded
      }
  }
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>list
  scalar
  </code></pre>
  
  <p>Can you think of a way to provoke a third <code>say</code> that outputs <code>void</code> after <code>context()</code> is called?</p>
  
  <p>I understand this is quite a contradiction, as void context would probably mean you are not really returning/assigning anything. But as I understand from what I've read on the way Perl works, it's not about nothing being returned, but the return value being discarded after being executed in void context.</p>
  
  <p>So, I'm wondering: Is there a way to <strong>force</strong> void context in the same way you can force list or scalar context, when you happen to actually be on list or scalar context at the moment of the call to a function?</p>