[8516] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2133 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 19 08:07:28 1998

Date: Thu, 19 Mar 98 05:01:05 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 19 Mar 1998     Volume: 8 Number: 2133

Today's topics:
    Re: (Newbie to Perl) - can you improve my program? <rjk@coos.dartmouth.edu>
    Re: A Perl version of Crypt <hackware@worldnet.att.net>
        Assign lines of a text file into an array (C.S.M.Leung)
    Re: Assign lines of a text file into an array <ebohlman@netcom.com>
        back-tick/pipe print output in reverse order. (saar ginzburski)
    Re: back-tick/pipe print output in reverse order. (Jason Gloudon)
    Re: Bitwise? <lr@hpl.hp.com>
    Re: building for perl 5.004_04 on NT (Frank)
    Re: Challenge your programming skill (Abigail)
    Re: Challenge your programming skill (dk smith)
    Re: compiling perl <rra@stanford.edu>
    Re: Fastest way to grep through a file? (Frank D. Cringle)
    Re: file not found!? <rra@stanford.edu>
        Help with two scripts one is CGI. <jeffrey.nospam@jborg.ml.org>
    Re: HI!PERL/CGI Websites? <sbekman@iil.intel.com>
    Re: How to implement "timeouts" in perl? <paganini@paganini.net>
    Re: Perl on IIS <tony@cyberscape.net>
        Problem with dealing with serial ports using Perl for W <chhang@unixg.ubc.ca>
        Qui sera assez fort pour repondre a ca ?? (sorry) (ATOS)
        Rand Banner caien@usa.net
    Re: Reading POST data using PerlIIS <ebohlman@netcom.com>
    Re: Running CGI-Scripts on a webserver <indeco@orc.ru>
    Re: searching a file in Perl <ebohlman@netcom.com>
    Re: setuid and $0 <rra@stanford.edu>
        Trace rout with perl <petersongroup-nospam@home.com>
    Re: Wanted: email address gleaner <rra@stanford.edu>
        Where is Comm.pl (saar ginzburski)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 19 Mar 1998 02:14:13 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
To: Matthew Kennedy <q9522772@mail.connect.usq.edu.au>
Subject: Re: (Newbie to Perl) - can you improve my program?
Message-Id: <3510C5CB.1F83979B@coos.dartmouth.edu>

[posted and mailed]

Zenin already addressed many of the things in your script to fix.  So, that
leaves me with...

Matthew Kennedy wrote:
> 
> if ($#ARGV != 0) {
>     warn "Syntax: perl psfragx eps_file";
>     exit 1;

That can't be right...  I think you meant ($#ARGV != 1)

Add a newline; you don't need the line number in the error message.
warn "Syntax: perl psfragx eps_file\n";

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 19 Mar 1998 03:14:25 -0800
From: "Stephen Wood" <hackware@worldnet.att.net>
Subject: Re: A Perl version of Crypt
Message-Id: <6equcn$c70@bgtnsc03.worldnet.att.net>


Thanks for posting this.  The reason I actually need the code is that I'm
porting it to a different language, and to a non-Unix platform.

Thanks again.




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

Date: Thu, 19 Mar 98 10:50:22 GMT
From: csml1@ukc.ac.uk (C.S.M.Leung)
Subject: Assign lines of a text file into an array
Message-Id: <1445@gos.ukc.ac.uk>

Is it possible to assign each line of a text file into an associative array where
the key will be the line number and the value will be a string variable containing
the whole line?

Catherine


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

Date: Thu, 19 Mar 1998 11:59:25 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Assign lines of a text file into an array
Message-Id: <ebohlmanEq2En1.54q@netcom.com>

C.S.M.Leung <csml1@ukc.ac.uk> wrote:
: Is it possible to assign each line of a text file into an associative array where
: the key will be the line number and the value will be a string variable containing
: the whole line?

It's trivially easy once you remember that $. contains the line number 
from the most recently read filehandle.  Here's one of many ways to do it:

my %lines=map {$.,$_} <FILE>;

Now *why* you'd want to do that is another question entirely, given that 
you could just use the line number as the index to an ordinary array (and 
remember that Perl will automatically convert between strings and numbers 
as needed, so a number read in as a string can be used as an index).  Of 
course, using a hash (the preferred term for an associative array) would 
make sense if only some of the lines were supposed to be included, since 
ordinary arrays are wasteful for sparse data, whereas hashes are ideal 
for it.


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

Date: Wed, 18 Mar 1998 13:57:59 +0200
From: saarg@amdocs.com (saar ginzburski)
Subject: back-tick/pipe print output in reverse order.
Message-Id: <MPG.f79e3429b070b99989685@speedy>

Hi,

I'm trying to run these three simple programs:

******************************************************************
PROGRAM_1.pl
==============
$output = `./PROGRAM_2.pl`;
print $output;

PROGRAM_2.pl
==============
print "This is output from PROGRAM_2.pl\n";
system "./PROGRAM_3.pl";

PROGRAM_3.pl
==============
print "This is output from PROGRAM_3.pl\n";
*******************************************************************
The output from PROGRAM_1.pl is:

This is output from PROGRAM_3.pl
This is output from PROGRAM_2.pl

As you all can see, the order is reversed. when doing the same programs 
using pipe instead of back-tick the output is the same. when adding 
printing to STDERR, the order changed completly and looks like:

This is STDERR output from PROGRAM_2.pl
This is STDERR output from PROGRAM_3.pl
This is STDOUT output from PROGRAM_3.pl
This is STDOUT output from PROGRAM_2.pl


Anyone has any idea ?

-- 
Saar Ginzburski
Aurec Group Ltd.
Israel, saarg@amdocs.com


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

Date: Thu, 19 Mar 1998 12:53:33 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: back-tick/pipe print output in reverse order.
Message-Id: <slrn6h257t.if0.jgloudon@manitoba.bbn.com>

In article <MPG.f79e3429b070b99989685@speedy>, saar ginzburski wrote:
>As you all can see, the order is reversed. when doing the same programs 
>using pipe instead of back-tick the output is the same. when adding 
>printing to STDERR, the order changed completly and looks like:
>
>This is STDERR output from PROGRAM_2.pl
>This is STDERR output from PROGRAM_3.pl
>This is STDOUT output from PROGRAM_3.pl
>This is STDOUT output from PROGRAM_2.pl

This is a most likely a result of the output buffering of STDOUT by stdio. 
Use $|=1, before the system command, to get the output from your prints flushed.
STDERR is not buffered as STDOUT is, that's why the order of output changes.

Jason Gloudon


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

Date: Wed, 18 Mar 1998 23:32:44 -0800
From: Larry Rosler <lr@hpl.hp.com>
To: Jim Michael <genepool@netcom.com>
Subject: Re: Bitwise?
Message-Id: <3510CA1C.F5235C94@hpl.hp.com>

Jim Michael wrote:
> 
> rfonline@nbn.com wrote:
> : Greetings,
> 
> : I have a set of "items," which are represented by a series of 0s and
> : 1s.  For example, an item might look like this:
> 
> : 10011
> 
> : I am comparing the items to see how "alike" they are, that is, how
> : many characteristics they have in common.  For example:
> 
> : 10011
> : 00000
> 
> : The above two items have two characteristics in common (the second and
> : third).
> 
> Assuming you have mapped your bits into numbers in $A and $B,
> the check for high bit matches would be $A & $B, and the check
> for low bit matches would be ~$A & ~$B, so the check for all
> matches would be ($A & $B) | (~$A & ~$B).
> 
> $A: 1001
> $B: 0011
> 
> $A & $B: 0001
> 
> ~$A: 0110
> ~$B: 1100
> 
> ~$A & ~$B: 0100
> 
> ($A & $B) | (~$A & ~B) = 0001 | 0100 = 0101
> 
> HTH.
> 
> Cheers,
> 
> Jim

The following seems like a more direct approach:

~($A ^ $B)

The exclusive-or operator doesn't get used much,
but fits fine here.

Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: 19 Mar 1998 08:32:39 +0100
From: dont_use_this_ey@hotmail.com (Frank)
Subject: Re: building for perl 5.004_04 on NT
Message-Id: <yo9ra3zdtk8.fsf@nym.sc.philips.com>

tyde@medtrodnet.cdom (Tye McQueen) writes:
> Note a previous posting of mine (see http://www.dejanews.com)
> that included a Perl script to transform all of these into
> relative paths so that they will work even after you move the
> whole directory tree and will work if you put them on a real
> Web server or access them via a network share, etc.
Hello Tye!

I had problems locating the post of yours. Do you have the subject line
at hand? I think it is related to your ".cdom".

As far as I understand now my problem is coming from the used syntax
in the refs to describe local files. IE 3.0 does not understand it. I
do not thing, that it is a matter of absolute vs relative paths. My
solutions seems to be an other browser or a different syntax for local
files. 

Is there any reason not to use something like:
file://localhost/F|/dir1/dir/.../file.html 

But even more convenient would be something more ASCII as
documentation. I think I will concentrate on getting perldoc to work
properly. Perhaps later an interface from emacs to perldoc. Dreaming..

regards
	Frank

P.S. After having trouble with locating your post, I rethought my
faked email-address approach to avoid spam. I'm now using a different
email address, please don't be confused. 


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

Date: 19 Mar 1998 07:39:35 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Challenge your programming skill
Message-Id: <6eqi3n$ssg$1@client2.news.psi.net>

Kim Lo (kiml@zplace.com) wrote on MDCLXI September MCMXCIII in
<URL: news:3510AEA6.DF610245@zplace.com>:
++ Perl programmers,
++ I am facing with the challenge of writing a program to find the closest
++ customer name based on an input zipcode. I have the data file containing
++ zipcode, state, longitude and latitude in a database already.
++ My approach to this problem is very simple however I want to find out
++ from you programmers if this is the most efficient way to do it. Here're
++ the steps:
++ 1. Get the long and lat based on the input zipcode
++ 2. For each customer do
++       a. Get customer zipcode and determine long and lat
++       b. Delta long and lat from step1 and 2a. Get the absolute value
++       c. Convert the long and lat into an R value using pythagore
++ theorem (R^2=x^2+y^2)

Actually, that isn't quite correct, as the earth isn't a sphere.
The approximation would be fine in a state like Rhode Island, but
for something the size of the US, that's not right.

++ 3. Sort the R value and the smallest R will contain the closest customer
++ to the input zipcode.
++ 
++ The problem I am having with this algorithm is that it could take a long
++ time to compute as the number of customers grow. To minimize computing,
++ I thought of just getting customers from the same state as the input
++ zipcode and compute those only. The caveat to this approach is that for
++ someone that lives closeby 2 states (especially on the East Coast), this
++ may return incorrect result.

Your problem is a variant of the closest neighbour problem, one well
known in the literature. [1]

Woooha! For a moment I thought you had 2 sets, one of offices, and
one of customers, and you wanted to find the closes offices for
each customers. However, reading your article again, you just have
a list of customers, and one fixed point. And you want to find
the customer living closest to this point?

Uhm, any reason not to use the braindead trivial "for each customer,
compute the distance to the fixed point; remember the one with
minimum distance" algorithm? You will have to process all customers
anyway, so better than linear you can't do anyway.

Or perhaps your set of customers is fixed, and you pick a point
repeatedly, having the calculate the closest customer each time?
In that case, you can preprocess the set of customers. Build a 
Voronoi diagram from it. Now all you need to do is a point location
for your query point. Building the Voronoi diagram can be done
in O (N log N) time, finding the nearest neighbour for each query
point takes O (log N) time. [2]


[1] D. E. Knuth: "The Art of Computer Programming. Volume III: Sorting
    and Searching". Addison-Wesley: Reading MA, 1973.
[2] F. P. Preparata and M. I. Shamos: "Computational Geometry an
    Introduction". Springer-Verlag: Berlin. 1985.



Abigail
-- 
perl -we '$_ = "4a75737420616e6f74686572205065726c204861636b65720as";
          for (s;s;s;s;s;s;s;s;s;s;s;s)
              {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


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

Date: Thu, 19 Mar 1998 03:09:52 -0800
From: dks@mediaweb.com (dk smith)
Subject: Re: Challenge your programming skill
Message-Id: <dks-1903980309520001@tulini.mediaweb.com>

Note that if this program is to handle Canadian zip codes in the future,
then your complexity goes up dramatically, AFAIK. Does anyone know of any
documentation that explains the rationale behind the Canadian Postal Code
system? Oh, and that's another thing. Canadians get upset when you refer
to their codes as zip codes. :)

-dk

In article <3510AEA6.DF610245@zplace.com>, Kim Lo <kiml@zplace.com> wrote:

> Perl programmers,
> I am facing with the challenge of writing a program to find the closest
> customer name based on an input zipcode. I have the data file containing
> zipcode, state, longitude and latitude in a database already.
> My approach to this problem is very simple however I want to find out
> from you programmers if this is the most efficient way to do it. Here're
> the steps:
> 1. Get the long and lat based on the input zipcode
> 2. For each customer do
>       a. Get customer zipcode and determine long and lat
>       b. Delta long and lat from step1 and 2a. Get the absolute value
>       c. Convert the long and lat into an R value using pythagore
> theorem (R^2=x^2+y^2)
> 3. Sort the R value and the smallest R will contain the closest customer
> to the input zipcode.
> 
> The problem I am having with this algorithm is that it could take a long
> time to compute as the number of customers grow. To minimize computing,
> I thought of just getting customers from the same state as the input
> zipcode and compute those only. The caveat to this approach is that for
> someone that lives closeby 2 states (especially on the East Coast), this
> may return incorrect result.
> Any feedback is welcome.

-- 
DK Smith                                  MediaWeb, Inc.
dks@mediaweb.com                          Mountain View, CA, USA
======================================>>> http://www.mediaweb.com
Quality Web Hosting, Excellent Rates                 


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

Date: 18 Mar 1998 23:38:32 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: compiling perl
Message-Id: <m3afanjfk7.fsf@windlord.Stanford.EDU>

Anthony Boyd <anthony@outshine.com> writes:

> Why is the Perl 5.005 release waiting for the promised compiler
> (supposed to be out in November 1997) if it doesn't have benefits?  Or
> are there indeed benefits that just haven't been mentioned?

Perl 5.005 is mostly waiting for completion of work on threads, not just
on the compiler.  And the compiler *does* help in one particularly place,
namely faster loading of modules.  A lot of us are hoping that will solve
this problem:

windlord:~> time perl -e 1
0.02u 0.07s 0:00.05 180.0%
windlord:~> time perl -MNews::Gateway -e 1
1.22u 0.42s 0:01.64 100.0%

-- 
#!/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: Thu, 19 Mar 1998 11:29:26 GMT
From: fdc@cliwe.ping.de (Frank D. Cringle)
Subject: Re: Fastest way to grep through a file?
Message-Id: <vtpvjiapgp.fsf@cliwe.ping.de>

bet@network.rahul.net (Bennett Todd) writes:
> For something as small as 20K, I'd guess the fastest approach would be a file
> suck --- sluurp the whole thing in as a single string, without parsing it into
> lines.

Here are two more benchmark cases using read() and sysread().  They
both handle arbitrarily large files and are faster than suck using <>.
The sysread() method is almost as fast as an external grep for the
"16x termcap" test on my system.  However, sysread is more fragile:
the handling of trailing line fragments needs to be tailored to the
particular search and I have not included code to handle interrupted
system calls.

    'read' => sub {
	seek FP,0,0;
	my($count) = 0;
	my $data;
	while (read(FP, $data, 32000)) {
	    my $tail = <FP>;
	    $data .= $tail if defined $tail;
	    $count++ while $data =~ /terminal[^\n]*\n/gs;
	}
	print "read: $count\n" if $opt_d;
    },

    'sysread' => sub {
       seek FP,0,0;
       my($count) = 0;
       my $data = '';
       while (sysread(FP, $data, 32000, length($data))) {
	   $count++ while $data =~ /terminal[^\n]*\n/gs;
	   $data =~ s/.*\n//s;
       }
       print "sysread: $count\n" if $opt_d;
   }

  });

-- 
Frank Cringle,      fdc@cliwe.ping.de
voice: (+49 2304) 467101; fax: 943357


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

Date: 18 Mar 1998 23:43:54 -0800
From: Russ Allbery <rra@stanford.edu>
To: Geert Roovers <etmgero@etm.ericsson.se>
Subject: Re: file not found!?
Message-Id: <m34t0vjfb9.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

Geert Roovers <etmgero@etm.ericsson.se> writes:

> So my question is, if I have this line first:

> #!/opt/LWperl/bin/perl

> but the perl binary is not in that directory on my webserver (that's
> what my sysadmin thinks), would it give a "file not found" error on the
> script!?

Yes.

-- 
#!/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: Thu, 19 Mar 1998 20:04:31 +1000
From: "Jeffrey Borg" <jeffrey.nospam@jborg.ml.org>
Subject: Help with two scripts one is CGI.
Message-Id: <6eqr1p$oab$1@nswpull.telstra.net>

Hello there
(if you reply to this please send me an E-Mail as I may not check back for a
while)

OK this is for a school.
Needed for stopping and starting general access to the www using a linux
computer.
Now I have figured out what commands have to be run as root to achieve this.

Now every computer has it's own fake IP address and the linux computer has
reverse lookup working on all the IP's with machinename.domain.edu or
whatever SO a direct translation is pretty easy.
Don't worry about authentication as I will fix this up,

It need to run a command as root to stop and start access because it changes
firewalling rules. This command can just use the hostname and don't even
need a IP address. So I guess that there is no need for this translation in
this.

It needs to do
A) CGI script to generate a form for a particular computer lab
B) this page will have a Change all option or something similar. And it will
display the current status of the computers as well.
Bit Like this
COMPUTER NAME | Status | No change | Off | On | Time limit
foo | off | X | x | x | [   ]
the X is a radio button checked
the x is a radio button not checked
the  [  ] is a box to insert a time like for the next 10 minutes it would be
a 10

C) CGI script that from the form is posted to with the changes (or no change
as on that form above)
This script writes to some file and leaves it there

D) root script read's changes file (somehow) and executes the changes on or
off for whatever computers need to be changed Then changes the current
status file for the CGI script in A) to read from.

Then the user will be able to go to whatever
if not you basically get this

(it's a perl script that dumps out a page in html or any URL! as a proxy
format)

Access denied
to http://www.whatever.url.you.typed.in.com/or/whatever/
Please ask for access COMPUTERNAME.DOMAIN.EDU

OR BACK TO THE HOMEPAGE


That's about it

all it does as the proxy is on port 8080
just redirects when off to port 9000 -> User get's page all the time when
they try to access URL outside

and removes that rule when it's OK to work again.

Yes I know that reload proxy access controls is too fiddly and SLOW!

Also a little SSI for saying two things
A) Machine name (easy part)
B) access is currently ON or OFF and time remaining.

Thanks

Jeffrey Borg
jeffrey@jborg.ml.org

Just remember if you reply to the newsgroup Please Send me an E-Mail as
well. Thanks
otherwise I may loose what you said.




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

Date: Thu, 19 Mar 1998 10:21:20 +0200
From: Bekman Stanislav <sbekman@iil.intel.com>
Subject: Re: HI!PERL/CGI Websites?
Message-Id: <3510D580.3CFA@iil.intel.com>

> >Does anybody know how to solve this?
> >I have an html online form. What should be the script to
> >save my incoming data, in simple perl(cgi) format code?
> >Does anybody know a good website for beginnners at perl/cgi.
> >please suggest, your reply requested at :
> 
> the CGI Meta FAQ has references to both general CGI documentation
> language specific documentation, including Perl references.
 
Browse http://www.eprotect.com/stas/TULARC for the cgi/perl links as
well

Brian, nice to see you back!

______________________________________________________________________
Stas Bekman     mailto:sbekman@iil.intel.com [just another webmaster]
Home Page:      http://www.eprotect.com/stas
A must visit: 	http://www.eprotect.com/stas/TULARC (Java,CGI,PC,Linux)
Linux-il Home:  http://www.linux.org.il/		    
    
Linux receives a 'Product of the Year Award' for Best Technical Support
http://www.infoworld.com/cgi-bin/displayTC.pl?97poy.supp.htm


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

Date: Thu, 19 Mar 1998 06:31:15 -0600
From: Marco Paganini <paganini@paganini.net>
To: jay@rgrs.com
Subject: Re: How to implement "timeouts" in perl?
Message-Id: <6er32r$470$1@nnrp1.dejanews.com>

Hello Jay!

> Both IO::Socket::INET and Net::Telnet allow you to connect with a
> timeout.  However, both use alarm() within an eval to timeout the
> connect.

Yes, the timeout problem on the connect() call was solved using
IO::Socket::INET. It works fine.

> I've never heard of anyone having a "non-reentrant" problem as you
> describe.  I'd think you could only have a problem of that nature
> using threads?

Signal processing is very tricky. Doing things inside subroutines
that catch signals is problematic, since (as I said), many parts
of the kernel (and perl itself?) are non-reentrant. So, even
a malloc (used by many perl commands, for sure) could cause
problems. This is documented in the perlipc man page and
(believe me) it really happens. :)

When your singal handler is called, you can do nothing (safely),
except set a variable. Even calling a "print" could cause a
syssegv (in theory).

> Additionally, Net::Telnet has the capability to timeout on read or
> write.  Here's how to do your first question:
>
>     $pid = open PH, "$program |"
> 	or die $!;
>
>     ## Create $ph and associate it with PH
>     use Net::Telnet ();
>     $ph = Net::Telnet->new(Fhopen  => \*PH,
> 			   Timeout => 10);
>     $ph->errmode("return");
>
>     ## Look for not hung indicator from program, time-out if too long.
>     while (! $ph->eof) {
> 	$ph->waitfor('/string indicating not hung/');
> 	if ($ph->timed_out) {
> 	    warn "program not responding: $program\n";
> 	    kill 1, $pid;
> 	    last;
> 	}
>     }
>
>     close PH;

Yes, this will probably work. It's a strange solution (to a strange
problem), but it's a very clever one.

Thanks a lot for your help
Paga

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 19 Mar 1998 12:45:05 GMT
From: "Tony Kenny" <tony@cyberscape.net>
Subject: Re: Perl on IIS
Message-Id: <01bd5333$175006c0$0300a8c0@ADMIN.FURNESS>

Hi, this is a problem I have encountered many times on Win NT.

This is a fix that hasnt failed for me yet, You need to edit your registry
manually with regedit.

This is wht to add and where. :)

HKEY_LOCAL_MACHINE
\System
  \CurrentControlSet
    \Services
      \W3SVC
        \Parameters
          \ScriptMap

Add a value: (data type REG_SZ)

in the string editor type      full path\perl.exe %s

if this odesnt work try     full path\perl %s %1

This should map perl.exe to the .pl extension for cgi scripts.

Your scripts should now work instead of being displayed in the browser.

Looking at your problem, have you put 

$|=1;
print "Content-type: text.html\n\n"; 

at the top of your script? :) (Sound obvious but worth a check)

~TK


Ieong Sze Chung Ricci <ricci@cs.ust.hk> wrote in article
<6enn12$s4f@ustsu10.ust.hk>...
> 
> Hello All,
> 
> 	I would like to place the Perl Script CGI code to the Microsoft
> IIS 3.0. I have already created the cgi-bin directory and installed the
> Perl 5.003 interpreter. In fact, I have also tested the Perl script
> directly on the command line. However, I can't have the Perl script run.
> 
> 	Is there any one out there have tackel that problem? Can any one
> tell me the clue to this problem?
> 
> 	I have already associate the .pl file to Perlscript and run the
> Perl script with the Perl.exe. Everything should be OK! But when I call
> the script by Action=http://domain/cgi-bin/test.pl, the web pages keep
> connecting for a long time and then time out. if I use the CGI2shell.exe
> (converted to test.exe), then the program gives a message:
> 
> CGI Error
> 
> The specified CGI application misbehaved by not returning a complete set
> of HTTP headers. The headers it did return are:
> 
> 	I would like to use Perl Script on MS IIS. Can any one please tell
> me possible solution.
> 
> 	Thanks.
> 
> Ricci Ieong
> 


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

Date: Wed, 18 Mar 1998 23:32:25 -0800
From: "AC" <chhang@unixg.ubc.ca>
Subject: Problem with dealing with serial ports using Perl for Win32
Message-Id: <C0Hj4iwU9GA.70@news1.aebc.com>

Hi everyone:

I'm encountering the following problem and I hope some folks can help me
out.

open(PORT, "COM3") || die "Can't open COM3 for read: $!";   #open COM for
reading

while (defined ($line = <PORT>) {     #read from COM3
     chomp($line);
     print "line is ($line)";
}

The serial port is supposed to have continuous data sending to the PC, but
the above code is not able to read and print the content. What's the
alternative way to do reading from serial port? Please help.







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

Date: Thu, 19 Mar 1998 10:45:25 +0100
From: cfockeu@atos-group.com (ATOS)
Subject: Qui sera assez fort pour repondre a ca ?? (sorry)
Message-Id: <MPG.f7b0764cf4baee4989685@news.axime.com>

Hello Ladies and Gentleman,

I would like to apologize to this group.
My question was written in english and some of you
didn't appreciate.
I'm explain to you :
I former wrote my question under the subject : 
"Finding a key thanks to a value in a hash"

but I didn't receive any "good" answer (perhaps 
because was badly written) so I wanted to post 
it in a French Group in FRENCH
(fr.comp.lang.perl) but I posted in (comp.lang.perl...)

Errare humanum est :))

Mea culpa
Cedric

PS : Dispite of the language used (french, english) the
     question seems to be good. Isnt'it Mr Tom Christiansen ? :)



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

Date: Thu, 19 Mar 1998 02:39:58 -0600
From: caien@usa.net
Subject: Rand Banner
Message-Id: <6eqlgr$68v$1@nnrp1.dejanews.com>

Hi People!

This is my first message in this board.

I am from Brasil and my english is very bad..

i think that you can understand me. :)

ok. i make a script that returns a banner and your URL by random.

in HTML, you need to have a JavaScript that will return a random
number. Ex: 1<=$number<=9

ok.
in HTML, you will need to write on part of you wnat to see the banner:

<script>
document.write("<a href='/cgi-bin/banner?url="+$number+"'><img src='/cgi-bin/
                banner?img="+$number+"' alt='Random Banner'></a>")
<script>

then, when the script receive the post, it check what string there are,
in the case, only IMG, then, the script will return

Location: http://url_of_the_image

but if you like the image and click on it, the script
will receive how string, only URL, then the script return

Location: http://url_link_of_the_image

then, you only need to say to script, the number, the image and the link.

ex:
if $number=3 then $url=3 and $img=3.
if $img=3, return image http://www.image.com/image03.jpg

if $url=3, return to location of top.window the
            url http://www.url.com/link03.htm

what you think about this!?

then, you can in perl script, to write others functions how to count
number of some number was called, etc...

hehehe how many good is my english!? :)

i dont use very much this board.
if some one would like to return this message, return it to my mail.
i thanx.

Savio Samp.
caien@usa.net

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 19 Mar 1998 09:03:46 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Reading POST data using PerlIIS
Message-Id: <ebohlmanEq26IA.MM8@netcom.com>

Jeff Hitchcock <dontspamme-jeffh@castleweb-nospam-.com> wrote:
: It must be late and I must be short on caffeine. I am unable to figure
: out how to read POST data using PerlIIS. Here's my code snippet:

: read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
: print $buffer;

: When run as a standard Perl script, it works fine. Here's the output:

: name=Name&email=Email&comments=Blah+Blah

: When run under PerlIIS, I get nothing, even though printing
: $ENV{'CONTENT_LENGTH'} shows a non-zero value.

: How do I read form data submitted using POST?

You use CGI.pm, which means you no longer have to worry about how the 
data was submitted.







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

Date: Thu, 19 Mar 1998 12:56:41 +0300
From: "Andrew J. Alexandrov" <indeco@orc.ru>
Subject: Re: Running CGI-Scripts on a webserver
Message-Id: <6eqoms$sra$1@boss.nc.ras.ru>

Hi !
What kind of webserver simulation tool do you use on your PC ?




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

Date: Thu, 19 Mar 1998 08:36:47 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: searching a file in Perl
Message-Id: <ebohlmanEq259B.Ln8@netcom.com>

tony <td@lavalink.com.au> wrote:
: I was wondering how would it be done if you wanted to search two or more
: files at the same time? ie: filename1 filename2 ...

See the section in perlop.pod on the "null filehandle" AKA the "diamond 
operator."



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

Date: 18 Mar 1998 23:48:16 -0800
From: Russ Allbery <rra@stanford.edu>
To: "Kuntal M. Daftary" <daftary@cisco.com>
Subject: Re: setuid and $0
Message-Id: <m3zpini0jj.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

Kuntal M Daftary <daftary@cisco.com> writes:

> i use the following construct to get the name of the script file in most
> of my perl scripts:

> ($self = $0) =~ s:.*/::;

Note that this gives you whatever the program running your script claimed
it was called.  That's it.  There's nothing special about that argument;
it can be set to anything the calling program cares to call it.

> recently i had to make a script setuid. and i realized that for setuid
> scripts $0 is no longer the name of the script file. in my case it
> became /dev/fd/4.  or something like that.

Yup.

> also, for specifically this script, i really need to get the name of the
> script file because i not only use it to set the $self but also stat the
> script to find out group and user ownerships and perform certain
> authorization checks.

I'm afraid there's no way to do this.  You're going to have to find a
different way of solving your problem.  There is no secure way of
obtaining from the operating system the exact path to the script that's
currently running.

-- 
#!/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: Thu, 19 Mar 1998 00:46:41 -0800
From: "Dan Peterson" <petersongroup-nospam@home.com>
Subject: Trace rout with perl
Message-Id: <6eqm1q$bgq$1@ha2.rdc1.sfba.home.com>

I would like to do a tracrt after a ping fails. (I got the ping working !)

Does anybody know of a perl module that will do this?
I would prefer not to do a system call.

I dont understand tracert (or perl) well enough to write one my self.
the system is:
NT 4.0
perl 5.??? (I gave up trying to keep up)

You can e-mail (remove the nospam) me or post it here. I dont know if I will
be able to find it if you post it here.
drpeterson-nospam@lbl.gov

-Dan




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

Date: 18 Mar 1998 23:40:14 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Wanted: email address gleaner
Message-Id: <m37m5rjfhc.fsf@windlord.Stanford.EDU>

Randal Schwartz <merlyn@stonehenge.com> writes:

> No it's not.  You aren't contributing to the topic.  You're raping the
> net.  And on top of that, you're gonna fill *my* email box with a
> question about permission to rape the net.

Oh, come *on*.  I've gotten e-mailed requests from people before wanting
to use things that I've written in books.  In every case, I've appreciated
the notification whether I gave permission or not.  It's a lot better than
having my work used without permission.

I believe one of those organizations to mail me in that fashion was
O'Reilly.

-- 
#!/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: Thu, 19 Mar 1998 11:18:41 +0200
From: saarg@amdocs.com (saar ginzburski)
Subject: Where is Comm.pl
Message-Id: <MPG.f7b0f692a86e57989687@speedy>

Hi all,
I'm trying to download the Comm.pl module for about three days but I'm 
not able to. It's looks like the file disappear from all CPAN sites.

Does anyone has any idea ?

If not, maybe you'll be able to find another way to solve that misty 
situation:

I'm trying to run these three simple programs:

******************************************************************
PROGRAM_1.pl
==============
$output = `./PROGRAM_2.pl`;
print $output;

PROGRAM_2.pl
==============
print "This is output from PROGRAM_2.pl\n";
system "./PROGRAM_3.pl";

PROGRAM_3.pl
==============
print "This is output from PROGRAM_3.pl\n";
*******************************************************************
The output from PROGRAM_1.pl is:

This is output from PROGRAM_3.pl
This is output from PROGRAM_2.pl

As you all can see, the order is reversed. when doing the same programs 
using pipe instead of back-tick the output is the same. when adding 
printing to STDERR, the order changed completly and looks like:

This is STDERR output from PROGRAM_2.pl
This is STDERR output from PROGRAM_3.pl
This is STDOUT output from PROGRAM_3.pl
This is STDOUT output from PROGRAM_2.pl

Any help will be appreciated !!!
-- 
Saar Ginzburski
Aurec Group Ltd.
Israel, saarg@amdocs.com


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

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

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