[7522] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1149 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 9 07:17:19 1997

Date: Thu, 9 Oct 97 04:00:23 -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           Thu, 9 Oct 1997     Volume: 8 Number: 1149

Today's topics:
     Re: "19971008" and (....)(..) (Casper K. Clausen)
     Re: Best way to extract array elements, modify, store r (Tony Bass)
     Re: Does Perl compile to bytecode internally?? <seay@absyss.fr>
     help finding combined size of files in dir via perl <paries@advicom.net>
     Re: help finding combined size of files in dir via perl (Mike Heins)
     Help!  I need to delete multiple lines from an HTML pag <rwhahn@idirect.com>
     Re: Lame Question re; pod2man <seay@absyss.fr>
     Launch Applications from Macperl <cmuth@cinci.infi.net>
     Lists of lists in Perl 4 <Janning.Vygen@bonn.netsurf.de>
     Re: Module for dealing with INN spools. <seay@absyss.fr>
     Re: Need help getting LWP to work with my proxy server <rpsavage@ozemail.com.au>
     Re: Need help with logic <seay@absyss.fr>
     Re: Passing Command Lines From Perl in NT <seay@absyss.fr>
     Perl Compiler <tsestini@ais.it>
     Re: Problems getting Perl to work with dbm files. <seay@absyss.fr>
     Problems with flock <xavi@teclata.es>
     Re: Process Control for NT/ Perl (Brent Herridge)
     Re: Q: hash key confusion <seay@absyss.fr>
     Q: How to change GID? (Marek Rouchal)
     Question: File locking <gjlee@uclink4.berkeley.edu>
     Re: splitting problems (Mick Farmer)
     Re: True compiled <seay@absyss.fr>
     Re: WHERE TO GET & HOW TO INSTALL PERL5 <pvhp@forte.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 09 Oct 1997 09:52:20 +0200
From: ckc@dmi.min.dk (Casper K. Clausen)
Subject: Re: "19971008" and (....)(..)
Message-Id: <wvpafgj74qz.fsf@hobbes.dmi.min.dk>

Okay. I blew it with the return value thing. Sorry. Won't happen
again, I hope. Now will you all get off my back? :)

Regards,
Kvan.
-- 
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- |  unattempted is impossible.'
           Lokal  544            |   
I do not speak for DMI, just me. |        - Lord Mhoram, Son of Variol.      


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

Date: 9 Oct 1997 10:09:01 +0100
From: aeb@brains.cartoon.bt.co.uk (Tony Bass)
Subject: Re: Best way to extract array elements, modify, store resulting list?
Message-Id: <61i6vd$9h3$1@brains.cartoon.bt.co.uk>

>From article <343BAF9E.D77A7CE9@dt.wdc.com>, by Bruce Reid <reid@dt.wdc.com>:
> Dear Perl folks,

> I'm looking for an elegant way to extract from an array all elements
> that satisfy a certain criterion, modify each one in a prescribed way
> (without modifying the original array), and assign the resulting list to
> another array. I'd like to do it as simply as possible without an
> explicit for loop.

> The original list consists of file names which are preceeded by either
> 'p.' or 's.'. I want to extract all 's.' files, strip off the 's.'
> prefix, and store the resulting filenames in a new list.
[...]

If the modification is just extracting a substring,

   my @array = qw/s.file1.c s.file2.c p.files.file4.c s.file3.c p.file5.c/; 
   my @sfiles = map m/^s\.(\S+)$/, @array;

More complicated modifications could build on this - for instance,

   my @sfiles = map "t.$_", map m/^s\.(\S+)$/, @array;

gets a sublist with new prefix.

    Tony Bass

-- 
# A E Bass                                      Tel: (01473) 645305
# MLB 3/19, BT Laboratories                     e-mail: aeb@saltfarm.bt.co.uk
# Martlesham Heath, Ipswich, Suffolk, IP5 7RE   DO NOT e-mail to From: line
#                                               Opinions are my own


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

Date: Thu, 09 Oct 1997 11:46:11 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Does Perl compile to bytecode internally??
Message-Id: <343CA7E3.2AFCD0C0@absyss.fr>

Benjamin Holzman wrote:
> 
> Eric wrote:
> >
> > Does PERL compile a program to bytecode internally before executing?
> Perl compiles a program to a 'syntax tree', not a bytecode per se, but
> still a discrete 'compilation' step.

Yeah, but it is a bit uglier than that.  BEGIN blocks are executed as
soon as they are compiled.  This is the magic that lets "use pramagata"
work.

- doug


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

Date: Wed, 08 Oct 1997 23:45:52 -0500
From: Randy Paries <paries@advicom.net>
Subject: help finding combined size of files in dir via perl
Message-Id: <343C617F.765DFB9A@advicom.net>

hello,

via perl  I need to determine how much disk space is being taken up by
jpgs in a particular dir

Thanks
Randy Paries




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

Date: 9 Oct 1997 06:34:04 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: help finding combined size of files in dir via perl
Message-Id: <61htss$ka8$1@vixen.cso.uiuc.edu>

Randy Paries (paries@advicom.net) wrote:
: hello,
: 
: via perl  I need to determine how much disk space is being taken up by
: jpgs in a particular dir
: 

my $dir = '/ext/htdocs/images';

my $totalsize = 0;

opendir(DIR, $dir) or die;
@files = grep /\.jpe?g$/i, readdir DIR;
for(@files) {
	$totalsize += -s _		unless -l "$dir/$_";
}
print "Size of JPEGS: $totalsize\n";


Note that if there are hard links this is not reliable.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: Thu, 09 Oct 1997 01:27:28 -0400
From: Robert Hahn <rwhahn@idirect.com>
Subject: Help!  I need to delete multiple lines from an HTML page
Message-Id: <343C6B11.3CD46976@idirect.com>

I'm rather new at Perl, so I hope someone can help me.  I need to write a
script that delets multiple lines from an HTML page.

So:
1) given that the block of lines I want to delete are preceeded and followed
by an identical comment:

<HTML>
 ...
<!--myComment.right.here and maybe a # will be found in here too-->
 ...
<!--myComment.right.here and maybe a # will be found in here too-->
 ...
</HTML>

2) that a string value is passed to the perl script from an HTML form:

 ...variable=<!--myComment.right.here-->&...

Why would this code not work?  Can anyone fix it? (I used Matt Wright's
guestbook.pl file as a starting point)

---
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);

   # Un-Webify plus signs and %-encoding
	$value =~ tr/+/ /;
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	$value =~ s/(\W)/\\$1/g;

   $FORM{$name} = $value;
}

# Begin the Editing of the Resale File
open (FILE,"$resalereal") || die "Can't Open $resalereal: $!\n";
@LINES=<FILE>;
close(FILE);
$SIZE=@LINES;

$PVAL = "$FORM{address}";

# Open File for deleting a listing
open (RESALE,">$resalereal") || die "Can't Open $resalereal: $!\n";

for ($i=0;$i<=$SIZE;$i++) {
   $_=$LINES[$i];
   if (/$PVAL.*?$PVAL/s) { 
		print RESALE "\n";
	}
	else {
		print RESALE $_;
	}
close (RESALE);
---

I've tried many things, but either I get no result (as per the perl code
above) or I wipe the entire file.

If I receive or discover a solution, I'll post it here.  Many thanks to anyone
who can help me on this one.

Rob


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

Date: Thu, 09 Oct 1997 11:21:35 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Lame Question re; pod2man
Message-Id: <343CA21F.1CF517A@absyss.fr>

Paul Denman wrote:
> 
> Hello,
> 
> I've often read of the utilities 'pod2man' and 'pod2html' which are meant
> to come with Perl. However, my web server which has Perl v5.001,
> unofficial patchlevel 1m, does not seem to have these two utilities
> installed.
> 
> Is there anywhere I could download just these two files from, and where
> should I install them on my server?

They come with Perl5.004, so if you have to, you can get the
distribution, untar and just copy out the files.  But I'd guess that
they'd be available on CPAN too.  As for installing them, that doesn't
matter as long as your PATH environment variable looks there (or you
like typing in absolute path names).  I'd put it in the same directory
as the perl binary, but it doesn't really matter.

- doug

PS - Get the sysadmin for your web server to upgrade.  There are serious
security holes with any Perl older than 5.004.


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

Date: Thu, 09 Oct 1997 00:56:11 -0400
From: Craig <cmuth@cinci.infi.net>
Subject: Launch Applications from Macperl
Message-Id: <343C63EA.3158@cinci.infi.net>

Hello,

It would be greatly appreciated if someone could tell me how to simply
launch an application from MacPerl.  I tried:

	open(AFILE,"| ".$OpenThisFile) || die "couldn't do it";

Running this (with a valid path name) gave no error (not even my
"couldn't do it" thing), but did nothing.
Also, I would love to know how to get MacPerl to quit after it is done
running a script.
If you have any ideas, please email me at cmuth@enquirer.com.
Thanks a lot.


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

Date: Thu, 09 Oct 1997 12:51:30 +0100
From: Janning Vygen <Janning.Vygen@bonn.netsurf.de>
Subject: Lists of lists in Perl 4
Message-Id: <343CC542.41759187@bonn.netsurf.de>

How can I create a list of a list
(=multidimensional array) in Perl 4?

I read in the german edition of "Learning Perl" by
Randal Schwartz:  ' that a list can4t have a list
as its element. But in Perl 5 it is allowed to use
a reference to a list as an element of a list.'

Is there no way to create list of lists??

Thanks in advance

Janning Vygen
Bonn - Germany



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

Date: Thu, 09 Oct 1997 11:32:41 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Module for dealing with INN spools.
Message-Id: <343CA4B9.5C1735E8@absyss.fr>

Eli the Bearded wrote:

	<stuff about news spools>

> 
> Elijah
> ------
> "But the second or third time I read news on PANIX Jim mentioned
>  to me that rn had been installed since I'd last looked.  He
>  noticed I was 'more'ing the news spool."
>  -- Mara Chibnik (mc@panix.com)

For you young-uns, "rn" is another fine product from Larry Wall.  Has he
ever gotten back to his project of redoing it in Perl?

- doug


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

Date: Thu, 09 Oct 1997 16:07:08 +1100
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: Need help getting LWP to work with my proxy server
Message-Id: <343C667C.31B@ozemail.com.au>

[snip]
 
> Does anyone else using Net::FTP and CPAN have a firewall setup like
> this?  If so, how did you get it to work for you?
> [snip]

#!/usr/local/bin/perl -w
# Name:
#	xferUrl.pl.
#
# Purpose:
#	Get or Put a URL.
#
# Switches:
#	-help				Display help and exit(1)
#	-debug				Turn on LWP::Debug::level('+')
#	-quiet				Stop echo to the screen of document retrieved
#	-proxy		String	My proxy's name
#	-agent		String	My disguise
#	-command	String	GET | PUT
#	-protocol	String	ftp | http
#	-site		String	Where to GET it from or PUT it to
#	-username	String	With PUT, my remote username
#	-password	String	With PUT, my remote password
#	-email		String	My Email address
#	-tilde				With GET, add ~ from start of -inFile.
#						With PUT, add ~ to start of -outFile
#	-inFile		String	What to GET, ie a remote name. This can include directory
#						names, and is used to save the document to disk if -outFile
#						is undef, so the dir name must exist.
#						Also, what to PUT, ie a local name
#	-outfile	String	The local name of GET's target
#						The remote name of PUT's target.
#						If undef, use -inFile
#
# Usage:
#	...>perl xferUrl.pl -i WebTechniques/col01.html
#
# Author:
#	Ron Savage 	1.00	rpsavage@ozemail.com.au.
# -------------------------------------------------------------------

use integer;
use strict;

use Getopt::Simple qw($switch);	 # One of mine. You could substitute your own.
use LWP::Debug;
use LWP::UserAgent;

my($option);

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

sub doIt2It
{
	LWP::Debug::level('+') if $switch -> {'debug'};

	# Fabricate myself.
	my($userAgent) = new LWP::UserAgent;

	# Stop error 500.
	# I'm inside bhp.com.au.
	if ($switch -> {'proxy'})
	{
		my($proxy) = "http://$switch->{'proxy'}:8080/";
		$userAgent -> proxy(['ftp', 'http'], $proxy);
	}

	# Stop error 501.
	# Disguise myself as Netscape.
	$userAgent -> agent($switch -> {'agent'});
	# Give the other party my true etherMail address.
	$userAgent -> from($switch -> {'email'});

	# Fabricate request.
	my($url, $request);

	if ($switch -> {'command'} eq 'GET')
	{
		$url = new URI::URL("$switch->{'protocol'}://$switch->{'site'}/$switch->{'inFile'}");
	}
	else
	{
		$url = new URI::URL("$switch->{'protocol'}://$switch->{'site'}/$switch->{'outFile'}");
		$url -> user($switch -> {'username'});
		$url -> password($switch -> {'password'});
	}

	$request = new HTTP::Request($switch -> {'command'}, $url);

	my($content);

	# Populate the content to send.
	if ($switch -> {'command'} eq 'PUT')
	{
		open(INX, $switch -> {'inFile'}) || die("Can't open $switch->{'inFile'}: $!");
		read(INX, $content, (-s INX) );
		close(INX);
		$request -> content($content);
	}

	# Send request.
	my($response) = $userAgent -> request($request);

	# What?
	if ($response -> is_success() )
	{
		print $response -> content() if (! $switch -> {'quiet'});

		if ($switch -> {'command'} eq 'GET')
		{
			$content = "../$switch->{'outFile'}";
		}
		else
		{
			$content = 'xferUrl.log';
		}

		open(OUT, "> $content") || die("Can't open > $content: $!");
		print OUT $response -> content();
		close(OUT);
	}
	else
	{
		print $response -> error_as_HTML();
		exit(0);	# Failure.
	}

}	# End of doIt2It.

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

sub init
{
	my($default) =
	{
	'help' =>
		{
		'Type'		=> '',
		'Env'		=> '-',
		'Default'	=> '',
		'Order'		=> 1,
		},
	'debug' =>
		{
		'Type'		=> '',
		'Env'		=> '-',
		'Default'	=> '',
		'Order'		=> 2,
		},
	'quiet' =>
		{
		'Type'		=> '',
		'Env'		=> '-',
		'Default'	=> '',
		'Order'		=> 3,
		},
	'proxy' =>
		{
		'Type'		=> '=s',
		'Env'		=> '$PROXY',
		'Default'	=> $ENV{'PROXY'} || '',
		'Order'		=> 4,
		},
	'agent' =>
		{
		'Type'		=> '=s',
		'Env'		=> '-',
		'Default'	=> 'Mozilla/3.01',	# Aka Netscape.
		'Order'		=> 5,
		},
	'command' =>
		{
		'Type'		=> '=s',
		'Env'		=> 'None. Use GET | PUT',
		'Default'	=> 'GET',
		'Order'		=> 6,
		},
	'protocol' =>
		{
		'Type'		=> '=s',
		'Env',		=> 'None. Use ftp | http',
		'Default'	=> 'http',
		'Order'		=> 7,
		},

# These numbers - 1, 2 - under site correspond to the numbers below under file.
#
# 1. ftp.ozemail.com.au
#
# 2. www.stonehenge.com/merlyn

	'site' =>
		{
		'Type'		=> '=s',
		'Env',		=> '-',
		'Default'	=> 'www.stonehenge.com/merlyn',
		'Order'		=> 8,
		},
	'username' =>
		{
		'Type'		=> '=s',
		'Env'		=> '$USER',
		'Default'	=> $ENV{'USER'} || 'rpsavage',
		'Order'		=> 9,
		},
	'password' =>
		{
		'Type'		=> '=s',
		'Env'		=> '-',	# Env? No. NOT a good place to put a password.
		'Default'	=> 'password',
		'Order'		=> 10,
		},
	'email' =>
		{
		'Type'		=> '=s',
		'Env'		=> '$EMAIL',
		'Default'	=> $ENV{'EMAIL'} || '',
		'Order'		=> 11,
		},
	'tilde' =>
		{
		'Type'		=> '',
		'Env',		=> '-',
		'Default'	=> '',
		'Order'		=> 12,
		},

# Warning: This file name is used to save the document to disk.
#	So any directory name here must refer to an existing directory.
#
# 1. rpsavage/index.html
#
# 2. WebTechniques/col01.html
# 2. WebTechniques/col01.listing.txt

	'inFile' =>
		{
		'Type'		=> '=s',
		'Env',		=> '-',
		'Default'	=> 'WebTechniques/col01.html',
		'Order'		=> 11,
		},
	'outFile' =>
		{
		'Type'		=> '=s',
		'Env',		=> '-',
		'Default'	=> '',	# Default is $switch -> {'inFile'} =~ s/~//.
		'Order'		=> 12,
		},
	};

	$option = new Getopt::Simple;

	if (! $option -> getOptions($default, "Usage: xferUrl.pl [options]", 1) )
	{
		exit(0);	# Failure.
	}

}	# End of init.

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

sub validate
{
	$switch -> {'command'} =~ tr/a-z/A-Z/;

	if ($switch -> {'command'} !~ /(GET|PUT)/)
	{
		print "-command takes GET or PUT \n";
		helpOptions();
		exit(0);
	}

	$switch -> {'protocol'} =~ tr/A-Z/a-z/;

	if ($switch -> {'protocol'} !~ /(ftp|http)/)
	{
		print "-protocol takes ftp or http \n";
		helpOptions();
		exit(0);
	}

	$switch -> {'outFile'}	= $switch -> {'inFile'} if (! $switch -> {'outFile'});

	if ($switch -> {'command'} eq 'GET')
	{
		$switch -> {'inFile'} = '~' . $switch -> {'inFile'} if ($switch -> {'tilde'});
	}
	else
	{
		$switch -> {'outFile'} = '~' . $switch -> {'outFile'} if ($switch -> {'tilde'});
	}

}	# End of validate.

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

&init();

&validate();

&doIt2It();

exit(1);

__END__

=head1 NAME

C<xferUrl.pl> - Get or Put a document given a URL.

=head1 SYNOPSIS

	xferUrl.pl -tilde
	xferUrl.pl -site www.stonehenge.com/merlyn -inFile WebTechniques/col01.html

=head1 DESCRIPTION

C<xferUrl.pl> uses a HTTP GET or PUT command to emulate a browser.

=head1 Command line switches

C<xferUrl.pl> provides these switches:

=over 4

=item *

-help. Display help and terminate with exit(1)

=item *

-debug. Turn on LWP::Debug(+)

=item *

-quiet. Stop echo to the screen of document retrieved

=item *

-proxy. My proxy's name, if I'm behind a firewall

=item *

-agent. My disguise, to keep happy those donors who care

=item *

-command. GET | PUT. This is case-insensitive

=item *

-protocol. ftp | http. This is case-insensitive

=item *

-site. Where to GET the -inFile from or PUT it to

=item *

-username. My remote username, to tell the site who is PUTting

=item *

-password. My remote password, to tell the site who is PUTting

=item *

-email. My Email address, to tell the donor who I am

=item *

-inFile. What to GET or PUT. This can include directory names, and may be used
to save the document to disk, so the dir name must exist

=item *

-outfile. What to save it as. If undef, use -inFile =~ s/~//

=item *

-tilde

=back

=head1 REQUIRED MODULES

=over 4

=item *

Getopt::Simple - one of mine. You could substitute your own

=item *

LWP::UserAgent

=item *

#LWP::Debug qw(+) -
Turn on debugging if error_as_HTML() does not provide sufficient gossip

=back

=head1 RETURN VALUE

C<xferUrl.pl> returns 1 for success, or 0 for failure.

=head1 TO DO

6-Oct-97. I'm uneasy about the handling of source 'v' destination directory
structures. I may change the way this operates.

=head1 AUTHOR

C<xferUrl.pl> was written by Ron Savage I<E<lt>rpsavage@ozemail.com.auE<gt>> in 1997.

=head1 LICENCE

This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.


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

Date: Thu, 09 Oct 1997 11:17:59 +0200
From: Doug Seay <seay@absyss.fr>
To: dwhill@atl.mindspring.com
Subject: Re: Need help with logic
Message-Id: <343CA147.3DD078EA@absyss.fr>

[posted and mailed]

dwhill@atl.mindspring.com wrote:
> 
>     Never said I was quick.
> 
>     I have a large text file containing reports delimited with a BEGIN
> keyword and an END keyword. A keyword "HARDWARE" is contained
> within some of these reports. Those I need to print to unique files.
> One report to a unique file name. I am obviously new at this. But, I
> have read and looked and can't find a good example. I can hack
> thru the syntax stuff but the logic is killin' me. Any hints would be
> greatly appreciated.
> 
>                                                 David W. Hill


Since you don't talk about one-per-line or other sort of easy trick,
I'll assume that anything can appear any where.  Try slurping the whole
file into a single scalar (it is only a couple of megs, right?), then do
a loop something looking for BEGIN/END pairs (you don't exclude the
possibility of multiple BEGIN/END pairs in your input).  Look in the
data between these pairs for your HARDWARE keyword.  Note that I only
look for HARDWARE once per BEGIN/END.

while ( length $buffer )
	{
	my $begin = index($buffer, "BEGIN");
	last unless ( $begin >= 0 );
	substr($buffer,0,$begin) = '';	# delete upto BEGIN
	my $end = index($buffer, "END", $begin);
	my $data;
	if ( $end > 0 )
		{
		# get stuff to the end marker
		$data = substr($buffer,0,$end);
		substr($buffer,0,$end) = '';
		}
	else
		{
		# no end marker, use rest of buffer
		$data = $buffer;
		$buffer = '';
		}

	# you'll need to tweek the details
	&handle_hardware($1) if ( $data =~ m/HARDWARE=(\w+)/ );
	}

This was typed directly into Netscape, so there is a good chance that
I've got a few syntax errors here, but the idea should be clear.  Notice
that I didn't use REs all that much.  index() is usually faster and
easier to read for many people (it is like C's strstr() function).

- doug


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

Date: Thu, 09 Oct 1997 11:36:04 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Passing Command Lines From Perl in NT
Message-Id: <343CA584.4A16E027@absyss.fr>

Authorized User wrote:
> 
> i need to pass a simple command line from a perl script to a c++ executable
> in a NT environment.   the command line is built within the perl script.
> 
> for example :
> 
> \usr\local\matt\script1 -f <filename> -st <source tables> -id <name> -pw
> <password>

You mean that you want to launch the binary file with a given set of
parameters, right?  That is easily found in the "perlfunc" man page.

- doug


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

Date: Wed, 08 Oct 1997 17:03:35 +0100
From: Telemaco <tsestini@ais.it>
Subject: Perl Compiler
Message-Id: <343BAED7.476D@ais.it>

Hi,
I want to know (if exists) where I can take a "true" Perl compiler for
MS-DOS.
I want to mean a Perl compiler that creates an executable file (.EXE)

Thank in advance

              Telemaco


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

Date: Thu, 09 Oct 1997 11:40:34 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Problems getting Perl to work with dbm files.
Message-Id: <343CA692.14271B76@absyss.fr>

David Evans wrote:
> 
> I am trying to set up Perl 5.004.01 on a Sun Spar20, running Solaris
> 2.5.1.
> 
> I have tried to run the following small Perl script:
> 
> #!/app/perl5.004_01/perl
> dbmopen(%DB, "./gctest", 0666) || die "Error: $!\n";
> dbmclose(%DB);
> exit;
> 
> It errors out with the following:
> 
> No dbm on this machine at ./gctest.pl line 2.
> 
> What is causing this error, and what does it mean?

That says to me that "dbm" isn't installed on your machine.  You are
trying the Perl4 approach to databases.  Type "perldoc AnyDBM_File" to
see the modern way.  I can't help you with the details of dbmopen() as
I've never used it.


> After running configure and make, I ran test and notice that it skipped
> the following tests with the message "Skipping test on this platform::
> db-btree, db-hash, db-recno and gdbm.  It also failed the test 3 of the
> filehand test.  What are the implications of skipping these tests on my
> machine?  Are these errors related to the failure of my script?

Nope, it says that "DB" (berkeley's DB) and gdbm (GNU's DB) aren't
installed.  Perl can't use 'em if the libraries aren't there.  No big
deal there.  It impiles that NDBM (New DB, but it is at least 10 years
old) is there.  This is described in AnyDBM_File and in the Camel (of
course).

- doug


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

Date: Thu, 09 Oct 1997 04:15:54 +0200
From: Xavier Tarafa Mercader <xavi@teclata.es>
Subject: Problems with flock
Message-Id: <343C3E58.2627EEF@teclata.es>

I've created a small perl script for understanding flock. The script
does
what follows: Open a file, lock it send amail with the return value for
flock, do something with the file, close the file, unlocked, send a mail

with the return value of the flock function.

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



#!/usr/bin/perl
$ENV{PATH} = '/usr/bin:/bin';

$LOCK_EX                                = 2;
$LOCK_UN                                = 8;
$trouble_email                          = 'xavi@teclata.es';


#
I've created a small perl script for understanding flock. The script
does what follows: Open a file, lock it.,send a mail with the return
value for flock, do something with the file, close the file, unlocked,
and send a mail with the return value of the flock function.

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



#!/usr/bin/perl
$ENV{PATH} = '/usr/bin:/bin';

$LOCK_EX                                = 2;
$LOCK_UN                                = 8;
$trouble_email                          = 'xavi@teclata.es';


#Open file

if(!(open(TABLE,">./test"))){
 print STDERR "Couldn't open Table: $table_content file. Aqui";
 exit(0);
}



#lock the file

$valor=flock(TABLE,$LOCK_EX);
Open file

if(!(open(TABLE,">./test"))){
 print STDERR "Couldn't open Table: $table_content file. Aqui";
 exit(0);
}



#lock the file

$valor=flock(TABLE,$LOCK_EX);


#Get a mail with flock return value

open(OUT,"|mail $trouble_email");
print OUT "El valor de flock es $valor"; # $valor = 1
close(OUT);

#Abort program if was not flocked
    if($valor == 0){
        print STDERR "Couldn't flock Table: $table_content file";
        exit(0);
    }


        print TABLE  "hola";

#Close table
if(!close(TABLE)){
        print STDERR "Could not close Table: $table_content file";
        exit(0);
}

#unlock table
$valor=flock(TABLE,$LOCK_UN);


#Get flock return value.
open(OUT,"|mail $trouble_email");
print OUT "El valor de unflock es $valor"; #$valor=0
close(OUT);

#Abort program if file is not unllocked. ASSUMING 0 AS value for
unsucces
flock.
if($valor == 0){
    print STDERR "Could not unflock Table: $table_content file";
    exit(0);
}

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

The value I get when locking the file (flock(TABLE,$LOCK_EX) is $valor=1

and when i'm unlocking $valor=0. I've assumed   1 = succes
0=error.
Why I get an error unlocking the file when I flock succesfully
(assuming success returns 1)?

The script run under Linux.


Xavier Tarafa
Teclata. S.L



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

Date: 9 Oct 1997 03:46:01 GMT
From: herridge@io.com (Brent Herridge)
Subject: Re: Process Control for NT/ Perl
Message-Id: <61hk1p$7p5$1@nntp-2.io.com>

In article <01bcd422$856fbb40$7cfce59b@matthewk.systecinc.com>, 
matthew.kravitz@systecinc.com says...

> i would like to
>capture the process id of a child process and monitor its state ( alive or
>dead ) .  this is easy to do in unix by using 'ps', but seems to be a

You can get a list of all current processes with PULIST.EXE or TLIST.EXE, both 
of which give a command line output of all current processes and their PIDs. 
Both tools, and a host of other intersting goodies are in the NT Resource kit. 
As for the state of each process, I'm still looking for that one too. Please 
email me if anyone knows.

	-- Brent Herridge <herridge@io.com>
	     Austin, Texas



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

Date: Thu, 09 Oct 1997 11:50:45 +0200
From: Doug Seay <seay@absyss.fr>
To: Raymond Yee <yee@socrates.berkeley.edu>
Subject: Re: Q: hash key confusion
Message-Id: <343CA8F5.79D086A7@absyss.fr>

[posted and mailed]

Raymond Yee wrote:
> 
> Hi everyone,
> 
> Please help me to understand the following construct in perl:
> 
> $Test{$string1,$string2}
> 
> which I found in some code that I'm studying.

Try "perldoc perlvar" and looking at the $; variable ($SUBSEP or
$SUBSCRIPT_SEPARATOR in the "use English" module).  I think that this
should answer all of your questions.

- doug


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

Date: 9 Oct 1997 11:55:59 +0200
From: Marek.Rouchal@-nospam-hl.siemens.de (Marek Rouchal)
Subject: Q: How to change GID?
Message-Id: <61i9nf$ik0@buffalo.HL.Siemens.DE>
Keywords: GID, groups

I need to change the group ID while running a perl script, similar to the
UNIX newgrp command. Sure, I can do something like:

open(NEWGRP,"| newgrp $new_gid");
print NEWGRP "some_unix_command\n";

but I'm wondering whether there is a more convenient way. I've read the
perlvar manpage and tried:

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

print "GID: $( EGID: $)\n";

unlink qw(GID1.txt GID2.txt);

open(FILE, ">GID1.txt") or die "$!";
print FILE "test\n";
close(FILE);

$) = 10051; # one of my secondary GIDs
$( = 10051;

print "newGID: $( newEGID: $)\n";

open(FILE, ">GID2.txt") or die "$!";
print FILE "test\n";
close(FILE);
__END__

I'm running perl 5.00305/Solaris 2.5.1. Although there are no errors (especially no
"no set[re]gid()" or alike), the GID doesn't change and the files both belong to the
same (original) user/group.
Can somebody please show me what I'm missing? Can I change the GID like this at all?
Thank you for having a look at this...

Cheers,

Marek

PS. If you want to reply by Email, please remove -nospam- from the address, I'm
still getting spam mail when posting with the correct address. Thank you.

-- 
  Marek Rouchal                   Phone : +49 89/636-25849
     SIEMENS AG, HL CAD SYS       Fax   : +49 89/636-23650
     Balanstr. 73                 mailto:Marek.Rouchal@-nospam-hl.siemens.de
     81541 Muenchen               PCmail:Marek.Rouchal.PC@-nospam-hl.siemens.de


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

Date: Wed, 08 Oct 1997 23:10:38 -0700
From: "George J. Lee" <gjlee@uclink4.berkeley.edu>
Subject: Question: File locking
Message-Id: <343C755E.8199E9AF@uclink4.berkeley.edu>

I need help with file locking. I am designing a web site for investing
(URL below) and it includes a stock simulation program. It uses a perl
script as a cgi interface to a msql database to keep track of trades.
Trouble is, if two people buy stock at precisely the same time, one of
them won't got the stock because both instances of my perl script assign
the same id # to it. Also, if one person clicks the submit button for
the buy form multiple times, they can get more shares than they should
be able to with their money. I tried using file locking to prevent two
instances from trying to buy at the same time, but with no success. I
know flock works on the server because I have tested it using a test
script, but I can still cheat by clicking the buy button rapidly. Here
as a portion of the relevant code:

      open(PURCHASE, ">>$LOCK_FILE")     or die "open $LOCK_FILE: $!\n";
      flock(PURCHASE, 2);
      &add_to_the_cart;
      flock(PURCHASE, 8);
      exit;

The subroutine "add_to_the_cart" does the actual buying. Inside the
subroutine I call another procedure to get and increment the id # from
the msql database. Since the id # is the primary key in this database,
if two purchases have the same id # one will get lost. I also added 

      $SIG{'PIPE'} = 'IGNORE';

and trapped KILL, TERM, QUIT, and ABRT to unlock the file and exit.
Please reply via e-mail. Thanks.

George Lee

InvestSmart
http://library.advanced.org/10326/


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

Date: Mon, 6 Oct 1997 10:13:07 GMT
From: mick@picus.dcs.bbk.ac.uk (Mick Farmer)
Subject: Re: splitting problems
Message-Id: <EHMKDv.Jy3@mail2.ccs.bbk.ac.uk>

Dear Brent,

The period is a metacharacter in a regular expression
meaning any character.  Try /\./ as your pattern.

Also, if you actually want four separate variables, you
can write the following.

	($ip1, $ip2, $ip3, $ip4) = split ...

Regards,

Mick


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

Date: Thu, 09 Oct 1997 10:51:15 +0200
From: Doug Seay <seay@absyss.fr>
To: tsestini@ais.it
Subject: Re: True compiled
Message-Id: <343C9B03.13D3934@absyss.fr>

[posted and mailed]

Telemaco wrote:
> 
> Hi,
> I'm using Perl under MS-Dos.
> I want obtain a true compiled program.
> Using GNU Perl4, I'm not able to create a .exe using dump-undump
> (it does under Unix but it doesn't under MS-Dos).

undump only works on some Unix platforms.


> Where could I find a "true" Perl Compiler?

You mean Perl->exe?  Doesn't exist ando one has ever talked about doing
that, least not that I heard of.  That would be too many platforms to
support.  If you had read the FAQ (perlfaq3 to be exact), you'd have
seen the question

	How can I compile my Perl program into byte code or C?

It will help you with Perl->C->exe, which should do what you want.

- doug

PS - Don't even think about ever compiling Perl4.  There's been no
support for 5 years or so, and since Malcolm (thy guy who made the
compiler) is leading the 5.005 work, I'd guess that he's more worried
about the future than the past.


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

Date: Wed, 08 Oct 1997 20:50:31 -0700
From: Peter Prymmer <pvhp@forte.com>
To: Don Hamrick <hamrick@alltel.net>
Subject: Re: WHERE TO GET & HOW TO INSTALL PERL5
Message-Id: <343C5487.55E9@forte.com>

Don Hamrick wrote:
>
> If perl5-latest.tar.gz above is not the stand alone perl5.exe I am
> looking for to run on my Win95 computer then where can I find it? And,
> how will I install it?
> 
> Thanks.
> 
> Don


Try looking for a file with 'bindist' in the name in a place called:

    http://www.perl.com/CPAN/authors/Gurusamy_Sarathy/

note that the 'bindist' file will be a .tar.gz file which means
that you will need a gunzip.exe and tar.exe program set or
perhaps the inexpensive Shareware program called WinZip in order
to unpack the *bindist*.tar.gz file.

Good luck.

Peter Prymmer


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

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

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