Ramprasad wrote:

> hello all,
>
> I have a file read into a single string, and I want to write a regex
> that will tell me wether the file contains any non hashed line
>

> __DATA__
> ## FORWARD
> ## FORWARD
> ## VACATION
> ## VACATION
> __END__
>
> But my regex fails in case of any blank lines or lines containing all
> white space
>
> Can anyone help me out
>
> Thanks
> Ram

Hi Ram,

I noticed that you posted again to say that you got this working, but I think there is 
still a conceptual issue here.  Look at your data.  It is organized as a collection of 
discrete lines.  The natural process for reading files is also a collection of lines.  
Thereofre when you slurp the file:
local($/)=undef;
$str=<DATA>;
You throw away the very organization pattern you need for your program logic, and then 
must recover it in a much more obscure manner.  I would recommend instead that you 
retain that information by using an array of lines:
my @strings = <DATA>;
or simply reading the lines and printing the:
"Data has lines that are not comments" message whe you first find a line that fails:

$testLine =~ /^\s*\#/;

Joseph


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

Reply via email to