From: <pushkar.n...@gmail.com>
Hi, I have a line read in perl from a file that itself is a source
code for languages like c/sv etc. The variable containing this line
contains special characters like %d. When i print this line to another
file, the %d is evaluated and a 0 is getting printed. How do i
overcome this and tell perl to strictly not interpolate/evaluate any
contents of this variable and simply print it as is !
~Pushkar
open RFH "< File1.txt";
Better use:
open(my $rfh, "<", "file1.txt") or die "Can't read file1.txt - $!";
open WFH "> File2.txt";
Better use:
open(my $wfh, ">", "file2.txt") or die "Can't write to file2.txt - $!";
while ($line = <RFH>)
Better use:
while (my $line = <$rfh>) {
chop($line);
You might want to use:
chomp $line;
printf WFH "$line\n";
You might want to use:
print $wfh "$line\n";
Octavian
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/