Sorry,it should be:
$_=~/\((\w+)\,\s*(\d+)\)\s+\((\w+)\,\s*(\d+)\)/;

Didn't consider the blank space before.

On Mon, 12 Sep 2005 14:54:56 +0800, "Jeff Pan" <[EMAIL PROTECTED]>
said:
> Is this feasible?
> 
> while(<>)
> {
>     next unless /$host/;
>     $_=~/\((\w+)\,(\d+)\)\s+\((\w+)\,(\d+)\)/;
>     my @array=("$1","$2","$3","$4");
> }
> 
> 
> 
> On Mon, 12 Sep 2005 16:14:14 +1000, "Keenan, Greg John (Greg)** CTR **"
> <[EMAIL PROTECTED]> said:
> > 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
> -- 
>   Jeff Pan
>   [EMAIL PROTECTED]
> 
> -- 
> http://www.fastmail.fm - Or how I learned to stop worrying and
>                           love email again
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 
-- 
  Jeff Pan
  [EMAIL PROTECTED]

-- 
http://www.fastmail.fm - The way an email service should be


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to