Perlwannabe
Technical User
Hello,
I made a simple script that picks up words from a text file A and save them in text file B each time I call the script.
I would that it appends the new array just under the existing one but the first word stands on the side:
Array:
bla
bla
bla
bla
After I add a new array should be:
bla
bla
bla
bla
bla
bla
bla
bla
Instead is:
bla
bla
bla
blabla (the last and the first coincide)
bla
bla
bla
Why this? What can I do?
Here is the very short script (didaptic):
Thanks for a kind help
Sincerely
I made a simple script that picks up words from a text file A and save them in text file B each time I call the script.
I would that it appends the new array just under the existing one but the first word stands on the side:
Array:
bla
bla
bla
bla
After I add a new array should be:
bla
bla
bla
bla
bla
bla
bla
bla
Instead is:
bla
bla
bla
blabla (the last and the first coincide)
bla
bla
bla
Why this? What can I do?
Here is the very short script (didaptic):
Code:
#!perl
# reading data from file A
# open file A to read
open(A,"filea.txt")||die("could not open file!");
# store them in an array
@a=<A>;
# close
close(A);
# writing data on file B
# open file B to write (append)
open(B,">>fileb.txt")||die("could not open file!");
# print data
print A;
# close
close(B);
# open file B to print a check
open(B,"fileb.txt")||die("error");
@b=<B>;
close(B);
# print results as html
print "Content-type: text/html\n\n";
foreach $line(@b)
{
print $line;print"<br>\n";
}
exit;
Thanks for a kind help
Sincerely