title: socket->recv() vs. <>?
body: <p>I'm trying to work through a small Perl learning project that requires reading 4 unsigned integers from a socket.  I couldn't get more than 1 integer read, and after digging around I found a solution. But I NEED to understand what I didn't do right (and have gone through a couple of Perl books, perldocs, etc to no avail.)</p>
  
  <p>Example 1:
  Here's the successful solution code (<a href="http://www.governmentsecurity.org/forum/index.php?showtopic=22538" rel="nofollow">original</a>), assume the socket connect is successful for both below:</p>
  
  <pre><code>{
    local $/ = \16; # make &lt;&gt; read in 16 bytes with one swoop.
    my @integers = unpack "IIII", &lt;$sock&gt;;
    print "numbers: @val\n";
  }
  </code></pre>
  
  <p>Example 2: I tried this below.  If I print the input prior to unpacking, I only get one Integer:</p>
  
  <pre><code>my $input;
  $sock-&gt;recv($input,16,0);
  my @integers = unpack("IIII", $input);
  </code></pre>
  
  <p>Specific questions:</p>
  
  <ol>
  <li>In example 1, what the heck is "$/"? And how does it "change" &lt;>, which I thought read STDIN?</li>
  <li>In example 2, is there some reason why my recv() doesn't take more than one integer off the socket?  My understanding (per perldoc) is that the "SIZE" parameter defaults to "bytes", and integers are 4 bytes?</li>
  </ol>
  
  <p>Any help, pointers, etc. is appreciated.  Btw, the "learning project" is overthewire.org - pretty cool stuff.</p>