[10358] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3951 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 12 08:07:34 1998

Date: Mon, 12 Oct 98 05:00:37 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 12 Oct 1998     Volume: 8 Number: 3951

Today's topics:
    Re: .htaccess Problem (brian d foy)
    Re: .htaccess Problem (Mark-Jason Dominus)
    Re: .htaccess Problem <rra@stanford.edu>
    Re: Any possible way to do graphics in perl?? <postmaster@localhost.net>
    Re: anyone got a rtf->html converter in perl? <jerryp.usenet@connected.demon.co.uk>
    Re: Are there any "perl.newbie" group or forum? <ckc@dmi.dk>
    Re: bug in this subroutine (David A. Black)
    Re: Can I FORMAT variables to be a specific length? <r.r@att.net>
        Character to hex conversion <david@david-bradshaw.com>
        Help: problem with creating ODBC System DSN <rlao@alumni.stanford.org>
        How to do a nslookup ! <ammann@ip-plus.net>
        How to embed a per module in perl 4 Windows <ammann@ip-plus.net>
        How to embed a per module in perl 4 Windows <ammann@ip-plus.net>
        How to embed a per module in perl 4 Windows <ammann@ip-plus.net>
        London.pm - Changed URL dave@mag-sol.com
    Re: Looking for a shopping cart <jimbo@soundimages.co.uk>
    Re: need help writing to a text file (Tad McClellan)
    Re: Need IP Address Sort Subroutine <erhmiru@erh.ericsson.se>
        Perlscript 3.16 and strict MafCassandra@my-dejanews.com
    Re: printing reserved characters from Perl script to we <garethr@cre.canon.co.uk>
        Problem with off the shelf script (Jacob Jay - Enigma)
        Re:Square Root In PERL <diego@valleyservices.com>
    Re: Square Root In PERL (brian d foy)
    Re: use autouse problem in perl 5.004 (Brendan O'Dea)
        Win32::NetAdmin usage problem gya@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 12 Oct 1998 02:57:44 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: .htaccess Problem
Message-Id: <comdog-ya02408000R1210980257440001@news.panix.com>
Keywords: from just another new york perl hacker

In article <362195C2.AC46EC2F@mkt2mkt.com>, madame philosophe <mp@mkt2mkt.com> posted:

>> um, file locking is good.  how about solving that mis-design first?
>
>I'm assuming that Brian means that aside from flocking, that generating a temp file doesn't sound very
>swift to me.

temp files are a lot of work since you have to clean up after them
even if your program exits pre-maturely.

>Is this true?

>Also what are the diffs (in security and in programming know how)
>between a cgi type login and a server login using htaccess?

see Nick Kew's excellent tutorial, "Login On the Web" referenced in
the CGI Meta FAQ.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


------------------------------

Date: 12 Oct 1998 03:21:00 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: .htaccess Problem
Message-Id: <6vsaks$b6i$1@monet.op.net>
Keywords: <font face="Helvetica">Brian D. Foy</font>

In article <comdog-ya02408000R1210980257440001@news.panix.com>,
brian d foy <comdog@computerdog.com> wrote:
>In article <362195C2.AC46EC2F@mkt2mkt.com>, madame philosophe <mp@mkt2mkt.com> posted:
>
>>> um, file locking is good.  how about solving that mis-design first?
>>
>>I'm assuming that Brian means that aside from flocking, that generating a temp file doesn't sound very
>>swift to me.
>
>temp files are a lot of work since you have to clean up after them
>even if your program exits pre-maturely.

I had imagined that the original poster was going to write a new,
complete password file into a temporary file, and then use `rename' to
atomically replace the password file with the new version.  That is a
reasonable way to try to solve the problem.

Of course, some sort of file locking is necessary here.
Opening the temporary file with O_CREAT|O_EXCL is appropriate.



------------------------------

Date: 12 Oct 1998 00:28:33 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: .htaccess Problem
Message-Id: <ylyaqmck7y.fsf@windlord.stanford.edu>

brian d foy <comdog@computerdog.com> writes:

> temp files are a lot of work since you have to clean up after them even
> if your program exits pre-maturely.

Not if you delete them right after you create them.  Of course, that
doesn't work if you're going to later be renaming them, only if you just
need temporary data storage for stuff you don't want to spool in memory.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


------------------------------

Date: 12 Oct 1998 11:31:45 +0400
From: Sergei S. Laskavy <postmaster@localhost.net>
Subject: Re: Any possible way to do graphics in perl??
Message-Id: <nqww66xmla.fsf@Peru.Gambit.Msk.SU>

"Robin Bank" <rbank@csf.edu> writes:

> E-mail me your responses!

	Perl/Tk

-- 
FreeBSD Project: http://FreeBSD.org/docproj/    Vim: http://www.vim.org/
$_='$6C86:P$^P|2D<2GJPl=2D<2GJp82>3:E^>D<^DFn';tr#P-~\x20-O#\x20-~#;print


------------------------------

Date: Sun, 11 Oct 1998 19:33:33 +0100
From: Jerry Pank <jerryp.usenet@connected.demon.co.uk>
Subject: Re: anyone got a rtf->html converter in perl?
Message-Id: <lJfSWDA9nPI2Ew0T@connected.demon.co.uk>

In <comp.lang.perl.misc> 
Avshi Avital <avitala@macs.biu.ac.il>, writes:
>
>Chris Denman wrote in message <361cc9cb.0@norbert.cerbernet.co.uk>...
>>anyone got a rtf->html converter in perl?
>>
>>If not I'll code one myselft (not looking forward to it, really!)
>
>
>if working in win95, you could load the doc in Word - which will cvrt to
>.doc.
>and then save as html
        s/html/disgusting bloatware/;

-- Jerry Pank                    mailto:jerryp.usenet@netconnected.com

Although the Perl Slogan is There's More Than One Way to Do It, I hesitate
to make 10 ways to do something.  :-)
-- Larry Wall in <9695@jpl-devvax.JPL.NASA.GOV>


------------------------------

Date: Mon, 12 Oct 1998 09:45:29 +0100
From: Casper Kvan Clausen <ckc@dmi.dk>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <Pine.GSO.3.92.981012094034.12706C-100000@edb>

On Fri, 9 Oct 1998, madame philosophe wrote:

[">>" is me, and ">>>" is madame]

> > May I ask what's wrong with the current FAQ? Also, what kind of book is it
> > you feel is missing?
>
> One that doesn't assume you are an idiot, or a dummy, and one that doesn's assume
> you have a degree in computer progamming and can program in C, C++, etc. etc.
> Somewhere in the middle.

A Perl book for non-programmers, which takes its audience seriously.

This would seem to fit the Llama book. [Disclaimer: I did not learn Perl
via the Llama book, so this is based on hearsay].

> Sorry don't know what you mean.  Are you saying that I posted that?

No. I thought you were referring to someone else's posting, and were
saying that one should let FAQs be FAQs in general. Since that was exactly
what had been done with the shuffle-posting, I was somewhat surprised.

Now on to more interesting things, since this discussion seems to be done.

Kvan, glad it is.

-------Casper Kvan Clausen------ | 'Screw you guys, I'm going home!
----------<ckc@dmi.dk>---------- |  Talking poo is where I draw the
           Lokal  544            |  line!'
I do not speak for DMI, just me. |        - Eric Cartman.



------------------------------

Date: Sat, 10 Oct 1998 06:20:34 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: bug in this subroutine
Message-Id: <6vncdi$9ge$1@earth.superlink.net>

zobsky@my-dejanews.com writes:

>Can anyone help me debug this tiny piece of code,please????

Perl can.  Run the code (with the -w switch, of course).

>Also, could someone show me how to impliment case structure in perl, i'm
>guessing it
>might be a more robust solution, but my text makes no mention of case
>structures.

This is a FAQ - a _V_FAQ.  (By the way, is that "text" as in "textbook"
as in college as in homework?)


David Black
dblack@saturn.superlink.net


------------------------------

Date: 12 Oct 1998 10:32:23 GMT
From: "Rathnakar Yelandur" <r.r@att.net>
Subject: Re: Can I FORMAT variables to be a specific length?
Message-Id: <6vslrn$rps@bgtnsc02.worldnet.att.net>

Bart Lateur wrote in message <362323d7.1705311@news.ping.be>...
>Guy Doucet wrote:
>
>>I am receiving data from users. I need to format that data to a certain
>>length. Is there a quick function.
>
>Try
>
> $_ = pack("A40", $_);
>
>to get a 40 characters result.
>
> Bart.
-----------------
Here is a Solution which works for most data type
and very well know to all C users....

my $string='STRING_VAR';
my $num  = 12345;

my $FormattedRec = sprintf ("STR=%-20s | NUM=%10d |\n", $string, $num);
-------------
Rath





------------------------------

Date: Mon, 12 Oct 1998 12:15:31 +0100
From: David Bradshaw <david@david-bradshaw.com>
Subject: Character to hex conversion
Message-Id: <3621E4D2.DCA808EE@david-bradshaw.com>

Hi There,
Can someone please inform me of how i can convert a Character ie "a"
within a string ie "Today" to give it its hexadecimal character code.

Thanks in advance.

David@David-Bradshaw.com



------------------------------

Date: Sun, 11 Oct 1998 23:07:41 -0700
From: Ralph Lao <rlao@alumni.stanford.org>
Subject: Help: problem with creating ODBC System DSN
Message-Id: <36219CAC.F39DF3F8@alumni.stanford.org>

Hi,

I have a need to create an ODBC System DSN using Perl.  I am using Perl
5.003 Build 316 and ODBC.pll dated (2/8/98 and size 177,215 bytes).  The
ODBC document of this version has three new options with ConfigDSN() and
they are for adding, modifying, and removing System DSN.  However, when
I tried them, they always fail.  If I change the options to the old ones
for User DSN's, then they always succeed.  Can anyone help me out?  Do I
need a different version of ODBC.pll?

Please email me because I don't have a regular access to the newsgroup.

Thanks

Ralph Lao
rlao@vantive.com





------------------------------

Date: Mon, 12 Oct 1998 13:53:25 +0200
From: Patrick <ammann@ip-plus.net>
Subject: How to do a nslookup !
Message-Id: <3621EDB4.F402620E@ip-plus.net>

Hi,

I have the following problem. I want to make a nslookup to check if
there is an entry for some ip adresses. I already searched for some
scripts but i haven't found one.
I also downloaded a DNS Resolver but i wan't able to do a lookup.

Couls someone help me ?

As example: I want to look if there is a DNS Entry for 164.128.151.130





------------------------------

Date: Mon, 12 Oct 1998 12:01:00 +0200
From: Patrick <ammann@ip-plus.net>
Subject: How to embed a per module in perl 4 Windows
Message-Id: <3621D35C.C2F8F568@ip-plus.net>

Hi,

I'm just very new in using Perl Scripts. I'm using Win98 and Perl
5.00502. I want to write a script witch collects all the IP Adresses
from a file  and then log in to a router and then check if the
Interfaces of all routers are entered in the DNS. Thats the reason why I
downloaded this packet.
Now my Problem is, that i'm not sure if i did everything witch will be
necessary. I startet teh makefile.pl. Then i copied the Directory DNS
into C:\Perl\5.00502\lib\Net\.. When I run one of the Examples it always
tells me that the query timed out.
I also saw, that, if I would use UNic, that i need some commands linke
make, make test and make install. How can I do them on my Windows PC ?
I hope that you will help me !

ammann@ip-plus.net



------------------------------

Date: Mon, 12 Oct 1998 12:01:59 +0200
From: Patrick <ammann@ip-plus.net>
Subject: How to embed a per module in perl 4 Windows
Message-Id: <3621D397.60C58968@ip-plus.net>

Hi,

I'm just very new in using Perl Scripts. I'm using Win98 and Perl
5.00502. I want to write a script witch collects all the IP Adresses
from a file  and then log in to a router and then check if the
Interfaces of all routers are entered in the DNS. Thats the reason why I
downloaded this packet (Net::DNS - Perl DNS Resolver Module -
http://www.fuhr.net/~mfuhr/perldns/).
Now my Problem is, that i'm not sure if i did everything witch will be
necessary. I startet teh makefile.pl. Then i copied the Directory DNS
into C:\Perl\5.00502\lib\Net\.. When I run one of the Examples it always
tells me that the query timed out.
I also saw, that, if I would use UNic, that i need some commands linke
make, make test and make install. How can I do them on my Windows PC ?
I hope that you will help me !

ammann@ip-plus.net



------------------------------

Date: Mon, 12 Oct 1998 12:03:13 +0200
From: Patrick <ammann@ip-plus.net>
Subject: How to embed a per module in perl 4 Windows
Message-Id: <3621D3E1.3057F7AF@ip-plus.net>

Hi,

I'm just very new in using Perl Scripts. I'm using Win98 and Perl
5.00502. I want to write a script witch collects all the IP Adresses
from a file  and then log in to a router and then check if the
Interfaces of all routers are entered in the DNS. Thats the reason why I
downloaded this packet (Net::DNS - Perl DNS Resolver Module -
http://www.fuhr.net/~mfuhr/perldns/).
Now my Problem is, that i'm not sure if i did everything witch will be
necessary. I startet teh makefile.pl. Then i copied the Directory DNS
into C:\Perl\5.00502\lib\Net\.. When I run one of the Examples it always
tells me that the query timed out.
I also saw, that, if I would use Unix, that i need some commands linke
make, make test and make install. How can I do them on my Windows PC ?
I hope that you will help me !

ammann@ip-plus.net



------------------------------

Date: Mon, 12 Oct 1998 09:46:09 GMT
From: dave@mag-sol.com
Subject: London.pm - Changed URL
Message-Id: <6vsj51$j81$1@nnrp1.dejanews.com>

Please note that the URL for the London.pm web site has changed. If you link
to our page, please update your links accordingly.

New URL: <http://london.pm.org>

Thanks to pm.org and all concerned for making this new URL possible.

Dave...

--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: 12 Oct 1998 09:28:58 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Looking for a shopping cart
Message-Id: <u4starxo5.fsf@jimbosntserver.soundimages.co.uk>

Have you checked your local supermarket. Chances are you will find
quite a few shopping carts.
-- 
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.


------------------------------

Date: Sun, 11 Oct 1998 23:42:53 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: need help writing to a text file
Message-Id: <dc1sv6.sd1.ln@flash.net>

Mike Barg (mbarg@mail.usyd.edu.au) wrote:


: What I want to do, however, is to read, say, the first 3 lines of a file,
: replace line 3, and leave the rest of the file untouched.


Perl FAQ, part 5:

   "How do I change one line in a file/
    delete a line in a file/
    insert a line in the middle of a file/
    append to the beginning of a file?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 12 Oct 1998 13:40:31 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: williams@clark.net
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <laogrinh3k.fsf@erh.ericsson.se>

Good work Joe.

"Joe Williams" <williams@clark.net> writes:
> The info below in a partial summary of the ways suggested to sort an IP
> number. It may be useful to some one new to the problem.
[...]
> # This one takes an approach that I don't understand. It uses a subroutine

Which part do you not understand?

> # to convert the IP address to 199 77 210 67 (using the split function)
> # which is assigned to an anonymous array used as the argument to the pack
> # function. Pack's "C4" takes the anonymous four element string and using
> # the template "C4", converts each number (the 4) to an unsigned binary
> # character (the C) and packs the four numbers into a "binary structure"
> # (the exact form of which is what I don't understand). This binary

This binary structure is a simple string. If you run this code:

perl -e 'print pack("C4",48,49,50,51),"\n"'

it will print a string "0123". The "C4" means, take 4 arguments and treat
ASCII char code. One can rewrite this pack as follow:

sub my_c_pack{
   my $tmp = "";
   foreach(@_){
      $tmp .= chr($_);
   }
   $tmp;
}

but it will, of course, be less efficient.

[...]
> # Still another approach uses the inet_aton function which is part of the
> standard
> # distribution libary. However, when I tried it, the function logs into the
> # network, probably because it can take "somehost.net" as well as the IP
> address,
> # and it is looking for a DNS. So, that approach doesn't work too well for
> my

Well, this function should not log on the network when not needed. I've
noticed this behaviour with old version of ActiveState perl (build 310 
I belive). However, with the latest version a problem is gone. Maybe
you have the same problem?

Regards,

Michal


------------------------------

Date: Mon, 12 Oct 1998 10:56:30 GMT
From: MafCassandra@my-dejanews.com
Subject: Perlscript 3.16 and strict
Message-Id: <6vsn8u$o67$1@nnrp1.dejanews.com>

We have a long (9 month) running IIS system with PerlScript as the main
scripting language. Generally speaking things have been fine.

Last week I downloaded 3.16 to our development machine, and apart from the
usual amount of tweaking have discovered a slightly odd problem (one that
isn't covered on Active State known issues page:
http://www.activestate.com/ActivePerl/knownissues)

We make a fair amount of use of session variables, and in scripts that have a
'use strict;' line it has previously been necessary to access Session
variables via $main::Session rather than via $Session (to prevent strict
complaining that '$Session requires explicit package name'). This has worked
fine for several months.

However, after upgrading to 3.16 I find it impossible to use strict anymore.
strict still complains about $Session being used directly
strict gives no errors or warnings about $main::Session
but code with use strict fails to access data from $main::Session.

If I comment out 'use strict' then both $main::Session and Session can be
used with impunity.

Removing use strict from all scripts seems to be asking for trouble
down-the-line, so I'd appreciate any alternatives.
Has anybody else had similar upgrade problems?

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Mon, 12 Oct 1998 07:48:42 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: printing reserved characters from Perl script to web page.
Message-Id: <sihfxajk4l.fsf@cre.canon.co.uk>

steve.cooke@wmc.com.au wrote:
> [...] but only part of each returned row gets printed to the web page.
> An example of the data that is being returned by the database is: 'Me
> <i.am@work>' (i.e. an email address, enclosed in '<' and '>', preceded
> by a name).

The three characters '&', '<', and '>' are special in HTML.  You need to
convert them to the entity references '&amp;', '&lt;' and '&gt;'
respectively.

Use the function 'encode_entities' from the CPAN module HTML::Entities
to encode your data before printing it to the web page.

-- 
Gareth Rees


------------------------------

Date: Mon, 12 Oct 1998 11:43:01 +0100
From: netmaster@the-enigma.co.uk (Jacob Jay - Enigma)
Subject: Problem with off the shelf script
Message-Id: <netmaster-1210981143020001@th-pm01-28.ndirect.co.uk>

I'm currently testing a program to produce surveys on the web [PowerTab
from <www.powerknowledge.com/home.htm>], it produces an aparently 'ready
to run' script to collect and save form to disk. However I can't actually
get it to do anything, amd when calling it, I get 'document contains no
data' from the browser, I guess this is beacuse it returns an http header
but is no sending any data.

I don't actually write perl and would appreciate it if someone could
quickly pass an eye over the script and see why it might behave thus (the
only problem I can think of is that it can't access the file it saves data
into, but surely it would return a descriptive error rather than nothing).

If someone can write something that works to do the same job, please do
let me know :)

PS: It's supposed to work with PERL4 but returns a generic server error
when you try and execute it.

Cheers,
/Jacob.



--------------
script follows
--------------

#!/usr/bin/perl5

#The HTML page 'tw-emADM.html' will be created when this PERL script
runs.  It will contain a button that enables the user to download the
survey data.
#It will be located in the directory docs/admin/tw-employees/
# Refer to the PowerKnowledge web site at <http://www.powerknowledge.com>
for updates and info.

#Subroutine Declarations #


#Note: the contents of cgi-lib.pl are included here for convenience.

sub ReadParse {
  local (*in) = @_ if @_;
  local ($i, $key, $val);

  # Read in text
  if (&MethGet) {
    $in = $ENV{'QUERY_STRING'};
  } elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
  }

  @in = split(/&/,$in);

  foreach $i (0 .. $#in) {
    # Convert plus's to spaces
    $in[$i] =~ s/\+/ /g;

    # Split into key and value.  
    ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.

    # Convert %XX from hex numbers to alphanumeric
    $key =~ s/%(..)/pack("c",hex($1))/ge;
    $val =~ s/%(..)/pack("c",hex($1))/ge;

    # Associate key and value
    $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
    $in{$key} .= $val;

  }

  return length($in); 
}

# PrintHeader
# Returns the magic line which tells WWW that we're an HTML document

sub PrintHeader {
  return "Content-type: text/html\n\n";
}

# MethGet
# Return true if this cgi call was using the GET request, false otherwise

sub MethGet {
  return ($ENV{'REQUEST_METHOD'} eq "GET");
}

# MyURL
# Returns a URL to the script
sub MyURL  {
  return  'http://' . $ENV{'SERVER_NAME'} .  $ENV{'SCRIPT_NAME'};
}

sub ShutDownAndSendMessageToClient {
   local($TheMessage) = @_;

   if ($LockFileAlreadyExists) {
      unlink $lockfile;  
      $LockFileAlreadyExists = "";
   }
   
   die($TheMessage);
}

# Use flock_open to open all files. Caller must initialize global var
$LockFileAlreadyExists to false before opening any files
sub flock_open 
{
   local(*FH, $filename, $ReadOrWrite) = @_;
   local(*LOCK);
   
   if ($ReadOrWrite eq "READ") 
      {
      open(FH, "<$filename") || ShutDownAndSendMessageToClient("Can't read
file \"$filename\" : $!\n");
      } 
   elsif ($ReadOrWrite eq "WRITE")
      {
      open(FH, ">>$filename") || ShutDownAndSendMessageToClient("Can't
write to file \"$filename\" : $!\n");
      } 
   else 
      {
      ShutDownAndSendMessageToClient("Anomalous paramaters passed to
flock_open.");
      }
   
   eval 'flock(FH, 2)';
   if ($@) 
      {
      #flocking failed. Let's see if we can FSpSetFlock it.
      eval 'FSpSetFLock($filename)';
      
      if ($@ && !$LockFileAlreadyExists) 
         {
            #FSpSetFLock failed. Let's fake it using a LockFile.

            ThankTheClient;  #Client doesn't need to hang around while we
wait for a lockfile
            
            # check if script is already executing
            $KeepWaiting = "TRUE";
            $StartingTime = Time;

            while ($KeepWaiting) 
            {
               # wait until lockfile is gone or 1/2 hour has elapsed
               $KeepWaiting = ((Time - $StartingTime) < 1800) && (-e $lockfile);
            }

            if ((Time - $StartingTime) >= 1800) 
            {
                ShutDownAndSendMessageToClient("Timeout Error");
            }

            open(LOCK, ">>$lockfile") ||
ShutDownAndSendMessageToClient("Can't open file \"$lockfile\" : $!\n");
            close(LOCK);
            
            #Update global var $LockFileAlreadyExists 
            $LockFileAlreadyExists = "TRUE";
         }
      }
}
   
sub flock_close {
   local(*FH, $filename) = @_;
   
   eval 'FSpRstFLock($filename)';   #In case FSpSetFlock was used

   close(FH);
}

#The terminating string ("print_tag") must appear by itself (unquoted and
with NO
#SURROUNDING WHITESPACE) on the terminating line.
#That's why this routine is not indented.
sub ThankTheClient {

if (!$ClientHasBeenThanked)
{
print<<"print_tag";
<html>
<head>

<title>Thank You </title>
</head>
<body>
<h2>
<center>
<BR>
Thanks very much for sharing your thoughts and feelings with us!

<BR>
<BR>
<A HREF= "$URLtoWebSite">Home</A>\n

</center>
</h2>
</body>

</html>
print_tag

$ClientHasBeenThanked = "TRUE";
}
}

#######################
#Main Body of Program #
#######################

require 'ctime.pl';  # needed for the date

if ($] < 5)
   {
      $TellUserToInstallPerl5 = "TRUE";
   } 
    else 
   {
      $UsingMacOS = ($^O eq 'MacOS');
      if ($UsingMacOS ) 
      {
         eval 'use Mac::Files';
         $TellUserToInstallMacFilesModule = "TRUE" if $@;
      }
   }

#Initialize Constants
$OpenForReading = "READ";
$OpenForWriting = "WRITE";

#Initialize Vars
$LockFileAlreadyExists = ""; #null string = FALSE
$LockFile = "";
$ClientHasBeenThanked = ""; #null string = FALSE

#####################################
#Survey-Specific Code and Variables #
#####################################



# setup enum type
@fields = ("1","2","3","4","5","6","7","8.1","8.2","8.3","8.4","9.1",
         "9.2","9.3","9.4","10","11","12","13","14","15","16","17","18",
         "19","ghidden20","20","21.1","21.2","21.3","21.4","21.5","21.6",
        
"21.7","21.8","21.9","21.10","21.11","21.12","22","23","ghidden24","24",
         "25.1","25.2","25.3","25.4","25.5","25.6","25.7","25.8","25.9",
         "26","ghidden27","27","28","29","30","31","32","33","34","35",
         "36.1","36.2","36.3","36.4","37","38","39","40");
@txtflds = ("");
$ThereAreResponsesGreaterThan255Chars = "FALSE";

$URLtoWebSite = "http://www.cbx..co.uk/";

$PathToTheSecureFolder = "docs/admin/tw-employees/";

$FileNameRoot = "tw-employees-survey"; #Used to construct filenames, using
the file extensions shown below
$htmlext = ".html"; #file extension for HTML files
$NameOfTheSecureFolder = "tw-employees/";




#########################
#Save All Response Data #
#########################

print &PrintHeader;
&ReadParse(*input);

$hdrtn = "\015";  # ascii 13
$lnfd = "\012";   # ascii 10

# you may wish to configure your server's MIME types to transfer .dat
files as binary so that
# files of this type are transferred immediately, rather than being
displayed as text 
# in the client's browser

$cntext = '.ctr';
$dataext = '.dat';
$lockext = '.lok';

$cntfilename = substr($FileNameRoot,0,8) . $cntext;  # this file will
contain the number of completed responses
$cntfilename = $PathToTheSecureFolder . $cntfilename;

$ResponseFileName = substr($FileNameRoot,0,7) . "1" . $dataext;  # this
file will contain the Responses to the majority of questions
$LongTextResponsesFileName = substr($FileNameRoot,0,7) . "2" . $dataext; 
# this file will contain the Responses from any Text fields that permit >
255 characters
$admfilename = $PathToTheSecureFolder . substr($FileNameRoot,0,5) . "adm"
 . $htmlext;
$lockfile = $PathToTheSecureFolder . $FileNameRoot . $lockext;

# open counter
$counter = 0;
if (-e $cntfilename)
{
   flock_open(COUNTER, $cntfilename, $OpenForReading);
   read(COUNTER, $counter, 20);
   truncate(COUNTER,0);
    flock_close(COUNTER, $cntfilename);
}

flock_open(COUNTER,$cntfilename, $OpenForWriting);
truncate(COUNTER,0);

print COUNTER ++$counter;
flock_close(COUNTER, $cntfilename);

# find and process multiple choice fields
@hidden = grep(/ghidden/,@fields);

foreach $mfield (@hidden)
{
   $len = $input{$mfield};
   $mfield =~ s/ghidden//;
   $_ = $input{$mfield};
   $num = s/\000/\t/g;
   if ($num ne "")
   {
      $input{$mfield} = $_ . "\t" x ($len - $num - 1);
   }
   else
   {
      $input{$mfield} = $_ . "\t" x ($len - 1);
   }
}

# open responses data file
flock_open(OUTPUT,"$PathToTheSecureFolder$ResponseFileName", $OpenForWriting);

print OUTPUT "\t\t\t\t\t\t\t\t";

$size = @fields; #$size now contains the number of elements in the array
$i = 0;
while($i < $size)
{
   $input{$fields[$i]} =~ s/\(no selection yet\)/ /; 
   if ($fields[$i] =~ /ghidden/)
   {
      $i++;
      next;
   }
   print OUTPUT $input{$fields[$i]},"\t";
 $i++;
}
print OUTPUT $counter,"\t",&ctime(time);  # write the date and time
flock_close(OUTPUT,"$PathToTheSecureFolder$ResponseFileName");

# open textfields file
flock_open(TEXTOUT,"$PathToTheSecureFolder$LongTextResponsesFileName",$OpenForWriting);

$size = @txtflds;
$i = 0;
while($i < $size)
{
   print TEXTOUT "      ",$counter,'   
Q#',$txtflds[$i],':(OE).',$input{$txtflds[$i]},$hdrtn,$lnfd,"\\",$hdrtn,$lnfd;
 $i++;
}
flock_close(TEXTOUT, "$PathToTheSecureFolder$LongTextResponsesFileName");

# open admin page to write new counter value
flock_open(ADMINOUT,"$admfilename", $OpenForWriting);
truncate(ADMINOUT,0);

print ADMINOUT<<"admin_header";
<HTML>
<HEAD>
<TITLE>Admin Page</TITLE>
</HEAD>
admin_header

print ADMINOUT "<BODY>\n<BR>\n<BR>\n<CENTER><H3>There have been $counter
responses to date.</H3></CENTER><BR>\n";

print ADMINOUT "<BR>\n<CENTER> To view responses click <A
HREF=\"",$URLtoWebSite,$NameOfTheSecureFolder,$ResponseFileName,"\">here</A>
or option-click to transfer the responses to your
computer.<\CENTER><BR>\n<P>\n";

if($ThereAreResponsesGreaterThan255Chars eq "TRUE")
{
print ADMINOUT "<BR>\n<CENTER>To view responses greater than 255
characters long, click <A
HREF=\"",$URLtoWebSite,$NameOfTheSecureFolder,$LongTextResponsesFileName,"\">here</A>
or option-click to transfer the responses to your
computer.<\CENTER><BR>\n<P>\n";
}

if($TellUserToInstallPerl5 eq "TRUE")
{
print ADMINOUT "<BR>\n<CENTER> PowerTab has noticed that you are using
version $] of PERL on your web server. This is an outdated version of
PERL. To take advantage of all of PowerTab's web survey features, please
update your server to the latest version of PERL.<\CENTER><BR>\n<P>\n";
}

if($TellUserToInstallMacFilesModule eq "TRUE")
{
print ADMINOUT "<BR>\n<CENTER> PowerTab has noticed that you have a Mac OS
web server, but the Mac::Files module for PERL has not yet been installed.
To take advantage of all of PowerTab's web survey features, please install
the Mac::Files module of PERL on your Mac OS web
server.<\CENTER><BR>\n<P>\n";
}

print ADMINOUT "</BODY>\n</HTML>\n";
flock_close (ADMINOUT, "$admfilename");

#Thank the client 
ThankTheClient;

# Cleanup
# In case lockfile was used      
if ($LockFileAlreadyExists) {
   unlink $lockfile;
   $LockFileAlreadyExists = "";
}


------------------------------

Date: Mon, 12 Oct 1998 00:18:04 -0700
From: Diego Acevedo <diego@valleyservices.com>
Subject: Re:Square Root In PERL
Message-Id: <3621AD27.D1FA38DB@valleyservices.com>

Is there a square root string or function in PERL?



------------------------------

Date: Mon, 12 Oct 1998 05:10:24 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Square Root In PERL
Message-Id: <comdog-ya02408000R1210980510240001@news.panix.com>
Keywords: from just another new york perl hacker

In article <3621AD27.D1FA38DB@valleyservices.com>, diego@valleyservices.com posted:

>Is there a square root string or function in PERL?

did you look in perlfunc?

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


------------------------------

Date: 12 Oct 1998 16:46:08 +1000
From: bod@compusol.com.au (Brendan O'Dea)
Subject: Re: use autouse problem in perl 5.004
Message-Id: <6vs8jg$e4m$1@duende.compusol.com.au>

In article <ptrsogx6b27.fsf@olkikukka.i-have-a-misconfigured-system-so-shoot-me>,
Jari Aalto+mail.perl <jari.aalto@poboxes.com> wrote:
>use autouse File::Basename => qw( fileparse basename dirname );

>Bareword "File::Basename" not allowed while "strict subs" in use at [...]

>	If I take away the "use strict" the code works, but I don't want
>	to compromise that. Shouldn't => operator quote anytthing to the left,
>	so why does "strict" complain?

The `=>' operator doesn't quote just `anything' to the left, only
identifiers (ie. [^\W\d]\w*).  The perlop(1) documentation is a
little ambiguous here:

    [...] As of release 5.001, it also forces any *word* to the left of
    it to be interpreted as a string.  [my emphasis]

as `word' could be [mis-]interpreted to mean `string' (ie. \S+).

Consider this hash:

    use strict;
    my %a = (
        foo                 => 'foo',
        -bar                => -'bar',               # '-bar'
        'File::'.Basename   => 'File::'.'Basename',  # 'File::Basename'
        0001                => 1,
        0x10                => 16,
    );

in which the values are equal to the keys.  Note that I'm *not*
advocating the use of 'File::'.Basename :-)

Regards,
-- 
Brendan O'Dea                                        bod@compusol.com.au
Compusol Pty. Limited                  (NSW, Australia)  +61 2 9809 0133


------------------------------

Date: Mon, 12 Oct 1998 10:51:28 GMT
From: gya@my-dejanews.com
Subject: Win32::NetAdmin usage problem
Message-Id: <6vsmvg$nt9$1@nnrp1.dejanews.com>

I have installed the ActiveState Perl release ( Build 316 ) on my NT4 P.C.I
have written and executed Perl scripts, Win32::File module packages etc but
when I try and use the Win32::NetAdmin package it is reporting an error.
Below is an example of the script and the resultant error message. N.B. I
have also downloaded the Dave Roth AdminMisc package and that works fine but
the bits I require are in the Win32::NetAdmin package.	 
C:\perl\ybs\test\NETWORK\test_perl.pl  
use Win32::NetAdmin;  
 
# Set up
parameters $username = 'GYA'; 
 
Win32::NetAdmin::UserGetAttributes  ('', 
 
$username,   $Getpassword,  
	$GetpasswordAge,  
  $Getprivilege,  
 
$GethomeDir, 	$Getcomment,  
  $Getflags,  
	$Getscriptpath ) || die $!; 
print "The user is  : $username \n"; 
print "Fullname is  : $Getfullname
\n"; print "Password is  : $Getpassword \n"; 
print "Password age is  :
$GetpasswordAge \n"; print "Privilege is  : $Getprivilege \n"; 
print "Home
directory  : $GethomeDir \n"; print "Comment  : $Getcomment \n"; 
print
"Flags	: $Getflags \n"; print "Script path  : $Getscriptpath \n"; 
 
 
Upon
execution all I get from $!  is   
  No such file or directory at
C:\perl\ybs\test\NETWORK\test_perl.pl line 6. 
If anyone can throw any light
on it for me please email me atgyatkinson@ybs.co.uk.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 3951
**************************************

home help back first fref pref prev next nref lref last post