...pointed it to a file called /tmp/xxx with a few lines in it and nothing happens! I tried to echo some additional lines to the file they're not reported either.

For the first part to work, you'd have to specify the tail option, e.g. tail => 10, to read/print out the last 10 lines of the file upon starting the script.

The latter part should've worked, though (if you append to the file while the test script is running — which I suppose you did).   As I can't replicate the problem here, I can only suggest you try strace/truss/tusc to check what's going on (or isn't) underneath.

For comparison, on my (Linux) system, I repeatedly (once a second) get the following block

$ strace ./944682.pl ... nanosleep({1, 0}, {1, 0}) = 0 nanosleep({0, 0}, NULL) = 0 lseek(3, 0, SEEK_END) = 32 open("/tmp/xxx", O_RDONLY) = 4 ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff3d7d2c00) = -1 ENOTTY (I +nappropriate ioctl for device) lseek(4, 0, SEEK_CUR) = 0 fstat(4, {st_mode=S_IFREG|0644, st_size=32, ...}) = 0 fcntl(4, F_SETFD, FD_CLOEXEC) = 0 fstat(4, {st_mode=S_IFREG|0644, st_size=32, ...}) = 0 close(4) = 0 lseek(3, 0, SEEK_END) = 32 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 ...

when there's no new lines in /tmp/xxx.  And an additional block

... lseek(3, 72, SEEK_SET) = 72 read(3, "foo\n", 4) = 4 lseek(3, 0, SEEK_CUR) = 76 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 nanosleep({1, 0}, {1, 0}) = 0 nanosleep({0, 0}, NULL) = 0 write(1, "foo\n", 4foo ) = 4 ...

when a new line has been appended to the file.

BTW, the "Inappropriate ioctl for device" error is meaningless, i.e. to be expected, here.  This is also what you see in $!, when you check that variable even though the actual system/library call in question hasn't failed.  (In other words, you should only interpret that variable, if Perl actually did indicate a failure.)


In reply to Re: I can't get the sample code for File::Tail to read my file by Eliya
in thread I can't get the sample code for File::Tail to read my file by markseger

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.