title: How to extract ip addresses and port numbers using Perl and compare it
body: <p>I have a file containing a port numbers and ip addresses in a string. I have to extract the ip addresses, calculate the port number according to the formula and compare it to the port number in the file and print the ones that dont match. If the ip address is W.X.Y.Z the formula for port number is 50000+200(Y)+Z.
  The text file is of the following format. </p>
  
  <p>exchangeA_5=53413 ;239.189.17.13 7990</p>
  
  <p>exchangeA_6=53415 ;239.189.17.15 7990</p>
  
  <p>exchangeA_e=53470 ;239.189.27.70 7990</p>
  
  <p>exchangeA_5=53468 ;239.189.27.68 7990</p>
  
  <p>What is the best way to do it?</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  
  open(my $fh, '&lt;', 'fileC')
  or die("Can't open fileC: $!\n");
  
  while (&lt;$fh&gt;) {
      chomp;
      my ($key, $val) = split /=/;
      #print "$key\n";
      #print "$val\n";
  
      my ($port, $ip) = split /[;]/, $val;
      print "$port\n";
      print "$ip\n";
  
  }
  </code></pre>