Donald Beck wrote:
> I am running Perl on Windows XP Pro. I am new to
> Perl.
>
> I am trying to write a script that will take a text
> file with multiple rows and a reoccurring character
> that I want replaced, then the output written to
> another text file.
>
> Here is what I have come up with (actually I got it
> out of a book):
>
> #!C:\perl\bin\perl
>
> open(TXT, "<sample.txt");
> @text = <TXT>;
> close(TXT);
>
> print "Content-type:text/html\n\n <html>";
> print "Text file contents:<br/>";
> foreach $line(@text)
> {
> print "$line <br/>";
> }
> print "</html>";
>
> This opens the file and displays it. I do not know
> where in this syntax I place s/,/|/ to replace the ,'s
> with |'s. I am using the html tags to display the
> output to a browser window, to make sure the output is
> what I want. I need it to write the output to a text
> file instead.
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
open TXT, 'sample.txt' or die "Error opening sample: $! ($^E)";
my @text = <TXT>;
close TXT;
print <<EOD;
Content-type: text/html
<HTML>
<BODY>
Text file contents:
<PRE>
EOD
foreach (@text) {
# s/,/|/g; # if you want to do a replace - do it here
print $_;
}
print <<EOD;
</PRE>
</BODY>
</HTML>
EOD
__END__
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs