R. Joseph Newton wrote:
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


Yes Joseph,
I would precisely do that if I were getting a filehandle in my actual script. It is much better because I would not always be reading the entire file before making the decision.
But my problem is that the file is actually a sieve data file that the module I use reads the entire file into a string and returns the string
The filehandle DATA I used only for sake of example


Thanks anyway, The best thing about newsgroups is that there are always better ways of doing things, and here you can explore them all

Bye
Ram


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



Reply via email to