[7747] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1372 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 27 08:07:57 1997

Date: Thu, 27 Nov 97 05:01:04 -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, 27 Nov 1997     Volume: 8 Number: 1372

Today's topics:
     Re: ?: in lhs <youngej@magpage.com>
     Re: ?: in lhs (Charles DeRykus)
     Re: Aigh!  Win95 Perl Sockets? (Michael Ng)
     Re: ASN.1 format to Perl? <rpsavage@ozemail.com.au>
     Date and time in ISO 8601 format <jacklam@math.uio.no>
     DG/UX perl5.004_4 compile problem <sherlock.holmes@worldnet.att.net>
     Re: How can I hide the Query string in the URL? (E.None Archibald)
     How do I run script as ROOT? <clivem@hixnet.co.za>
     Re: How do I run script as ROOT? (Jeremy D. Zawodny)
     Re: How to directly call a POST method (Faust Gertz)
     Re: How To Test if number is ODD or EVEN? <dboorstein@ixl.com>
     HOWTO: DBD:Sybase running on Linux <pjacob@brodeur.com>
     IS THERE A DB INTERFACE INTO MS SQL SERVER? <csa@netcom.com>
     Re: IS THERE A DB INTERFACE INTO MS SQL SERVER? (Jeremy D. Zawodny)
     Re: launch a child process in a cgi <westxga@ptsc.slg.eds.com>
     Re: launch a child process in a cgi <davidson@zk3.dec.com>
     Re: newbie question <rootbeer@teleport.com>
     None ("Cho, Kwangje")
     None ("Cho, Kwangje")
     Re: Open file works under DOS, not under server <esociety@vademecum.be>
     pattern substituition operation question <jlee@mdsi.bc.ca>
     Re: perl bad for backgroud job? <maevans@io.com>
     Re: PERL Hourly Rates twod@not.valid
     Re: PERL Hourly Rates (brian d foy)
     Re: PERL Hourly Rates <sherlock.holmes@worldnet.att.net>
     Re: PERL Hourly Rates <merlyn@stonehenge.com>
     Re: perl script for generating simple web page <doug1@net-link.net>
     Re: perl script for generating simple web page <rootbeer@teleport.com>
     Re: Perl5 Devel tools (ala cscope and cflow)?? (Scott Anthony Hamilton)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 25 Nov 1997 23:24:17 GMT
From: Ed Young <youngej@magpage.com>
Subject: Re: ?: in lhs
Message-Id: <65fmn1$l0n$0@204.179.92.145>

Dirk Vleugels wrote:
> 
> Hi,
> 
> i wonder why the following will not work:
> 
> while (<>) {
>         push(/^!/ ? @reject : @accept,$_);
> }
> 
> fails with:
> 
> po (vleugels):~/src/perl > cat t | ./foo.pl
> Type of arg 1 to push must be array (not null operation) at
> ./foo.pl line 4, near "$_)"
> Execution of ./foo.pl aborted due to compilation errors.
> 
> Perlop says:
> 
>      The operator may be assigned to if both the 2nd and 3rd
>      arguments are legal lvalues (meaning that you can assign to
>      them):

I have no idea why this failed, it did for me also, 
but I have the workaround:

@data = qw( yes !no !nyet si ja !nien);
foreach (@data)
{
  push @{/^!/ ? 'reject' : 'accept'}, $_;
}
foreach (@accept)
{
  print "accept: $_\n";
}
foreach (@reject)
{
  print "reject: $_\n";
}


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

Date: Tue, 25 Nov 1997 21:16:14 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: ?: in lhs
Message-Id: <EK80F3.Lzt@bcstec.ca.boeing.com>

In article <880472768.186641@firewall.do.isst.fhg.de>,
Dirk Vleugels <vleugels@do.isst.fhg.de> wrote:
 > Hi,
 > 
 > i wonder why the following will not work:
 > 
 > while (<>) {
 >         push(/^!/ ? @reject : @accept,$_);
 > }
 > 
 > fails with:
 > 
 > po (vleugels):~/src/perl > cat t | ./foo.pl
 > Type of arg 1 to push must be array (not null operation) at ./foo.pl line 4,
 > near "$_)"
 > Execution of ./foo.pl aborted due to compilation errors.
 > 
 > 
 > Perlop says:
 > 
 >      The operator may be assigned to if both the 2nd and 3rd
 >      arguments are legal lvalues (meaning that you can assign to
 >      them):
 > 
 > 

push seems to be really picky about lexing something 
that looks like an array very early. (Maybe someone 
can offer a much better explanation ...)    


At any rate, this works and is a bit more readable:

 /^!/ ? push @reject,$_ : push @accect,$_ ;



Or, more, obfuscatedly,


  push @{/^!/ ? \@reject : \@accept}, $_ ;



HTH,
--
Charles DeRykus


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

Date: 25 Nov 1997 18:55:18 GMT
From: syng@jalisco.engr.ucdavis.edu (Michael Ng)
Subject: Re: Aigh!  Win95 Perl Sockets?
Message-Id: <65f6um$5pn$1@mark.ucdavis.edu>

Pretty weired.  At least socket works on my Win95.  I forgot which ver of 
Perl - win32 I used for testing, however.  I tried the one with some 
socket demo (w/o fork) in example directory.

Dan Kaminsky (effugas@best.com) 
wrote:
::> Hi!  I'm trying to get Windows 95 to use Perl to access sockets...I tell ya,
::> no luck.  Doesn't matter if I use Activestate or Standard, it's just "can't
::> find sys/socket.ph".  Doesn't care what script I use, I've tried about
::> eight.  IO:Socket seems to work, but pritning to its file handle seems to do
::> nothing.  What gives?




--
Michael (syng@engr.ucdavis.edu)
+--------------------------------------------------------------+
| http://www.engr.ucdavis.edu/~syng/                           |
| <PGP public key: http://www.engr.ucdavis.edu/~syng/mike.pgp> |
+--------------------------------------------------------------+


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

Date: Wed, 26 Nov 1997 09:06:19 +1000
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: ASN.1 format to Perl?
Message-Id: <347B59EB.2C89@ozemail.com.au>

Al Wang wrote:
> 
> Hi,
> 
> I'm looking to import data encoded in ASN.1 to a local relational[snip]

I have tried this. Warning: The code only works up until it has to recurse.
Feel free to fix it and re-post it :-)

#!/usr/gnu/bin/perl -w
#
# Name:
#   ASN1.pl.
#
# Purpose:
#	Decode a stream of bytes in ASN.1 format.
#
# Input:
#	The name of the file to decode. This file must have been
#		encoded in ASN.1. Default: stdin.
#
# Output:
#	The parsed, formatted output. Default: stdout.
#
# Options:
#
# Version:
#	1.00	Ron Savage	rpsavage@ozemail.com.au.
#
#-------------------------------------------------------------------
#
# Purpose of decodeASN1() function:
#
# Globals referenced:
#	%class
#	%tag
#	$indentLevel
#	$indentString
#
# Return type:
#	None
#
# Return value:
#	None
#
sub decodeASN1
{
	my($buf) = @_;

	my(@buf)								= ( () );
	my($index, $class, $constructed, $tag)	= (0, 0, 0, 0);
	my($length, $lengthLength, $dataEnd)	= (0, 0, 0);
	my($indefiniteLength, $i, $j)			= (0, 0, 0);

	@buf = unpack("C*", $buf);

#	print sprintf("Start: 0x%02X 0x%02X 0x%02X 0x%02X \n",
#			$buf[0], $buf[1], $buf[2], $buf[3]);

# Look for:
#	END OF CONTENTS.

	if ($buf[$index] == 0)
	{
		print "-- ANY -- \n";
		return (0);
	}

	print $indentString x $indentLevel;

# Determine characteristics of field.

	$class			= $buf[$index] & 0xC0;
	$constructed	= $buf[$index] & 0x20;
	$tag			= $buf[$index] & 0x1F;
	$index++;

	print "Class: $class. Constructed: $constructed. Tag: $tag. \n";

	if ($tag == 31)
	{
		$tag = 0;

		while ($buf[$index] & 0x80)
		{
			$tag = ($tag << 7) + ($buf[$index] & 0x7F);
			$index++;
		}

		$tag = ($tag << 7) + $buf[$index];
		$index++;	
	}

# Determine length of field.

	$length = $buf[$index];
	$index++;

	if ($length & 0x80)
	{
		$lengthLength		= $length & 0x7F;
		$indefiniteLength	= 1 if ($lengthLength == 0);

		if ($lengthLength > 4)
		{
			print "Length field too long: $lengthLength bytes. \n";
			return (0);
		}

		$length = 0;

		for ($i = 0; $i < $lengthLength; $i++)
		{
			$length = ($length << 8) + $buf[$index];
			$index++;
		}
	}

# Print results so far.

	print "$class{$class}" if (defined($class{$class}) );
	print "[$tag]";
	print "$tag{$tag}" if (defined($tag{$tag}) );
	print " CONSTRUCTED" if ($constructed);

	if ($indefiniteLength)
	{
		print "      (INDEFINITE LENGTH)";
	}
	else
	{
		print "     (LENGTH $length)";
	}

	print "\n";

# Print the contents.

	$dataEnd = $index + $length;

	if (! $constructed)
	{
		$indentLevel++;

		for ($i = 0; $i < $length; $i++)
		{
			if (! ($i % 16) )
			{
				print "\n" if ($i);
				print $indentString x $indentLevel;
			}

			if ( ($buf[$index] < 0x20) || ($buf[$index] > 0x7E) )
			{
				print sprintf("%02x ", $buf[$index]);
			}
			else
			{
				print sprintf(" %c ", $buf[$index]);
			}

			$index++;
		}

		print "\n";
		$indentLevel--;
print "1. indentLevel: $indentLevel. \n";

		return ($dataEnd);
	}

	$indentLevel++;

	while ( ($index < $dataEnd) || $indefiniteLength)
	{
		if ( (! $buf[$index]) && $indefiniteLength)
		{
			$index++;
			print sprintf("Invalid EOC byte 0x%x\n",
				$buf[$index - 1]) if ($buf[$index]);
			$index++;
			print $indentString x $indentLevel;
			print "END OF CONTENTS\n";
			$dataEnd = $index;
			last;
		}

# Recurse.

		$index = &decodeASN1(substr($buf, $index) );

		if ($index == 0)
		{
			return (0);
		}

		substr($buf, 0, ($index - 1) )	= '';
		$index							= 0;
	}

	$indentLevel--;
print "2. indentLevel: $indentLevel. \n";

	if ($index != $dataEnd)
	{
		print sprintf("Internal error. data=%lx dataEnd=%lx\n",
			$index, $dataEnd);
		return (0);
	}

	return ($dataEnd);

}   	# End of decodeASN1.

#-------------------------------------------------------------------

sub process1File
{
	my($buffer) = ('');

	open(INX, $fileName) || die "Unable to open: $fileName\n";
	binmode(INX);
	read(INX, $buffer, -s INX);
	close(INX);
	&decodeASN1($buffer);

}   	# End of process1File.

#-------------------------------------------------------------------

sub init1File
{

}   	# End of init1File.

#-------------------------------------------------------------------

# Initialize.

unshift(@INC, $ENV{'PERL_HOME'});
require 'lib.pl';

@ARGV = ('-') if ($#ARGV < 0);

$class{0x00}	= 'UNIV';
$class{0x40}	= 'APPL';
$class{0x80}	= 'CTXT';
$class{0xC0}	= 'PRIV';

$tag{1}			= ' BOOLEAN';
$tag{2}			= ' INTEGER';
$tag{3}			= ' BITSTRING';
$tag{4}			= ' OCTETSTRING';
$tag{5}			= ' NULL';
$tag{6}			= ' OBJECT IDENTIFIER';
$tag{7}			= ' OBJECT DESCRIPTOR';
$tag{8}			= ' EXTERNAL';
# 9 .. 15?
$tag{16}		= ' SEQUENCE/SEQUENCE OF';
$tag{17}		= ' SET/SET OF';
$tag{18}		= ' CHARACTER SET STRING';
$tag{19}		= ' CHARACTER SET STRING';
$tag{20}		= ' T61 (TELETEX) STRING';
$tag{21}		= ' CHARACTER SET STRING';
$tag{22}		= ' CHARACTER SET STRING';
$tag{23}		= ' UTC TIME';
$tag{24}		= ' GENERALIZED TIME';
$tag{25}		= ' CHARACTER SET STRING';
$tag{26}		= ' CHARACTER SET STRING';
$tag{27}		= ' CHARACTER SET STRING';

$indentLevel	= 0;
$indentString	= '.  ';

for $fileName (@ARGV)
{
	&init1File();
	&process1File();
}

exit(0);

-- 
Cheers,
Ron Savage
Office: savage.ron.rs@bhp.com.au
Home (preferred): rpsavage@ozemail.com.au


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

Date: Tue, 25 Nov 1997 20:49:17 +0100
From: Peter John Acklam <jacklam@math.uio.no>
Subject: Date and time in ISO 8601 format
Message-Id: <347B2BBD.43B2@math.uio.no>

(This may be a FAQ, but I have not found an answer.)

Is there a module or script that returns the current date and time in
ISO 8601 format? I am thinking of the "long" version, like

   1997-11-23 14:38:42 +01:00

Is there a Perl program that does this?

I have made one, but I think it is a bit "messy" and I would guess that
is is possible to do it more elegantly. Here is my program:

# Date, time and time relative to UTC in ISO 8601 long format.
sub isodatetime {

    @lt = localtime;    # Local time.
    @gt = gmtime;       # Greenwich Mean Time (GMT).

    # Find difference between local time and GMT.
    $min = ( time - timelocal(@gt) )/60;
    $hrs = int( $min/60 );
    $min = abs( $min - 60*$hrs );
    $gmtdiff = sprintf( "%+0.2d:%0.2d", $hrs, $min );

    $lt[5] += 1900;     # Adjust year value.
    $lt[4] += 1;        # Adjust month value.

    $isodate = sprintf( "%d-%0.2d-%0.2d",    @lt[5,4,3] );
    $isotime = sprintf( "%0.2d:%0.2d:%0.2d", @lt[2,1,0] );

    @out = ( $isodate, $isotime, $gmtdiff );
    return wantarray ? @out : join( " ", @out );

}

Anyone with anything better?

Peter


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

Date: Tue, 25 Nov 1997 17:35:59 -0500
From: "Alan Fahrner" <sherlock.holmes@worldnet.att.net>
Subject: DG/UX perl5.004_4 compile problem
Message-Id: <65fjth$c25@mtinsc03.worldnet.att.net>

Hi Folks...

I was putting of compiling up perl 5.004, but another problem with 5.003 has
made me want to get the "upgrade."

I'm trying to compile it on a DG/UX system, R4.11MU03.  Compilation of 5.003
was no problem, and compilation of 5.004 appears the same.

However, when I do a "make test" afterward it gives me errors like this
every time it tries to load a library dynmically:

lib/filecopy......Can't load '../lib/auto/IO/IO.so' for module IO: dynamic
linker: ./perl: relocation error: symbol not found: Perl_markstack_ptr at
 ../lib/DynaLoader.pm line 166.
 at ../lib/IO/Handle.pm line 248

Anyone seen this and figured out the solution?  I used the defaults given by
the Configure script -- which, up to now, has been perfect.

Thanks ahead of time!

Alan




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

Date: 25 Nov 1997 19:29:37 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: How can I hide the Query string in the URL?
Message-Id: <65f8v1$36r$2@tepe.tezcat.com>

Tina Marie Holmboe <tina@scandinaviaonline.se> wrote:
: In article <7qvb56.or.ln@localhost>,
: 	tadmc@flash.net (Tad McClellan) writes:

: > This would be a Natural Language Processing application. Those are
: > non-trivial to implement. That's probably why someone hasn't already
: > done it  ;-)

:   Well - someone *has* done it; but perhaps not in the fashion you meant :)
: There are atleast one, probably more, such applications available as
: frontends to SQL.

There is one, currently open for testing, at:

www.electricmonk.com

it is, however, very much in testing mode - but it's DAMN COOL anyhow.

i'm an addict, that for sure.

--eugene
  "ask the monk!"


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

Date: 26 Nov 97 06:14:02 GMT
From: "Clive McAdam" <clivem@hixnet.co.za>
Subject: How do I run script as ROOT?
Message-Id: <01bcf9e0$073f22e0$bfda22c4@clive>

I have a perl script that allows users to create directories and files.

My problem is that the script is owned by root and the webserver is set
up as nobody (not even a user on the system, don't want to set it up as
root)
 so when each user comes in and creates his directory, the owner
 is "nobody".
How do I force the script to run as root so that the chown command inside
my script will work correctly?
I've tried setuid, but then the script doesn't work at all! 

TIA
Clive

PS. reply to my work email address:-  clive@icl.NOSPAM.co.za
( remove .NOSPAM )



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

Date: Tue, 25 Nov 1997 20:43:09 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: How do I run script as ROOT?
Message-Id: <347b382d.451291693@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On 26 Nov 97 06:14:02 GMT, "Clive McAdam" <clivem@hixnet.co.za> wrote:

>I have a perl script that allows users to create directories and files.
>
>My problem is that the script is owned by root and the webserver is set
>up as nobody (not even a user on the system, don't want to set it up as
>root)
> so when each user comes in and creates his directory, the owner
> is "nobody".
>How do I force the script to run as root so that the chown command inside
>my script will work correctly?
>I've tried setuid, but then the script doesn't work at all! 

You could create a SUID wrapper in C.

Maybe you ought to look into something like cgiwrap, though. It'd save
you the trouble of [mostly] reinventing the wheel.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Tue, 25 Nov 1997 20:04:28 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: How to directly call a POST method
Message-Id: <34802527.3601871@news.wwa.com>

On Mon, 24 Nov 1997 19:18:21 +0100, "SveN" <SveN@schleissheimer.de>
wrote:

>Help,
>
>I have a HTML Dokument that uses:
>
><form method=POST action="http://www.domain.com/cgi-bin/test.pl">
>     <input type=text name=var size=6><BR><BR>
>  <input type=submit>
> </form>
>
>Now I want to call test.pl directly without any user action
>(no klicking on the submit button) with a specified value for
>var. How can I do this?

Do you mean with a script like this?

:#!/usr/local/bin/perl5.004 -w
:use strict;
:use HTTP::Request::Common qw(POST);
:use LWP::UserAgent;
:my $ua = new LWP::UserAgent;
:my $req = POST 'http://www.domain.com/cgi-bin/test.pl', ['var' => 'value'];
:my $res = $ua->request($req);
:if ($res->is_success) { print "'It worked\n\n" }
:else { print "'It didn't work\n\n" }
:exit;

Or, were you asking a non-perl question with an answer like this?

:<A HREF="http://www.domain.com/cgi-bin/test.pl?var=value">click here</A>

Streben nach Wahrheit

Faust Gertz
Philosopher at Large

"Even the gods, for all they are called wise, are no more to be
trusted than fleeting dreams.  Among the gods, no less than mortal
men, confusion reigns." -- Orestes, _Iphigenia in Taurus_


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

Date: Tue, 25 Nov 1997 12:04:51 -0500
From: Dan Boorstein <dboorstein@ixl.com>
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <347B0533.6DE12B5E@ixl.com>

Mike West wrote:
> 
> In article <comdog-ya02408000R2411971501330001@news.panix.com>
>  brian d foy, comdog@computerdog.com writes:
> >
> >In article <01bcf675$0ea174c0$c82da8c0@akilles.ittek.org>, "Robert Friberg" ><robert.friberg@your_clothes.eductus-vast.com> wrote:
> >
> >>print $number && 1 ? 'Odd!': 'Even!', "\n";
> >
> >i guess you didn't bother to test this.  thanks for posting crap.
> >
> 
> foreach $number ( -3..4 )
>    {
>    print $number, ": " ,$number%2 && 1 ? 'Odd!': 'Even!', "\n";
>    }
> 
> Gives:
> 
> -3: Odd!
> -2: Even!
> -1: Odd!
> 0: Even!
> 1: Odd!
> 2: Even!
> 3: Odd!
> 4: Even!
> 
> Though wrong, Robert's way was only off by "%2", and when fixed
> it seems to meet the wizard's criteria of being terse, dense,
> and needing about an hour in the documentation to understand,
> and relies on what I think of as advanced features.

why the "&& 1"? isn't this always "true"?

for (-3..4) {
  $type = $_ % 2 ? 'Odd!' : 'Even!';
  print "$_: $type\n";
}

should yield the same.

dan


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

Date: Tue, 25 Nov 1997 21:35:43 GMT
From: Philip Jacob <pjacob@brodeur.com>
Subject: HOWTO: DBD:Sybase running on Linux
Message-Id: <EK81Hn.CGJ@nonexistent.com>

I have spent all of yesterday and most of today trying to get DBI/DBD:Sybase
running on my Linux box here, and it's finally working.  Due to a lack of decent
instructions on the web, I am making this how-to doc available for those of you
who might be interested in interfacing Perl and Sybase SQL Server:

	http://www.brodeur.com/~pjacob/dbdsybase/

Please let me know if you have any corrections or additions to make.  I'm also
interested in your experiences with Linux distribs apart from Redhat 4.2.

Thanks,
phil.

-- 

Philip Jacob
Brodeur Porter Novelli Interactive
855 Boylston Street
Boston, MA 02116
V: (617) 587-2012
http://www.brodeur.com/


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

Date: Tue, 25 Nov 1997 10:46:11 -0800
From: "csa@netcom.com" <csa@netcom.com>
Subject: IS THERE A DB INTERFACE INTO MS SQL SERVER?
Message-Id: <347B1CF3.4878@netcom.com>

Does anybody know of a module that would allow me to interface
into MS SQL SERVER on a Windows NT machine (besides the ODBC module)?

Thanks
csa@netcom.com


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

Date: Tue, 25 Nov 1997 19:07:55 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: IS THERE A DB INTERFACE INTO MS SQL SERVER?
Message-Id: <347b21fd.445611475@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On Tue, 25 Nov 1997 10:46:11 -0800, "csa@netcom.com" <csa@netcom.com>
wrote:

>Does anybody know of a module that would allow me to interface
>into MS SQL SERVER on a Windows NT machine (besides the ODBC module)?

Yes.

Win32::ODBC.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Tue, 25 Nov 1997 11:41:36 +0000
From: Glenn West <westxga@ptsc.slg.eds.com>
Subject: Re: launch a child process in a cgi
Message-Id: <347AB970.1C57@ptsc.slg.eds.com>

xavier wrote:
> 
> Hello everybody,
> 
> In one of my perl cgi script I have to read a form, execute a child
> process and return a information page on the browser.
> I'm using : system("the command to run"); and my script wait for this
> child process to terminate and display the information page. But I don't
> want to wait for the child. I want to execute the process in background
> and display the information page before the end of this process. I tried
> : system("command to run &") but it doesn't change anything.
> 
> Please help me !!!

use fork and exec

> 
> Xavier (delaval@hotmail.com)


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

Date: Tue, 25 Nov 1997 17:02:59 -0500
From: "D. Sean Davidson" <davidson@zk3.dec.com>
Subject: Re: launch a child process in a cgi
Message-Id: <347B4B13.C827CE05@zk3.dec.com>

This is what I do to disassociate the detached process from the httpd
server
so if the server ever goes down it doesn't take the child with it.

Sean


use POSIX;

# response to brower here...

#
# detach process
#
$Detach = 1;
open(STDIN, "</dev/null");
open(STDOUT, ">/dev/null");
open(STDERR, ">/dev/null");
if ($pid = fork) {
    waitpid($pid, &WNOHANG);
    exit 0;
}

# other stuff here...


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

Date: Tue, 25 Nov 1997 16:51:32 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: James Mak <mak@saturn.osf.org>
Subject: Re: newbie question
Message-Id: <Pine.GSO.3.96.971125164838.7861B-100000@usertest.teleport.com>

On 24 Nov 1997, James Mak wrote:

> Subject: newbie question

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> open(FD, $filename);

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

> while (<FD>){
> 	s/oldstuff/newstuff/gi;
> }

You probably want the diamond operator and $^I. Or see below. 

> &flush(FD);
> close(FD);

Closing the file will flush it, so there's no need (or use) to an explicit
flush.

I think you want this command line, or one like it.

    perl -pi.bak -e 's/old/new/gi' files*

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 27 Nov 1997 19:23:36 +0900
From: kwangje@handy.co.kr.amadagp.co.jp ("Cho, Kwangje")
Subject: None
Message-Id: <199711271028.TAA19271@hs.int.amadagp.co.jp>

This is a multi-part message in MIME format.

------=_NextPart_000_0000_01BCFB69.F54AF740
Content-Type: text/plain;
	charset="euc-kr"
Content-Transfer-Encoding: quoted-printable

 subscribe perl-users


------=_NextPart_000_0000_01BCFB69.F54AF740
Content-Type: text/html;
	charset="euc-kr"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3D"text/html; charset=3Dks_c_5601" =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.71.1008.3"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<P><FONT color=3D#000000 face=3D=B1=BC=B8=B2 size=3D2>&nbsp;subscribe=20
perl-users</FONT></P></BODY></HTML>

------=_NextPart_000_0000_01BCFB69.F54AF740--




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

Date: Thu, 27 Nov 1997 19:26:58 +0900
From: kwangje@handysoft.co.kr ("Cho, Kwangje")
Subject: None
Message-Id: <199711271032.TAA19772@hs.int.amadagp.co.jp>

This is a multi-part message in MIME format.

------=_NextPart_000_0001_01BCFB6A.6DB4C580
Content-Type: text/plain;
	charset="euc-kr"
Content-Transfer-Encoding: quoted-printable

=20

 subscribe perl-users



------=_NextPart_000_0001_01BCFB6A.6DB4C580
Content-Type: text/html;
	charset="euc-kr"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3D"text/html; charset=3Dks_c_5601" =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.71.1008.3"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<P><FONT color=3D#000000 face=3D=B1=BC=B8=B2 size=3D2>&nbsp;</P>
<P><FONT color=3D#000000 face=3D=B1=BC=B8=B2 size=3D2>&nbsp;subscribe =
perl-users</FONT></P>
<P></FONT></BODY></HTML>

------=_NextPart_000_0001_01BCFB6A.6DB4C580--




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

Date: Tue, 25 Nov 1997 15:45:05 +0100
From: E-Society Editor <esociety@vademecum.be>
Subject: Re: Open file works under DOS, not under server
Message-Id: <347AE470.2EBD1680@vademecum.be>

Nathan,

I'll bet you are using a UNIX as webserver - just try to change the
forward slash into a backslash

Nathan V. Patwardhan wrote:

> dsmith6@sct.edu wrote:
> : Why does the following code work fine under DOS, but doesn't appear
> : to work under the O'Reilly Web Server.  From the server, the file
> : doesn't appear to read in any data. Other CGI's seem to work OK.
>
> : $file = "ratedata/comments.txt";
>
> Use the absolute path to the file.  CGI doesn't know where it is.
>
> --
> Nathan V. Patwardhan
> nvp@shore.net





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

Date: Tue, 25 Nov 1997 16:13:32 -0800
From: jlee <jlee@mdsi.bc.ca>
Subject: pattern substituition operation question
Message-Id: <347B69AC.4D33@mdsi.bc.ca>

I want to delete all the white spaces from a string but do not want to
delete the spaces that are between quotation marks. For example, if I
have the following string:

    test= "aaa aaa " bbb bbb "ccc ccc"   ddd  

and want the result to be:

    test="aaa aaa"bbbbbb"ccc ccc"ddd

Does anyone know how to do this with the pattern substitution operation?
I know you can do this in sed since has pattern addressing.

Thanks.

Jerry


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

Date: Tue, 25 Nov 1997 20:38:27 -0600
From: "Mark Evans" <maevans@io.com>
Subject: Re: perl bad for backgroud job?
Message-Id: <65g205$kus$1@nntp-2.io.com>


>However, after I ran it for couple of days, it seems like it
>is eating up more and more RAM as time goes.  Is there anything
>special about memory allocation in perl?  Any suggestion?
>
>Ernest
>esiu@cs.ualberta.ca

>
Memory Allocation is really a 'ignore it' in perl. What is important,
however, is to make sure you're not calling subroutines which never end
(i.e. a recursive routine gone bad). Memory is release when it is no longer
referenced. Watch for anonymous references and the like. Perl is probably
just as good as any for your task. Probably the same memory allocation
issues too!




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

Date: 25 Nov 1997 17:22:21 GMT
From: twod@not.valid
Subject: Re: PERL Hourly Rates
Message-Id: <65f1gd$mn8$2@vnetnews.value.net>

Jacqui Caren (Jacqui.Caren@ig.co.uk) wrote:
: other techniques and tools is always a plus. There are many almost
: competent perl progammers out there who write perl that works but
: a good perl progammers shudders when they see it - I know I usually
: do so when I am asked to "enhance" someones software.

Is it not one of the unwritten rules about contracting/consulting that you
reserve the right to throw your hands in the air and exclaim 'Who the hell
wrote this junk and why ? when maintaining code ?

Believe me, someone will have said this about some of your code in the past if
you have been in the industry for a while - I'm sure it's been said of some 
of my early work :)

IAP
--
I am using anti-spam measures, please replace 'not.valid' with 'value.net'


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

Date: Wed, 26 Nov 1997 01:36:55 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: PERL Hourly Rates
Message-Id: <65fsmr$8ut@mtinsc03.worldnet.att.net>

In article <toutatis-ya023180002511970422120001@news.euro.net>,
toutatis@no.mail.please (Toutatis) wrote:

> comdog@computerdog.com (brian d foy) wrote:

> > CGI scripting is trivial.  you output an HTTP header and some data.  all
> > of my interns pick it up the same day that i teach it to them.  remember
> > that CGI programming is just another skill set - it's not a job
> > description.

> I'm only programming CGI in perl for about one and a half year, and to be
> frank not made a single dime with it _yet_, but dare to say: I disagree.
> Note that the question was about CGI *scripting*.I translate that as:
> creating server side applications that interact with a user through a
> browser using the Common Gateway Interface. When developing an application
> under CGI there are a *lot* of very specific conditions. 

i don't see how this is different than any other programming intended for
use by other people.  it certainly is a lot more simple than programming
X-Windows or any other GUI with which i've dealt.

software engineering is not a trivial task, but CGI is not difficult. there
is a clear specification with a minimal set of rules.  if you separate
this set of skills from learning how to debug and test your creations and
all of the other normal programming skills, there isn't very much left.

perhaps my perspective is different than others because i was programming
before CGI and had already developed my toolbox of programming skills.  as
such CGI wasn't anything terribly difficult compared to the other things 
i had already done.  i'm sure that the perspective might be different for
someone whose first substantive programming experience is with CGI, but
i don't think it is the CGI portion of the task which makes it seem
difficult.

-- 
brian d foy                                 <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm


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

Date: Tue, 25 Nov 1997 20:40:24 -0500
From: "Alan Fahrner" <sherlock.holmes@worldnet.att.net>
Subject: Re: PERL Hourly Rates
Message-Id: <65fumv$eah@mtinsc03.worldnet.att.net>

Hello all...

I must admit that I agree totally with Brian D. Foy's assertion that CGI
programming is basically easy.  Obviously, even easy things become extremely
complicated as you dig into them (perl itself is a great example of the
sliding scale of difficulty).  But if you know some perl and basic html
tags, then building a script that basically looks at environmental variables
and prints to STDOUT can't be considered difficult.  I cannot tell you how
hard cgi stuff is in other languages...

As for those who kind of zapped him about bugs supposedly found on one (or
more) of his web-sites -- I suspect we all live in glass houses (especially
if you've got a lot of code or html pages out there) :-)

We are all human...

And I wish you all a great Thanksgiving!

Alan
alan@protix.com
http://www.chelz.com/




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

Date: 25 Nov 1997 15:09:31 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: PERL Hourly Rates
Message-Id: <8c4t50eick.fsf@gadget.cscaper.com>

>>>>> "twod" == twod  <twod@not.valid> writes:

twod> Is it not one of the unwritten rules about
twod> contracting/consulting that you reserve the right to throw your
twod> hands in the air and exclaim 'Who the hell wrote this junk and
twod> why ? when maintaining code ?

twod> Believe me, someone will have said this about some of your code
twod> in the past if you have been in the industry for a while - I'm
twod> sure it's been said of some of my early work :)

I've said it about my *own* stuff when I've gone back later.
Admittely, modern versions of Perl really make a lot of things easier
that we had to do "by hand" earlier.

Probably the most embarassing code I've written was the first Perl
code to be part of the "public record", as one of the exhibits in my
trial.  Awful stuff, actually... just a quick hack.  (Remember that
the next time you write a quick hack... you may have to defend it in
court. :-)

For details about my case, see the autoreply address below:

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 279 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: Tue, 25 Nov 1997 12:07:44 -0500
From: Douglas Clifton <doug1@net-link.net>
Subject: Re: perl script for generating simple web page
Message-Id: <347B05E0.97B17156@net-link.net>

> Does anyone know of a simple perl script that takes the input of a form
> and simply appends it to an HTML file?
> I'd appreciate any help.

Is the HTML file local to the machine that the script will run on?I hope so
or your script will considerably more difficult.

Example:
----------------------------------------
#!/usr/bin/perl

open HTML, "/path/to/your/htmlfile";
undef $/;
$html = <HTML>;
close HTML;

# now the scalar $html contains the entire HTML file
# and all you have to do is grab the form data and
# append it to this string. Two popular packages
# for doing this easily are CGI.pm and cgi-lib.pl

require 'cgi-lib.pl';

&ReadParse;
# now concatenate
$html .= $in{'form_input_name'};
 ...

# print the MIME header
print "Content-type: text/html\n\n";
# then the HTML itself
print $html;
------------------------------------------------

~d



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

Date: Tue, 25 Nov 1997 14:07:31 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Douglas Clifton <doug1@net-link.net>
Subject: Re: perl script for generating simple web page
Message-Id: <Pine.GSO.3.96.971125140618.4536C-100000@usertest.teleport.com>

On Tue, 25 Nov 1997, Douglas Clifton wrote:

> open HTML, "/path/to/your/htmlfile";

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 26 Nov 97 00:31:34 GMT
From: sah@uow.edu.au (Scott Anthony Hamilton)
Subject: Re: Perl5 Devel tools (ala cscope and cflow)??
Message-Id: <sah.880504294@wumpus>

Gary Faulkner <faulkner@castor.dev.tivoli.com> writes:

>Hello all,

>I've been searching around quite a bit for cflow (preferrably) and/or
>cscope like tools for perl5.  Specifically, I've got several rather
>large packages that are used by a large set of cgi scripts.  I need to
>get my hands around what is being called where, and what is old, dead
>code that can be removed.

I'd also find useful a code coverage tool. Something like 'tcov' that
ships with some compilers.

>Does anyone have, or know of, tools like this for perl5??

--
Scott Hamilton / sah@uow edu au / KeyID C3107E75
87 FE 1D C3 DE 20 37 FB  6F 30 6A 8A D1 38 9A B5


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

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

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