in reply to Re: reading text from afile
in thread reading text from afile

thanks zaxo , i agree with you that i overdid somethings. your code seems to work much better for me . i have another query though . this code that i am posting now is taken from a site for stripping HTML . It does the same thing that my other code was doing , generated empty txt files and gives me "Use of uninitialised variable " error for $plain_text. can any body tell me why??
#!c:/perl/perl.exe use strict; use warnings; use CGI ':standard'; use HTML::Parser; my $plain_text ; my $p = HTML::Parser->new(text_h => [\&text_rtn, 'text']); my $path = "c:/perl/htmlfiles"; opendir(LOCAT, $path) or die "Couldn't open folder, $!\n"; my @folder = grep !/^\.\.?$/, readdir(LOCAT); closedir (LOCAT); # Do a loop for each file in the folder. This gets the filename also. foreach my $file (@folder) { my $full_path = $path.$file; print "Reading '$full_path'\n"; $p->parse_file($full_path); $full_path =~ s/html/txt/gi; $full_path =~ s/htm/txt/gi; print "Writing '$full_path'\n"; open(WRITE,">$full_path") or die("Cannot create file!"); print WRITE $plain_text; close(WRITE); } sub text_rtn { foreach (@_) { $plain_text .= "$_\n"; } }