Hi all,
I am new to perl and I have written a smal script to grab data from one file, and put them into another file. The problem is new lines, which are printing nice under a linux environment, but it is all messed up if I open it with notepad. I am running Perl 5 under cygwin. Heres the script:
[CODE=perl]
#!/usr/bin/perl
open (READ, "opt.txt") || die "Can't find opt.txt\n";
$x=0;
while ($info = <READ>) {
chomp $info;
@data = split (/\t/, $info);
push @cells, [@data];
$x++;
}
close READ || die "Couldn't close opt.txt";
open (WRITE, ">rel.txt") || die "Can't find rel.txt\n";
$y=0;
print WRITE "#DoNotEditThis Line: UndoCommandFile off_files model_n_m_z endfile=/tmp/6222\n\n";
foreach (@cells){
print WRITE "cr balla=1,blablab la=$cells[$y][0],foobar=$cells[$y][0]_$cells[$y][1]\n";
print WRITE "bleh=10175,foo unbar=$cells[$y][1]\n\n";
$y++;
}
close WRITE || die "Couldn't close rel.txt";
exit (0);
[/CODE]
Now if I cat the output in cygwin, the newlines are working. If I open it with notepad, one new line is working which is after print WRITE "bleh=10175,foo unbar=$cells[$y][1]\n\n"; (please note not both of newlines are working).
Any ideas? I need those in that specific format
I am new to perl and I have written a smal script to grab data from one file, and put them into another file. The problem is new lines, which are printing nice under a linux environment, but it is all messed up if I open it with notepad. I am running Perl 5 under cygwin. Heres the script:
[CODE=perl]
#!/usr/bin/perl
open (READ, "opt.txt") || die "Can't find opt.txt\n";
$x=0;
while ($info = <READ>) {
chomp $info;
@data = split (/\t/, $info);
push @cells, [@data];
$x++;
}
close READ || die "Couldn't close opt.txt";
open (WRITE, ">rel.txt") || die "Can't find rel.txt\n";
$y=0;
print WRITE "#DoNotEditThis Line: UndoCommandFile off_files model_n_m_z endfile=/tmp/6222\n\n";
foreach (@cells){
print WRITE "cr balla=1,blablab la=$cells[$y][0],foobar=$cells[$y][0]_$cells[$y][1]\n";
print WRITE "bleh=10175,foo unbar=$cells[$y][1]\n\n";
$y++;
}
close WRITE || die "Couldn't close rel.txt";
exit (0);
[/CODE]
Now if I cat the output in cygwin, the newlines are working. If I open it with notepad, one new line is working which is after print WRITE "bleh=10175,foo unbar=$cells[$y][1]\n\n"; (please note not both of newlines are working).
Any ideas? I need those in that specific format
Comment