Re: help with pattern matching/parsing

2002-06-06 Thread drieux
On Thursday, June 6, 2002, at 01:56 , lz wrote: > > You were right - I got multiple lines in the file and > I guess while the variable was set when it found the > correct pattern, but was unset after it couldn't find > the pattern. > > Since, I don't need anything after I got my field, I > just u

Re: help with pattern matching/parsing

2002-06-06 Thread John W. Krahn
Lz wrote: > > I do set the line, and thats why I am not sure, why it > doesn't work: > > while ( $line = ) > { > $idNumber = $line =~ /\((ID\d+)\)/; You _need_ the parenthesis around $idNumber for it to work properly. ($idNumber) = $line =~ /\((ID\d+)\)/; > } > > print $idNumber; //

Re: help with pattern matching/parsing

2002-06-06 Thread lz
Hi guys, Thanks a lot! You were right - I got multiple lines in the file and I guess while the variable was set when it found the correct pattern, but was unset after it couldn't find the pattern. Since, I don't need anything after I got my field, I just used 'last' to exit out from the loop an

Re: help with pattern matching/parsing

2002-06-06 Thread David T-G
Leon -- ...and then lz said... % % Hi David, Hello! % % I do set the line, and thats why I am not sure, why it % doesn't work: % % while ( $line = ) % { % $idNumber = $line =~ /\((ID\d+)\)/; % } % % print $idNumber; // empty Very odd indeed. I rewrote my one-liner in your format an

RE: help with pattern matching/parsing

2002-06-06 Thread Mark Anderson
ll be satisfied with. /\/\ark -Original Message- From: lz [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 06, 2002 1:46 PM To: David T-G; perl beginners Cc: lz Subject: Re: help with pattern matching/parsing Hi David, I do set the line, and thats why I am not sure, why it

Re: help with pattern matching/parsing

2002-06-06 Thread lz
Hi David, I do set the line, and thats why I am not sure, why it doesn't work: while ( $line = ) { $idNumber = $line =~ /\((ID\d+)\)/; } print $idNumber; // empty Thanks again! --- David T-G <[EMAIL PROTECTED]> wrote: > Leon -- > > ...and then lz said... > % > ... > % Here is a line fr

Re: help with pattern matching/parsing

2002-06-06 Thread David T-G
Leon -- ...and then lz said... % ... % Here is a line from my file: % Dear Test Test1(ID127158), ... % % I use the following line, when I am reading the file: % ($idNumber) = $line =~ /\((ID\d+)\)/; % % For, some reasons idNumber is still empty Do you actually read the line into $line? M

Re: help with pattern matching/parsing

2002-06-06 Thread lz
Jeff, Here is a line from my file: Dear Test Test1(ID127158), . I use the following line, when I am reading the file: ($idNumber) = $line =~ /\((ID\d+)\)/; For, some reasons idNumber is still empty Thanks again! --- Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote: > On Jun 6,

Re: help with pattern matching/parsing

2002-06-06 Thread Jeff 'japhy' Pinyan
On Jun 6, lz said: >I will have the file that will start with the >following line: > >Dear Name (ID12345) > > > > >Do you know how can I parse the above file, so I can >retrieve the ID12345? Open the file, read the first line, and use the following regex: ($id) = $line =~ /\(