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
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; //
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
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
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
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
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
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,
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 =~ /\(