Hi,
 
Have a file like:
 
meteor    (L, 4) (G,24)
rocket    (J,19) (D,35)
aulan     (E,28) (E, 2)
aupbx     (B,32) (O,10)
 
And I need to work with the chars between the brackets after I've found the
string on the left e.g. if my $host variable matches rocket then I need to
get J and 19 and D and 35 into an array or their own seperate variables.
 
I have been going around in circles with the regex.  I have tried escaping
the round brackets with \, anchoring the string to the end with \z and a
multitude of other combos of \D \d \w . \s etc.
 
Note that some coordinates have two digits and others single digit with
whitespace before it.
 
#StartCode
use strict;
use warnings;
use diagnostics;
 
my $host = $ARGV[0];
my $dirRoot = "/gjkeenan/G7";
my $fileG7 = "$dirRoot/G7";
my $filePW = "$dirRoot/PW";
 
open(PWFILE, "$filePW")
  || die "Can't open $filePW: $!";
while (<PWFILE>) {
  if (/$host/) {
    my @c = /(\D,\d\d)\s(\D,\d\d)/;
  }
}
close(PWFILE);
...do something with $c[0] $c[1] $c[2] $c[3]...
#EndCode
 
 
Really appreciate some pointers.
Regards, Greg

Reply via email to