Here's a stripped down CGI script I'm working on. It works fine on a BSD box and will be deployed to a Solaris box (running Perl 5.6). Since I've never worked with Solaris, are there things I should be wary of?
#!/usr/bin/perl -wT use CGI qw( :all ); use strict; $|++; print header(), start_html( "Counter Test" ); # *snip* my $datapath = "/home/username/data/project"; # outside httpd directo +ry my $datafile = "$datapath/counter.dat"; # Permissions: 666 my $subID = sprintf( "%06d", getNewCounter( $datafile ) ); # more snipped, including code verification of directory, file, and at +tributes. print "Get Counter Results: $subID", end_html; sub getNewCounter # --------------------------------------------------------------- # Reads and incremements the counter value. # Credit: Implementation based on sample found in the perl CGI # FAQ at www.perl.com. # --------------------------------------------------------------- { my( $countfile ) = @_; open( FILE, "$countfile" ) or die "Cannot open counter for reading +.\n"; flock( FILE, 2 ) or die "Cannot lock counter for reading +.\n"; my( $countval ) = <FILE>; chomp( $countval ); flock( FILE, 8 ) or die "Cannot unlock counter after rea +ding.\n"; close( FILE ) or die "Cannot close counter after read +ing.\n"; open( FILE, ">$countfile" ) or die "Cannot open counter for writing +.\n"; flock( FILE, 2 ) or die "Cannot lock counter for writing +.\n"; print FILE ++$countval; flock( FILE, 8 ) or die "Cannot unlock counter after wri +ting.\n"; close( FILE ) or die "Cannot close counter after writ +ing.\n"; return( $countval ) }

I'm primarily worried about the getNewCounter() subroutine and, as always, any security issues. In case you didn't catch the earlier comments, data/ is outside of httpd/ and cgi-bin/, as outlined in Organization Redux.

Also, any other concerns or suggestions?

--f


In reply to Flock Feedback by footpad

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.