Dramton has asked for the wisdom of the Perl Monks concerning the following question:
Again, I can write to the file but can't read from it and can't figure out why?use strict 'vars'; use warnings; use Fcntl; use POSIX; use POSIX qw(setsid); use POSIX qw(:errno_h :fcntl_h); File_Data(); sub File_Data { my $path = "fd_search.txt"; my $create = 0; my $write = 0; my @temp = ""; sysopen(my $FH,$path,O_RDONLY) or $create = 1; if (not $create) { @temp = <FH>; if (not @temp) { $write = 1; close($FH); } } if ($write || $create) { if ($create) { sysopen(my $FH,$path,O_CREAT) or die "Could not create $path."; close($FH); } sysopen(my $FH,$path,O_WRONLY) or die "Could not open $path to wri +te to."; print $FH "one two three"; close($FH); sysopen(my $FH,$path,O_RDONLY) or die "Could not open $path the 2n +d time"; @temp = <FH>; } close($FH); my $count = 0; print "<tr>\n"; print "<td>($count)@temp</td>\n"; print "</tr>\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading file contents
by jethro (Monsignor) on Jul 04, 2011 at 16:34 UTC | |
by davido (Cardinal) on Jul 04, 2011 at 16:42 UTC | |
by Dramton (Initiate) on Jul 04, 2011 at 17:53 UTC | |
by d5e5 (Beadle) on Jul 04, 2011 at 20:05 UTC | |
|
Re: Reading file contents
by GrandFather (Saint) on Jul 04, 2011 at 21:04 UTC | |
by Dramton (Initiate) on Jul 05, 2011 at 01:39 UTC | |
by Anonymous Monk on Jul 05, 2011 at 01:49 UTC | |
by Dramton (Initiate) on Jul 05, 2011 at 04:02 UTC | |
by Dramton (Initiate) on Jul 05, 2011 at 02:11 UTC | |
by Anonymous Monk on Jul 05, 2011 at 02:29 UTC | |
|
Re: Reading file contents
by davido (Cardinal) on Jul 04, 2011 at 16:25 UTC | |
by Dramton (Initiate) on Jul 04, 2011 at 17:48 UTC |