When I run your code I get:

"my" variable $FH masks earlier declaration in same scope at C:\Users\ +Peter\Delme~~\PerlScratch\noname1.pl line 36. readline() on unopened filehandle FH at C:\Users\Peter\Delme~~\PerlScr +atch\noname1.pl line 38. <tr> <td>(0)</td> </tr>

which tells you exactly what jethro and d5e5 determined for you. Using strictures is good, but they only work for you if you take notice of the warnings and errors they issue!

A few other tips: avoid needless initialisation. Use sensible and meaningful names. Take advantage of all failure information. Consider:

use strict; use warnings; use Fcntl; use POSIX qw(setsid :errno_h :fcntl_h); File_Data(); sub File_Data { my $path = "fd_search.txt"; my $create = !sysopen(my $inFile, $path, O_RDONLY); my $write; my @data; if (not $create) { @data = <$inFile>; $write = !@data; close $inFile; } if ($write || $create) { if ($create) { sysopen(my $outFile, $path, O_CREAT) or die "Create $path failed: $!"; close $outFile; } sysopen(my $outFile, $path, O_WRONLY) or die "Create $path fai +led: $!"; print $outFile "one two three"; close $outFile; sysopen(my $inFile, $path, O_RDONLY) or die "Reopen $path fail +ed: $!"; @data = <$inFile>; } print "<tr>\n"; print "<td>(0)@data</td>\n"; print "</tr>\n"; }
True laziness is hard work

In reply to Re: Reading file contents by GrandFather
in thread Reading file contents by Dramton

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.