title: perl: reverse values in a column
body: <p>I have a tab-seperated table (table1) with 4 columns, looking like this</p>
  
  <pre><code>A       +       1      1
  A       +       2      2
  A       +       3      3
  B       -       2      4
  B       -       3      5
  B       -       4      6
  B       -       5      7
  C       +       1      8
  C       +       2      9
  C       +       3      10
  D       -       1      11
  D       -       2      12
  D       -       3      13
  </code></pre>
  
  <p>The letters in col1 define groups. Now, if there is a "+" in col2, I just want to keep the line as it is. If there i a "-" in col2, I want to reverse the values in col3, for all lines belonging to the group defined by col1. For this example the output should look like this</p>
  
  <pre><code>A       +       1       1
  A       +       2       2
  A       +       3       3
  B       -       5       4
  B       -       4       5
  B       -       3       6
  B       -       2       7
  C       +       1       8
  C       +       2       9
  C       +       3       10
  D       -       3       11
  D       -       2       12
  D       -       1       13
  </code></pre>
  
  <p>So for group A, everything stays the same. But for group B the original values in col3 are: 2, 3, 4, 5. They should become 5, 4, 3, 2. The rest of the columns stays the same.</p>
  
  <p>How should I work this out in Perl?</p>