Your question raises plenty of problems.
What exactly do you want to do? As the previous answers showed if you want to write to a file, then later on to read from it, you just need to close it in between. If you want to keep it open here is how you can do it:
#!/bin/perl -w use strict; open( NOTES, "+<note.txt") # +< allows you to do read/writ +e updates on the file or die "cannot open note.txt: $!"; print NOTES "stuff\n"; # print stuff in your file my $pos= tell NOTES; # mark the position before the +write you are interested in print NOTES "test\n"; # write your data (it should en +d up with \n if you want # <NOTES> to pick it up properl +y later) # when you are ready to read it seek NOTES, $pos, 0; # reset filehandle to the right + position my $fromfile=<NOTES>; # read chomp $fromfile; # rememebr that \n? You might w +ant to remove it now if ($fromfile eq "test") {print "Yes, this works"}
Now why would you want to do this over storing the data in an array or something similar, which would be way faster than playing with files? I have no idea (size of the data you actually write?)
In reply to Re: File Access
by mirod
in thread File Access
by dmckee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |