Hi, Keenan, Greg John (Greg)** CTR ** <[EMAIL PROTECTED]> asked:
> 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. > #StartCode > use strict; > use warnings; > # use diagnostics; # I don't think you really need this ;-) > > my $host = $ARGV[0]; Alternatively: my $host = shift; > my $dirRoot = "/gjkeenan/G7"; > my $fileG7 = "$dirRoot/G7"; > my $filePW = "$dirRoot/PW"; > > open(PWFILE, "$filePW") > || die "Can't open $filePW: $!"; > while (<PWFILE>) { if( my(@c) = ( m/^$host \((\S+),\s*(\d+)\)\s+\((\S+),\s*(\d+)\)/ ) ){ # do something with $c[0] $c[1] $c[2] $c[3] } > } The Regex is OTTOH, but it should get you started. HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>