No :-)

This code is fine for what it does:

open # open a file for read or write ( ORDERFILE # onto a FILEHANDLE called ORDERFILE , " > # > means write to the file, create if does not exist # Note all previous content will be deleted # if this file exists >> means append to the end $outfile # full or relative path to file " ) or # if the open works it returns true so we never do the next + bit diehtml() # print an error message

You don't wanna touch anything in the demon code. It was for illustrative purposes and is not relevant to your problem provided you are happy that the code you have worked just replace the lockfile code.

In this code:

$fh = "ORDERFILE"; sysopen($fh, "$outfile", O_CREAT | O_EXCL | O_RDWR, 0600) or diehtml("Can't open order records: $!\n");

You don't need to set $fh to a string. It will just get overwritten in the open. A FILEHANDLE is a type of perl internal object (like a scalar) and the reference to it is held in the $fh var. To illustrate the syntax:

open $fh, ">$file" or die "Can't write $file $!\n"; print $fh "here is some data\n"; close $fh;

Same with sysopen but I can't be bothered to type that much.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Re: Re: Perl script crashing at lockfile ? by tachyon
in thread Perl script crashing at lockfile ? by peterr

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.