Beau..I guess , the evaluation of the expression  is not going to be true if no 
"Date:" is found. Since map returns a list consisting of the results of each 
successive evaluation of the expression..., the map will  return undef. 

Although, here..I think using grep would be a better idea!! 

-----Original Message-----
From: Eric Beaudoin [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 05, 2002 4:29 PM
To: Shishir K. Singh
Cc: Ankit Gupta; [EMAIL PROTECTED]
Subject: RE: Help in Regular expression with array


At 16:12 2002.06.05, Shishir K. Singh wrote:
>open (FILE , "<$ARGV[0]");
>print "ok" if  ( map { /Date:/ } (<FILE>) );
>close FILE;

map return an array with the result of the express apply to each line. Even if none of 
the lines in <FILE> contain Date:, you will have an array with one ""  value for each 
line. This is a non empty array i.e. it has multiple lines and when evaluate in a 
scalar context (with the if() ), it would always be true unless there are no lines in 
<FILE>.

I think you want grep there as in

print "ok" if (grep /Date:/ ,(<FILE>));

or 

print "ok" if (map { /Date:/ ? $_ : () } , (<FILE>));

I may be wrong though.

Best


----------------------------------------------------------
Éric Beaudoin               <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to