[6628] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 253 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 8 10:17:11 1997

Date: Tue, 8 Apr 97 07:00:26 -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           Tue, 8 Apr 1997     Volume: 8 Number: 253

Today's topics:
     Re: Accept function call <tom@eiscat.uit.no>
     Re: flock() not implemented on Solaris 2.5.1? (Peter Haworth)
     Re: Help regarding Microsoft's Personal Web Server CGI  <lpa@sysdeco.no>
     Re: How to use COOKIES from perl ??? (Mike Stok)
     Re: How to use COOKIES from perl ??? (Kerry Schwab)
     Re: LWP - again... (Mike Stok)
     Re: Newbie Question about Llama Book (Tad McClellan)
     Re: Newbie Uncertainties, Chess Translator (Mike Stok)
     Re: Ousterhout and Tcl lost the plot with latest paper (Richard A. O'Keefe)
     Re: Ousterhout and Tcl lost the plot with latest paper (Richard A. O'Keefe)
     Perl / Forms and  Post <Patrick.Reilly@netcel.co.uk>
     Re: Perl and MSDOS <piet@cs.ruu.nl>
     problem with -s <jim.michael@gecm.com>
     question about printing + interpolation with object ref (Curtis Hrischuk)
     Re: Renegade script setting own values? <merlyn@stonehenge.com>
     Re: Split and Print? (Mike Stok)
     Re: Split and Print? (Tad McClellan)
     Re: TPJ: Nukes (Terje Bless)
     Tutorial for Win32 Perl <dhayden@netcomuk.co.uk>
     Re: Unix and ease of use  (WAS: Who makes more ...) <kenny@kacweb.com>
     Win95 opendir() (Marcel Kuiper)
     Working perl script... not running with HTTP get. (nick^)
     Re: Working perl script... not running with HTTP get. (Mike Stok)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 08 Apr 1997 13:10:33 +0200
From: Tom Grydeland <tom@eiscat.uit.no>
Subject: Re: Accept function call
Message-Id: <trafn9py6u.fsf@eiscat.uit.no>

jason kruse <jason.kruse@teldta.com> writes:

> How do you call accept so that a new file descriptor will be generated
> and can be found?  Here is what I am doing at present.

You're using filehandles when you want objects to manipulate.

use IO::Socket;


> socket(Client, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
> socket(Server, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
> 
> bind (Client, sockaddr_in(4000, INADDR_ANY));
> bind (Server, sockaddr_in(4001, INADDR_ANY));
> 
> listen(Client, SOMAXCONN);
> listen(Server, SOMAXCONN);

Why would a Client want to listen?

$Client = IO::Socket::INET->new(Proto => 'tcp', Listen => SOMAXCONN,
				LocalPort => 4000);
$Server = IO::Socket::INET->new(Proto => 'tcp', Listen => SOMAXCONN,
				LocalPort => 4001);

> $list = IO::Select->new();
> $list->add(\*Client);

$list->add($Client);

> $list->add(\*Server);

$list->add($Server);

> while (@ready = $list->can_read()) {

I've been bitten by this in Solaris.  I now use

while () {
    my @ready = $list->can_read();

>    foreaech $sock (@ready) {
         ^^ ??  :-)
> 
>    if ($sock == \*Client) {
>        accept(Host, Client);
>        $list->add(\*Host);
> }

    if ($sock == $Client) {
        my $Host = $sock->accept	or die "Whatever: $!";
        $list->add($Host);
    }

> # Here I want to have a number of people being able to connect to the
> # server.  How can I do this in a similar fashion as the C function call 
> # for accept?
> elsif ($sock == \*Server) {  
>        accept(Serv, Server);
>        add_to_list(\*Serv);

         my $Serv = $Server->accept    or die "Again: $!";
         $list->add($Serv);

> }
> else {
>       process($sock);
>       $list->remove($sock);
>       close($sock);
> }
> }

Take a look at the examples provided with IO::Socket and IO::Select

HTH,

-- 
//Tom dot Grydeland at phys dot uit dot no
            The case of Randal Schwartz - http://www.lightlink.com/fors/


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

Date: 8 Apr 1997 11:52:53 GMT
From: pmh@ioppublishing.com (Peter Haworth)
Subject: Re: flock() not implemented on Solaris 2.5.1?
Message-Id: <5idbil$rf6@newton.ioppublishing.com>

In article <3345D1F5.6FAE215C@enteract.com>,
	Eryq <eryq@enteract.com> writes:
> Nancy Voorhis wrote:
> 
>> Perhaps I haven't sufficiently perused the Perl documentation but my
>> understanding from all the man pages, FAQ's, compilation notes, etc. is
>> that the builtin flock() function ought to work
>> if I my system implements any one of the following (and it will try them
>> in this order): flock,  fcntl, lockf (see
>> perlfaq5/How_can_I_lock_a_file)
> 
> Since 5.001 is a little hoary anyway, I would... 
> 
> 	1. upgrade to a Perl that emulates with fcntl(), or

Good idea

> 	2. upgrade anyway, and make sure it builds using the BSD library, or
> 	3. rebuild your 5.001 with the BSD library, or 

Not good ideas. The BSD library shouldn't be used.

> 	4. find an extension module that emulates flock() with fcntl(), or
> 	   that calls the BSD flock(), or
> 	5. write an extension module that emulates flock() with fcntl(), or
> 	   that calls the BSD flock().

There are a couple on CPAN. File::Lock is the one you probably want.
The others seem to be wrappers round perl's flock(), which won't improve your
situation.

> As usual, TMTOWTDI :-)

I solved this by patching pp_flock() in pp_sys.c to call fcntl() if it existed,
in preference to lockf(). This is a pretty simple patch, but I got fed up of
doing it every time we upgraded perl, so I submitted it to perl5-porters,
where it was rationalised (that means it was completely rewritten and made to
fit in  with the way the rest of the perl source properly - thanks Chip!) and
will be in perl5.004

Peter

-- 
	Peter Haworth	pmh@edison.ioppublishing.com
In terms of visual processing, humans aren't good at counting above one.
	-- Larry Wall


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

Date: Tue, 08 Apr 1997 15:21:15 +0200
From: Luca Passani <lpa@sysdeco.no>
Subject: Re: Help regarding Microsoft's Personal Web Server CGI configuration
Message-Id: <334A464B.4081@sysdeco.no>

Pete Miller wrote:
> 
> Hey, I just cracked this last weekend...
> 
> See MS knowledge base
> 
> article q158236 - 500 server error
> --------q150629 - configuring and testing a perl script for IIS
> 
> The second one shows what to do with the registry, although for IIS, it's just about
> the same for Win95.
> 
> Ensure that the directory on the server is marked for execute and NOT
>read.

I think it's worth pointing out that the execute checkbox is in the
"share" part of the directory properties dialog box. Putting it there is
surprisingly poor GUI design.

NOW:

PLEASE INSERT THIS ANSWER IN ALL OF THE RELEVANT FAQS, SINCE THERE HAVE
6 PEOPLE ASKING THIS QUESTION ON THE COMP.LANG.PERL.MISC NEWSGROUP WHICH
HAS NOTHING TO DO WITH IT!


> 
> Good luck...
> 
> In article <33489aa1.11446457@news.primenet.com>, Benson Trinh <benson@primenet.com>
> writes
> >Your approach to this is incorrect.  First, you need to create an
> >association with .cgi or .pl in Explorer.  Then you need to add the
> >.pl or .cgi mapping in the registry.  If you need further details,
> >e-mail me.  I've done this but currently the problem I have is that I
> >need to create one directory or each perl script.  However, others
> >have added perl with this method and it has worked for them.
> >
> >Benson
> >
> >On Wed, 26 Mar 1997 01:25:12 -0800, Gunraj Singh
> ><Gunraj.Singh@atsys.com> wrote:
> >
> >>Hi
> >>
> >>I am facing a problem regarding MicroSoft's Personal Web Server. I am
> >>using this server on Win 95 system and I'am trying to run some cgi
> >>scripts written in Perl in the cgi-bin directory, which also contains
> >>the Perl for Win32 executable file. What happens is that
> >>
> >>1) If I am using MS Internet Explorer then it gives error:
> >>               500 Server Error    for files with .cgi extension
> >>   but opens files with .pl extension.
> >>
> >>2) If I am using Netscape 3.0 then it gives the same error for file
> >>   with .cgi extension i.e. 500 Server Error but opens .pl file
> >>   as Save as to disk. I changed the Option for x-perl application to
> >>run the perl.exe file on win95 but it stills open as save as.
> >>
> >>
> >>Both Netscape and IE opens cgi scripts if they are running on some other
> >>servers. Certainly it has something to do with Microsoft's PWS.
> >>
> >>Is there any way to configure PWS so that cgi scripts run successfully
> >>on both IE and NEtscape and I don't get the above errors. If so, can
> >>anybody help me in that ?
> >>
> >>I would greatly appreciate any help.
> >>
> >>
> >>Gunraj Singh
> >
> 
> --
> Pete Miller     email: pete@superpan.demon.co.uk
>                 Web:   http://www.superpan.demon.co.uk

-- 

======================================================================
Luca Passani.          | Sysdeco Innovation AS, http://www.sysdeco.no
Email: lpa@sysdeco.no  | Trondheimsveien 184, 0570 Oslo, Norway
Tel: (+47) 22 09 66 06 | Fax: (+47) 22 09 65 03
======================================================================


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

Date: 8 Apr 1997 11:24:51 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: How to use COOKIES from perl ???
Message-Id: <5id9u3$cbf@news-central.tiac.net>

In article <33495055.4BC4@telebyte.nl>,
T. de Konink <konink@telebyte.nl> wrote:
>Hello,
>
>I want to use cookies for an internet-game I'm going to develop, soo I
>can identify the players. 
>
>QUESTION:
>How can I set and "read" cookies from a Perl script.

Cookies are sent between web servers & browsers in the header of an HTTP
message.  The perl CGI.pm module which is available on CPAN (check out
http://www.perl.com/CPAN/ or ftp to ftp.funet.fi and look in
/pub/languages/perl/CPAN) which contains some useful routines for cookie
manipulation which are described in its documentation.

[...]

  The -cookie parameter generates a header that tells the browser to provide
  a "magic cookie" during all subsequent transactions with your script.
  Netscape cookies have a special format that includes interesting attributes
  such as expiration time.  Use the cookie() method to create and retrieve
  session cookies.

[...]

  The interface to Netscape cookies is the cookie() method:

      $cookie = $query->cookie(-name=>'sessionID',
                               -value=>'xyzzy',
                               -expires=>'+1h',
                               -path=>'/cgi-bin/database',
                               -domain=>'.capricorn.org',
                               -secure=>1);
      print $query->header(-cookie=>$cookie);

  cookie() creates a new cookie.  Its parameters include:

[...]

  To retrieve a cookie, request it by name by calling cookie() method without
  the -value parameter:

          use CGI;
          $query = new CGI;
          %answers = $query->cookie(-name=>'answers');
          # $query->cookie('answers') will work too!
                                                               
Using the CGI.pm module will probably save you a lot of work if you're
writing web applications from scratch, if you need details of what cookies
are meant to do then one of the cgi newsgroups or www.w3.org might be
better places to ask.

Hope this helps,

Mike



-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 8 Apr 1997 06:45:46 -0600
From: kschwab@nyx10.cs.du.edu (Kerry Schwab)
Subject: Re: How to use COOKIES from perl ???
Message-Id: <5idelq$od2@nyx10.cs.du.edu>

In article <5ici8p$61a$1@news3.microserve.net>,
Geoffrey Hebert <soccer@microserve.net> wrote:
>Perl read and writes.
>
>Cookies are a form of data formated so that a www browser can process
>it.
>
>This is not a perl question.  use another news group.
>   try comp.info.system.www.authoring.cgi
>

I think that asking if there's already work done to interface with cookies
from perl is a perfectly legitimate question. 

Lincoln Stein's CGI.pm module has "cookie" support...

$cookie = $query->cookie(-name=>'sessionID',
                             -value=>'xyzzy',
                             -expires=>'+1h',
                             -path=>'/cgi-bin/database',
                             -domain=>'.capricorn.org',
                             -secure=>1);
    print $query->header(-cookie=>$cookie);

Check CPAN...

--
Kerry


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

Date: 8 Apr 1997 13:03:30 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: LWP - again...
Message-Id: <5idfn2$hgh@news-central.tiac.net>

In article <334A0BFE.167E@dircon.co.uk>,
Alex Schajer  <schajer@dircon.co.uk> wrote:

>I'm trying to user the LWP library and in particular the HTTP/Header
>part.
>All I want to do is go through a list of URL's and check when they were
>last modified. It says in the LWP manual user 
>
>if ($h->last_modified < time - 60 *60 {
>...
>}
>
>However how do I tell the script what webpage to look at?

#!/usr/local/bin/perl -w

require LWP::UserAgent;
$ua = new LWP::UserAgent;
$request = new HTTP::Request('GET', 'http://www.perl.org/');

my $res = $ua->request ($request);

if ($res->is_success) {
  my $lastModified = $res->last_modified;

  if (defined $lastModified) {
    print scalar (localtime $lastModified), "\n";
  }
  else {
    print "No last modified header\n";
  }
}
else {
  print "Request failed\n";
}

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 8 Apr 1997 06:06:33 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Newbie Question about Llama Book
Message-Id: <pr8di5.et.ln@localhost>

Stephen J. Cole (scole@liberty.uc.wlu.edu) wrote:
: Greetings, I am playing with Perl and going through the llama book and am 
: stumped on page 56.  The fifth, sixth, and seventh printed lines state:

: ($d,@fred) = ($a,$b,$c); # give $a to $d, and ($b,$c) to @fred

after that assignment:

$d=$a;
$fred[0]=$b;
$fred[1]=$c;

: ($e,@fred) = @fred; # remove the first element of @fred to $e

after that assignment:

$e=$b;          # from the original $fred[0] (above)
$fred[0]=$c;    # whatever is left (only the single variable, in this case)
                # gets put into @fred


: # this makes @fred = ($c) and $e =$b

: Would someone be so kind to explain this to me.  Perhaps I am rather 
: "thick" but it doesn't seem to make sense to me.

: As there isn't probably a huge need to waste bandwidth here, feel free to 
: just email me rather than doing a followup.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 8 Apr 1997 12:42:28 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Newbie Uncertainties, Chess Translator
Message-Id: <5idefk$gd2@news-central.tiac.net>

In article <y+cSz4mipRgR090yn@islandnet.com>,
Jonathan Berry <jberry@islandnet.com> wrote:

>@English = qw ( P N B R Q K );
>@French  = qw ( P C F T D R );
>
>foreach $Piecex (@English) {
>  $Trans {$Piecex} = $French [$counter++];
>}

You can say @Trans{@English} = @French; for this, is that the type of
array assignment you didn't like?

>while (<>)  {
>  foreach $Key (keys %Trans) {
>    s/($Key)(x?[1-8]?[a-h]{1,2}x?[1-8])/$Trans{$Key}$2/g;
>  }
>  print OUTFILE;
>}

As the keys to %Trans are single characters you can build up a character
class for them e.g. [PNBRQK] in a regex will match a character which is
one of the things between [ and ] so you can say (using the perl 5 x
modifier on the s/// to spread out the expression over multiple lines and
allow comments:

$class = '[' . join ('', keys %Trans) . ']';

while (<>) {
  s/\b                          # word boundary
    ($class)                    # valid piece letter -> $1
    (x?[1-8]?[a-h][a-h]?[1-8])  # rest of move -> $2
    \b                          # word boundary
   /$Trans{$1}$2/gx;
  print OUTFILE;
}


>Criticisms?
>
>I found the way I discovered (tim-woody?) of assigning the
>arrays to a hash to be inelegant, especially when you try to
>apply it to a "general case" such as translating a chess game
>from any language to any other language.  Surely there's a way
>to choose any array as the keys--and any other array as the
>values--of the hash without going through what in BASIC would
>be a double SELECT CASE process.

If you have $from = 'English' and $to = 'French' then you could use perl 5
soft references e.g.

  @Trans{@{$from}} = @{$to};

but this requires that the from and to arrays be in the symbol table (i.e.
not "my" variables) and strict references be turned off.

>The general case process also fails in half the cases when the
>two languages share a letter for the pieces.  For example, if I
>were to reverse the two languages here, the French Tour (T)
>would be translated to the English Rook (R) and then in the
>subsequent processing this would be confused with the French
>Roi (R) and translated to the English King (K).  So every French
>rook move would become an English king move.  I could avoid
>this problem by moving the kings up before the rooks in the
>arrays, but it could easily rear its ugly head again in other
>languages.

the s///g remembers where it has got up to in a string, so you won't
attempt a second round of substitution unless you ask for it

>A possible solution is to split the input line into words,
>process each word separately, exiting the loop on success, and
>then joining the processed words.  Each word (entity separated
>by whitespace) would contain no more than one chess move.
>
>The compiler gave me a warning message on account of the
>$counter which it thought was used only once.

It only appears in the text once, it's a useful warning in most cases
(especially for me as I can't type accurately :-) and one way to avoid the
warning is to explicitly initialise it to 0.

#!/usr/local/bin/perl -w

use strict;
use vars qw/@English @French/;

sub translate;

@English = qw/ P N B R Q K /;
@French  = qw/ P C F T D R /;

my @frenchGame = translate 'English' => 'French', <DATA>;
my @englishGame = translate 'French' => 'English', @frenchGame;

print @frenchGame;
print @englishGame;

sub translate {
  my $from = shift;
  my $to = shift;
  my %Trans;
  my @result;

  {
    no strict 'refs';
    defined @{$from} and defined @{$to} or die "\@$from or \@$to missing\n";
    @{$from} == @{$to}or die "\@$from or \@$to are different sizes\n";
    @Trans{@{$from}} = @{$to};
  }

  my $class = '[' . join ('', keys %Trans) . ']';
  while (@_) {
    $_ = shift;
    s/\b                                # word boundary
      ($class)                  	# valid piece letter -> $1
      (x?[1-8]?[a-h][a-h]?[1-8])        # rest of move -> $2
      \b                                # word boundary
     /$Trans{$1}$2/gx;
    push @result, $_;
  }

  return @result;
}

__END__
[Event "1997 Toronto Closed Chess Championship"]
[Site "Primrose Hotel"]
[Date "1997.01.18"]
[Round "2"]
[Result "1-0"]
[White "Zugic, Igor"]
[Black "Day, Lawrence"]

1. d4 g6 2. c4 Bg7 3. Nf3 d6 4. g3 Nf6 5. Bg2 O-O
6. O-O Nbd7 7. Nc3 c6 8. e4 e5 9. h3 Qa5 10. Qc2 exd4
11. Nxd4 Qc5 12. Nce2 Nb6 13. b3 Re8 14. Be3 Qh5
15. Rad1 Qe5 16. Nc3 Qe7 17. Rfe1 Qc7 18. f4 a6
19. Bf2 Bd7 20. a4 a5 21. Rd2 Rad8 22. Red1 Bc8
23. Ndb5 cxb5 24. Nxb5 Qc6 25. Rxd6 Rxd6 26. Rxd6 Nxe4
27. Rxc6 Nxf2 28. Rxc8 Nxh3+ 29. Bxh3 Nxc8 30. Qd2 f5

As usual in perl there's more than one way to do it, and this is probably
not the best or most elegant...

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 7 Apr 1997 18:39:36 +1000
From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <5iabs8$r6r$1@goanna.cs.rmit.edu.au>

fellowsd@cs.man.ac.uk (Donal K. Fellows) writes:
>In article <s6y208um0ey.fsf_-_@aalh02.alcatel.com.au>,
>Chris Bitmead  <Chris.Bitmead@alcatel.com.au> wrote:

>[ button example elided ]
>> Come on! All this shows is the inconveniece of using the MFC
>> classes. An interface exactly the same as the Tcl one could easily be
>> written in C++.

>Oh?  I'd love to see you try it.  (Clue: the configuration parameters
>can be in any order, and there are a lot more that have been omitted.
>C++ offers no good support for this at all.)

I note that the way Limbo (the vaguely C-ish language used in the Inferno
network OS) handles its GUI interface is by creating window objects and
sending Tk strings to them.  There is no TCL there; just their completely
fresh implementation of Tk.  What precisely is there about C++ that would
prevent equally direct use of a Tk clone from C++?

-- 
Will maintain COBOL for money.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.


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

Date: 7 Apr 1997 18:54:53 +1000
From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <5iacot$sd7$1@goanna.cs.rmit.edu.au>

ouster@tcl.eng.sun.com (John Ousterhout) writes:

>2. Many people objected to the fact that their favorite programming
>   was left out of the white paper.  Yes, I have heard of Scheme,
>   Smalltalk, ML, etc.  I left these languages out because they
>   didn't seem particularly relevant for the discussion.  No offense
>   intended...

Lisp having been used as a scripting language for a lot longer than TCL,
it was a *relevant* omission.  (Yes, I have used Lisp as my command and
scripting language, and yes, it was before TCL.)

>     - It is possible to make languages with execution speeds like C or C++,
>    that use dynamic typing successfully, whilst being high-level enough
>    in the creation of abstractions to "glue" things together quite
>    nicely and easily.

>Can you point to a specific language and identify a large community of
>users who agree with this assessment?

But restricting it to a large community smuggles in another criterion:
marketing.  SELF, for example, has dynamic typing, and published benchmarks
show it close to C or C++.  I imagine people at Sun would understand more
about SELF than I do.  I've certainly had Scheme code perform close to C
(with the aid of comilers that do a fair amount of type inference, admitted.)

I would also expect someone from Sun to be aware of the awesome ease of
interoperability with C/C++ offered by ESH.

>Either you have a strongly typed language, which gives high
>speed and manageability but makes gluing hard, or you have a weakly
>typed language with the opposite properties.

This is clearly false.  You can have a language with *optional* 
declarations which can be checked and relied on if they are there.
Mercury programs, for example (a statically typed language) can usually
by run by NU Prolog (a dynamically typed language) if you erase the
declarations.  Common Lisp type information is optional.  There are
people currently designing a type system for Erlang (Ericsson's
functional + concurrent language); that will be yet another example
of a system with optional declarations for speed and static checking
yet able to run without them.  (Henry Baker has a paper on a type
inference algorithm for Common Lisp types.)

-- 
Will maintain COBOL for money.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.


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

Date: Tue, 08 Apr 1997 11:31:35 +0100
From: Patrick <Patrick.Reilly@netcel.co.uk>
Subject: Perl / Forms and  Post
Message-Id: <334A1E87.2F57@netcel.co.uk>

I would like to get a perl program to pretend to be a form!

But, I DON'T want the perl program to produce a form that a user can
fill in. I need to get the perl program to send the info. to the form
handler.

using GET I can do the following...

print "Location: http://www.my.site.com/Perl/formhandle.pl?n=55\n\n";

but how the dickens do I get a POST to work?
I've tried :_

print "Location: http://www.my.site.com/Perl/formhandle.pl\n\n";
print "n=55";

and 

print "Location: http://www.my.site.com/Perl/formhandle.pl\nn=55\n\n";

Help??

Cheers

Pat


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

Date: 08 Apr 1997 13:53:31 +0200
From: Piet van Oostrum <piet@cs.ruu.nl>
Subject: Re: Perl and MSDOS
Message-Id: <wzlo6tyblw.fsf@kemmel.cs.ruu.nl>

>>>>> "Smith A. Cat" <imbe@primenet.com> (SAC) writes:

SAC> I know I am the ONLY person using Perl in MSDOS, but I would like to
SAC> share my experience getting the latest Ilyaz port running "as
SAC> advertised" under DOS:

SAC> got the files:
SAC> 		1. perl_aou.zip
SAC> 		2. perl_mlb.zip

SAC> unzipped perl_.exe into c:\perl and renamed it to perl.exe

SAC> pkunzip -d perl_mlb.zip from c:\perl\lib

SAC> hex edited the perl.exe so that one of the internal directory
SAC> entries pointed at c:/perl/lib (instead of f:/blah/blah/blah).

No need to hex edit it. There is an environment variable  to take care of
this, something like PERLLIB_PREFIX. See the readme file for the exact
name.

SAC> hex edited the perl.exe so that where it said f:/bin/sh.exe it
SAC> now says c:4dos.com (shareware DOS command interpreter) so that
SAC> the exe will spawn a subshell nicely.

sh.exe will also do this, and there may be some cases where it it more up
to perls expectations than 4dos.com. On the other hand it would have been
nice if you would be able to specify which one to use.

SAC> and most importantly:

SAC> DID NOT set the PERLLIB variable! If you set it to anything at all
SAC> the system will not spawn a subshell!! don't know why.  this is why
SAC> I hex edited the binary.

I have the PERLLIB variable set (because of perl4), and I could spawn
subshells.

SAC> but i did:

SAC> use emm386 with the noems switch.
SAC> loadhigh cwsdpmi -p (charles sandman's excellent DPMI service!)
SAC> set emx=c:rsx.exe (since emx won't do the piping stuff perl wants)

SAC> (also helps to hex edit rsx.exe so that the version reads c9.0. not
SAC> necessary, but disables irritating emx (yes emx) version warning. most
SAC> emx stuff seems to work with cwsdpmi and rsx, including TeX, metafont, 
SAC> and all the DJGPP stuff.)

You could also get a new version of rsx.exe that is emx 0.9c compatible.

SAC> and after doing this can use the system, exec, and backtick functions
SAC> very well, thank you!  if you don't do all of these things you will 
SAC> absolutely NOT get system , exec, and backticks (``) working.

I didn't do all these things, and still could get these working. But then I
run it in a DOS box under MS Windows, maybe that's the difference.

See http://www.cs.ruu.nl/~piet/perl5dos.html



-- 
Piet van Oostrum <piet@cs.ruu.nl>
URL: http://www.cs.ruu.nl/~piet [PGP]


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

Date: 8 Apr 1997 12:39:45 GMT
From: Jim Michael <jim.michael@gecm.com>
Subject: problem with -s
Message-Id: <5ideah$tc2@gcsin3.geccs.gecm.com>

I have a script which FTPs some files from our Vax cluster to an NT 
(alpha) server. If the target files do not exist yet, zero byte files are 
created on the NT server during the FTP session. Another script creates a 
copy routine, but it  appears the -s does not work since all files are 
copied including the 0 byte files:

if (-s $datafile) {
        print MYFILE ("copy $datafile \"Daily Captures\"\n");
}

How can I properly test for an empty file? TIA.

Jim



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

Date: 08 Apr 1997 12:53:44 GMT
From: ceh@arcturus.sce.carleton.ca (Curtis Hrischuk)
Subject: question about printing + interpolation with object reference
Message-Id: <CEH.97Apr8085344@arcturus.sce.carleton.ca>

Hi.  I do not understand the following ambiguity about printing and
interpolation of an object reference.  Could someone please explain
what is going on and why.

The example code is:
	my($temp) = $anObject->name();
	print "Case 1 THIS IS THE  NAME $temp\n";
	print 'Case 2 THIS IS THE  NAME ' . $anObject->name() . "\n";
	Print "Case 3 THIS IS THE  NAME  $anObject->name() \n";

The output is:
	Case 1 THIS IS THE  NAME 1
	Case 2 THIS IS THE  NAME 1
	Case 3 THIS IS THE  NAME  Thread=HASH(0xecfd4)->name() 

I do not understand why Case 3 differs from the other two.

Thanks

Curtis
-- 
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ Curtis Hrischuk (PhD Cand)  "in reality that comes from above      _/
_/ ceh@sce.carleton.ca          God is calling                        _/
_/ Carleton University          there's no bigger love                _/
_/ Ottawa, On., Canada, K1S-5B6 It's his reality that welcomes us back_/
_/ Ph  (613) 520-2600 x1762     Trust and obey                        _/
_/ FAX (613) 520-5727           there is no other way..." the newsboys_/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


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

Date: 08 Apr 1997 04:28:07 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: mriggsby@sybex.com
Subject: Re: Renegade script setting own values?
Message-Id: <8cg1x1rby0.fsf@gadget.cscaper.com>

>>>>> "Matt" == Matt Riggsby <mriggsby@sybex.com> writes:

Matt>    if ($bodyappend = "Yes") {

Ouch.  To para-quote Princess Bride, "You keep using that word.  I do
not think that word means what you think it means."

You have assigned "Yes" to $bodyappend, and then checked to see if
that was true.  Yuppers.  It is.

I think you'll get along better with Perl if you change that to:

	if ($bodyappend eq "Yes") {

But that's only a guess.  (Probably durn good one. :-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 511 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 8 Apr 1997 11:18:07 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Split and Print?
Message-Id: <5id9hf$c4c@news-central.tiac.net>

In article <334cf94e.331928359@sfunix2.fln.ads.se>,
Pontus Berglund <pontus@se.adsanker.com> wrote:
>On Tue, 08 Apr 1997 03:11:47 GMT, tgy@chocobo.org (Tim Gim Yee) wrote:

>>$hits = (split)[0];
>
>Oh, this is a good one. But if I want to use two or three variables,
>which is often the case when I'm stating a file? Is there a similar
>trick then?
>
>I'm new to Perl and I'm waiting for my copy of the camel book, so
>please excuse me if this question is particularly.

You can supply a list of indicies in the [], so you can say

  ($uid, $gid, $mode) = (stat $file)[4, 5, 2];

note that there are () around the list of values you're assigning to.
There is a difference between:

  $item = stat $file;

and 

  ($item) = stat $file;

where the stat in the first assignment knows it's in a context where the
assignment wants a single scalar so it returns a true value if the stat
call succeeds and a false value if stat fails (and sets $!)  

In the second assignment stat knows that it's called in a context where
the asignee wants a list of values, ($item) is a list, so stat returns a
list which is used to populate the single element list ($item)

If you say

  $item = (stat $file)[0];

you get the same effect as the second example above, *but* it's a scalar
assignment and the combination of () and a subscript tell perl to call
stat in a list context.

I hope that I haven't clouded the issue too much, scalar vs. list/array
context is one of the ways in which perl infers what to do, in your own
subroutines you can use wantarray to tell whether perl's requesting a
scalar or a list back, and a little function like

  sub tryContext { print wantarray ? "wants list" : "wants scalar"; }

and the debugger (which can be called up using the command 'perl -de 1')
let you experiment:

  DB<1> sub tryContext { print wantarray ? "wants list" : "wants scalar"; }

  DB<2> $d = tryContext
wants scalar
  DB<3> @d = tryContext
wants list
  DB<4> ($d) = tryContext
wants list
  DB<5> $d = (tryContext)
wants scalar
  DB<6> $d = (tryContext)[0]
wants list

As you mention stat in particular you might use the trick of using _ as a
file name which tells the file test operators and stat to use the current
contents of the stat buffer, then 2nd edition camel book says

  if (-x $file and ($d) = stat (_) and $d < 0) {
    print "$file is an executable NFS file\n";
  }

where the stat uses the buffer which was loaded by the -x test.

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 8 Apr 1997 05:22:59 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Split and Print?
Message-Id: <3a6di5.up.ln@localhost>

Pontus Berglund (pontus@se.adsanker.com) wrote:
: On Tue, 08 Apr 1997 03:11:47 GMT, tgy@chocobo.org (Tim Gim Yee) wrote:

: [...]
: >
: >You only used $size, $bytes, and $URL once.  You've assigned values to
: >them, but then neglected them.  If $hits is the only variable you plan
: >to use, then perhaps...
: >
: >$hits = (split)[0];

: Oh, this is a good one. But if I want to use two or three variables,
: which is often the case when I'm stating a file? Is there a similar
: trick then?


To get only the size [eighth] and modification time [tenth]:


($size, $mod_time) = (stat("skel"))[7,9];


: I'm new to Perl and I'm waiting for my copy of the camel book, so
: please excuse me if this question is particularly.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 08 Apr 1997 12:56:59 +0100
From: link@tss.no (Terje Bless)
Subject: Re: TPJ: Nukes
Message-Id: <link-YANW250b4-0804971256590001@news.uit.no>

In article <33448218.535417747@news.diac.com>, sitaram@diac.delete.com wrote:

>Randal Schwartz <merlyn@stonehenge.com> wrote:
>
>>As long as it doesn't map() to my house, which'd be the sort() of
>>thing that could really ruin my day.
>
>Shouldn't that be "my() day" ? :-)

No, it should be "my $house" and "my(@day).".

(four days late and a terrible sense of humor. I'm *bound* to be a hit. ;D)

-- 
Party? Party, lord? Yes, lord. Right away, lord.
        - Beopunk Cyberwulf


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

Date: 8 Apr 1997 09:28:50 GMT
From: "David Hayden" <dhayden@netcomuk.co.uk>
Subject: Tutorial for Win32 Perl
Message-Id: <01bc43ff$181ce6c0$6502a713@fce04438.jubilee.ford.com>

Can anyone tell me if there is an On-line Perl Tutorial available, written
for those people using Perl on W95/NT.



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

Date: Tue, 08 Apr 1997 04:40:37 -0600
From: "Kenny A. Chaffin" <kenny@kacweb.com>
Subject: Re: Unix and ease of use  (WAS: Who makes more ...)
Message-Id: <334A1295.6833@kacweb.com>

Graham C. Hughes wrote:

> 
> I work just fine if you get out of my way.  Free software (and often
> small startups) understand this much better than IBM does.  It's this
> morale thing, y'know?  Good programmers program because it's fun, not
> because it's their job.  When you make it not fun, you kill the entire
> enterprise.
> - --
> Graham Hughes    http://A-abe.resnet.ucsb.edu/~graham/     MIME & PGP 

Man, do I hear that!

KAC
Website Design, Programming, Hosting --> http://www.kacweb.com
Now Available: Multi-Channel Server-Push Ticker ---^^^^^^^^^^^
kenny@kacweb.com


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

Date: Tue, 08 Apr 1997 10:35:11 GMT
From: Kuiper.Marcel@uniface.nl (Marcel Kuiper)
Subject: Win95 opendir()
Message-Id: <5id711$3f0@news.nl.compuware.com>

Hi there,

I've got a small problem with perl for Win32 build 304. When I try
opendir(DIR,"\\"); 
to open de root directory I got a message "no such file or directory"
This worked well with bigperl 4.36. I can workaround it by:
opendir(DIR,"\\SUBDIR\\..");
but it looks like a small bug to me.

Thanks for any help

Marcel
marcel_kuiper@nl.compuware.com



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

Date: Tue, 08 Apr 1997 10:25:04 GMT
From: webmaster@componentweb.com (nick^)
Subject: Working perl script... not running with HTTP get.
Message-Id: <334a1906.2362677@news.come.net.uk>

I have got a form to mail script working on my server. I cannot make
any scripts I have written work in the same way from an HTTP GET.
I have written a search script, which runs on my machine. I have had
problems making the script run on the web server. To debug the cause,
I have written a very simple script. It works when called from the
IRIX command line but I get a server misconfiguration error when I use
a submit button on a web browser form (Netscape/ MSIE). I have chmod
755 the script.

I expect "Hello World" to be displayed on the web browser when I do a
GET from a web browser form.

I get the "Server misconfiguration error..." message.

Here's the script:
#!/usr/bin/perl
# Program to do the obvious
#
print 'Hello world xxx.';           # Print a message

Parameters will be passed from the form to the URL to the environment
and these will be ignored, Right? 

Have i missed a basic requirement when using a perl script called with
an HTTP GET, or should it run as I expect?

Regards

Nick.


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

Date: 8 Apr 1997 11:40:22 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Working perl script... not running with HTTP get.
Message-Id: <5idar6$d4n@news-central.tiac.net>

In article <334a1906.2362677@news.come.net.uk>,
nick^ <webmaster@componentweb.com> wrote:

>I expect "Hello World" to be displayed on the web browser when I do a
>GET from a web browser form.
>
>I get the "Server misconfiguration error..." message.
>
>Here's the script:
>#!/usr/bin/perl
># Program to do the obvious
>#
>print 'Hello world xxx.';           # Print a message

You might try sending a minimal set of headers as it's hard for the web
server to know what type of content you're returning e.g.

#!/usr/bin/perl

print "Content-type: text/plain\n";
print "\n";				# end of header
print "Hello world xxx.\n";

might be more productive.  If you have access to your web logs you can
check for evidence of syntax errors (but perl -wc script is a way of doing
a basic syntax check from the command line...)

  http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html

Might also be of some use to you.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

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


Administrivia:

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 253
*************************************

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