V
vedpsingh
I want to print something looking like this(binary value are in another
text file) :
rec_codein0 000000010000000000 0
rec_codein1 111101110000000000 0
.......
......
rec_codein15 111111110000000000 0
---------------------------------------------------------------------
I have written programmentioned below.
Value is being read in $_ but why can't I print in the desirable way
?
Please point out the mistake.
------------------------------------------------
use strict; # important pragma
use warnings; # another important pragma
open (MYFILERead, 'data.txt');
while (<MYFILERead>) {
chomp;
print "$_\n";
}
print "Enter value of instantiations ? "; # print out the question
chomp( my $j = <STDIN> );
for (my $i = 0; $i < $j; $i++) {
my $file = 'copypaste.txt';
open my $MYFILE, '>>', $file or die "Could not open '$file': $!\n";
print MYFILE "
rec_codein$i $_\n ";
}
close (MYFILE);
close (MYFILERead);
----------------------------------------------------------
File "data.txt" contains ------>
111110110000000000
111101110000000000
000000010000000000
000001100000000000
111110000000000000
000000010000000000
000010000000000000
000000100000000000
000000110000000000
111110000000000000
000000110000000000
000000000000000000
000001100000000000
111110100000000000
000000110000000000
111111110000000000
Thanks
text file) :
rec_codein0 000000010000000000 0
rec_codein1 111101110000000000 0
.......
......
rec_codein15 111111110000000000 0
---------------------------------------------------------------------
I have written programmentioned below.
Value is being read in $_ but why can't I print in the desirable way
?
Please point out the mistake.
------------------------------------------------
use strict; # important pragma
use warnings; # another important pragma
open (MYFILERead, 'data.txt');
while (<MYFILERead>) {
chomp;
print "$_\n";
}
print "Enter value of instantiations ? "; # print out the question
chomp( my $j = <STDIN> );
for (my $i = 0; $i < $j; $i++) {
my $file = 'copypaste.txt';
open my $MYFILE, '>>', $file or die "Could not open '$file': $!\n";
print MYFILE "
rec_codein$i $_\n ";
}
close (MYFILE);
close (MYFILERead);
----------------------------------------------------------
File "data.txt" contains ------>
111110110000000000
111101110000000000
000000010000000000
000001100000000000
111110000000000000
000000010000000000
000010000000000000
000000100000000000
000000110000000000
111110000000000000
000000110000000000
000000000000000000
000001100000000000
111110100000000000
000000110000000000
111111110000000000
Thanks