[16705] in Perl-Users-Digest
Perl-Users Digest, Issue: 4117 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 11:06:04 2000
Date: Thu, 24 Aug 2000 08:05:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967129518-v9-i4117@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 24 Aug 2000 Volume: 9 Number: 4117
Today's topics:
$: in regular expressions <jgoldst@my-deja.com>
Re: $: in regular expressions <uackermann@orga.com>
Re: $: in regular expressions <dietmar.staab@t-online.de>
Re: $: in regular expressions <dietmar.staab@t-online.de>
Re: @ARGV with ( and ) symbols in it <graham.wood@iona.com>
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
A Proposal for BaseLib module <hasant@trabas.com>
Re: about CGI <amonotod@netscape.net>
Can I call a C-function in an existing dynamic library <verbunroX@Xiquip.nl>
Check array for an element <hf@ses-astra.com>
Re: Check array for an element <jkline@one.net>
Re: Check array for an element <elephant@squirrelgroup.com>
File handling and manipulation from function, help plea ptomsic@my-deja.com
File handling and manipulation from function, help plea arvind_kuk@hotmail.com
Re: File handling and manipulation from function, help <care227@attglobal.net>
Re: Flipflop matching <elephant@squirrelgroup.com>
Re: Flipflop matching <jeff@vpservices.com>
fork <wokup.balr005@rd.francetelecom.fr>
Re: fork (Martien Verbruggen)
Re: how can I optimize a tied hash for speed <iltzu@sci.invalid>
Re: How to Include a Perl script in a Perl script (Keith Calvert Ivey)
how to round ? <ventuno@gmx.de>
Re: how to round ? (Martien Verbruggen)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 24 Aug 2000 13:42:20 GMT
From: JL Goldstein <jgoldst@my-deja.com>
Subject: $: in regular expressions
Message-Id: <8o38no$h5v$1@nnrp1.deja.com>
I've searched all my reference books, but I can't find out what $: means
in a regular expression, as in
(?:\d\d\d\d\d)
to match zip codes (example taken from *Mastering Regular Expressions*
by Jeff Friedl, O'Reilly, 1997).
Can anyone help? Thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 24 Aug 2000 16:05:33 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: $: in regular expressions
Message-Id: <39A52BAD.4B30C94B@orga.com>
JL Goldstein wrote:
>
> I've searched all my reference books, but I can't find out what $: means
> in a regular expression, as in
>
> (?:\d\d\d\d\d)
>
> to match zip codes (example taken from *Mastering Regular Expressions*
> by Jeff Friedl, O'Reilly, 1997).
>
> Can anyone help? Thanks.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Hi JL Goldstein,
AFAIK this means that you are using non-capturing brackets, wich means,
that you where not interested in the zip code because you cannot use $n
(n = 1, ...) to get what you have caught in the brackets.
Ulrich
--
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925
mailto:uackermann@orga.com
------------------------------
Date: Thu, 24 Aug 2000 16:10:29 -0500
From: "Dietmar Staab" <dietmar.staab@t-online.de>
Subject: Re: $: in regular expressions
Message-Id: <8o3ad8$elj$13$1@news.t-online.com>
In article <8o38no$h5v$1@nnrp1.deja.com>, JL Goldstein
<jgoldst@my-deja.com> wrote:
> I've searched all my reference books, but I can't find out what $: means
> in a regular expression, as in
Can't find "$" in your regular expression.
$ matches at the end of the string (or line, if using /m modifier).
greetings, D.
------------------------------
Date: Thu, 24 Aug 2000 16:15:18 -0500
From: "Dietmar Staab" <dietmar.staab@t-online.de>
Subject: Re: $: in regular expressions
Message-Id: <8o3am8$r6s$12$1@news.t-online.com>
In article <8o3ad8$elj$13$1@news.t-online.com>, "Dietmar Staab"
<dietmar.staab@t-online.de> wrote:
> In article <8o38no$h5v$1@nnrp1.deja.com>, JL Goldstein
> <jgoldst@my-deja.com> wrote:
>> I've searched all my reference books, but I can't find out what $:
>> means in a regular expression, as in
>
> Can't find "$" in your regular expression.
> $ matches at the end of the string (or line, if using /m modifier).
(?:...) groups thinks like (...) but doesn't make backreferences like (...)
Greetings, D.
------------------------------
Date: Thu, 24 Aug 2000 11:58:12 +0100
From: "Graham Wood" <graham.wood@iona.com>
Subject: Re: @ARGV with ( and ) symbols in it
Message-Id: <8o2vh1$luf$1@bvweb.iona.com>
It was the shell. Thanks all.
Graham
Graham Wood <graham.wood@iona.com> wrote in message
news:8o0tt8$cjt$1@bvweb.iona.com...
> I'm attempting to write a script that will accept OS/390 dataset names and
> members thereof as input. The command line will look like:
>
> process.pl GWOOD.UTIL.JCL(STARTUP)
>
> Sadly perl is complaining that it is getting a "(" where it was expecting
a
> newline.
>
> Can anyone point me at the docs that will explain how to fool perl into
> accepting "(" and ")" as valid parts of a command line argument?
>
> I've had a look in perldoc perlvar and at perl -h but didn't see anything
> obvious there.
>
>
> Thanks
>
> Graham
>
>
------------------------------
Date: Thu, 24 Aug 2000 10:22:23 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage967112641.25225@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://www.cpan.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
For an alternative way to get answers, check out the Perlfaq website.
http://www.perlfaq.com/
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://www.cpan.org/
http://www.perl.com/CPAN/
http://www.cpan.org/doc/FAQs/FAQ/html/
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 24 Aug 2000 13:26:30 GMT
From: Hasanuddin Tamir <hasant@trabas.com>
To: bandung-pm-list@happyfunball.pm.org
Subject: A Proposal for BaseLib module
Message-Id: <8o37ph$g3j$1@nnrp1.deja.com>
NAME
BaseLib - manipulate @INC dynamically for independent installation
path
[WARNING: The module name is still subjected to change]
DESCRIPTION
BaseLib provides a simple and straightforward mechanism to
include private library path of an application set to @INC
independent of installation path. It optionally takes two
arguments, which also happen to be the keywords of this
module: BASEDIR and LIBDIR.
This module is intended for a set of application with certain
file and directory structure, not for ordinary single script
at general. The typical structure could be:
mail2sms/ -> base directory of the application
scripts/ -> where the scripts located, this directory
might have so many nested directories
libdir/ -> path of the private modules
others/ -> other directory
The usage is similiar to lib.pm,
use BaseLib qw(BASEDIR LIBDIR);
In the absence of the arguments, BaseLib will use the default
values: `appl_root' (subjected to change) and `lib' respectively.
For example, the structure is put under `/installation/path'.
Using lib.pm, all scripts need to say,
use lib '/installation/path/mail2sms/libdir';
What happens when the application is moved to, for example,
`/new/installation/path'? Of course, in order for it to work,
all scripts must be modified to refer to the new pat,
use lib '/new/installation/path/mail2sms/libdir';
OK, one may use environment variables, either the built in
ones (PERL5LIB and PERLLIB), or customized one, say, PRIVLIBDIR.
The scripts only need to say once,
use lib "$ENV{PRIVLIBDIR}";
or nothing at all if PERL5LIB/PERLLIB is used. But then
someone must be responsible to maintain the content of the
environment variables, either via global profile (assumming
unices), or, via web server conf (and don't forget to reload
or restart the server :-), each time the installation path
changes (Thanks to Steven Haryanto for providing this
examples.)
And what if during the development process, there are more
than one version at the same machine? Or there are multiple
developers with their own environment? So many changes need
to be done. Beside PERL5LIB and PERLLIB don't work with -T
switch.
This when BaseLib comes to rescue. All the scripts have to
say is,
use BaseLib qw(mail2sms libdir);
And no further tweaking is necessary, no matter how many
environments the application will run in. The scripts will
always be able to lookup to the right path to mail2sms/libdir
without having to care where mail2sms is put under. Well, as
long as no change on mail2sms and/or libdir.
As addition, BaseLib has a global package variable $BaseDir,
contains full path to the, unsuprisingly, base directory of
the application. This is not exported, so it must be qualified
with the package name to use it, e.g. $BaseLib::BaseDir.
AVAILABILITY
The module is currently available via URL,
http://www.zp.f2s.com/perl/modules/BaseLib-0.01.tar.gz
CAVEATS
At this very early stage, BaseLib lacks of many things:
* portability support
* checking the existence of the path in @INC
* include standard hierarchy style under LIBDIR
* more accommodative regex when untainting
* potentially broken if same name as base dir exists
* might be broken in mod_perl environment
* proper documentation
* good testing (only tested it few times myself)
Thanks for everyone's attention and/or comments.
Best regards,
--
san
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 24 Aug 2000 13:31:11 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: about CGI
Message-Id: <8o382v$geu$1@nnrp1.deja.com>
In article <39A4D636.6D3ED5FD@stomp.stomp.tokyo>,
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> Manuel Ho wrote:
<snip some off-topic crap>
> > how can i store files in user directories?
<snip some more off-topic moronic crap>
> > since i am 'nobody' when running in the webserver,
> > i can't change uid/gid to each user and put
> > the file there??! is there a way i can do it?
<snip even more off-topic moronic clueless crap>
> What you ask, is either unethical or illegal,
> without an owner's explicit permission.
Hey, dumbass, it is neither unethical, or illegal. Check out
Win32::NetAdmin or Win32::AdminMisc. These modules are designed
specifically for su-ing, just like IIS' integration with NT is designed.
Either get a clue, or shut up. Both solutions ask the user for a
>
> Godzilla!
>
#!perl
# Ask-a-troll.pl
# Godzilla! emulator
# usage: just call the script anytime you feel
# like you you're missing Godzilla!.
# print "Content-type: text/plain\n\n"; #Uncomment this for web use
print "Blah Blah Blah" x 1000000;
exit;
You freakin' idiot troll,
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 24 Aug 2000 15:41:46 +0200
From: "Roel Verbunt" <verbunroX@Xiquip.nl>
Subject: Can I call a C-function in an existing dynamic library from Perl?
Message-Id: <8o3879$1d4p$1@buty.wanadoo.nl>
I'm not a real Perl-guru. So I ran into the following problem:
I want to call a C-function in an existing shared library (.sl on HP-UX)
from Perl. Is this possible? Another problem is that we only have the .sl
file. So we don't have the C-sources.
I read something about XS-modules, but I did not really understand it. Is
there more doc about this than on CPAN.
Greets,
Roel
------------------------------
Date: Thu, 24 Aug 2000 15:33:42 +0200
From: Hermann FASS <hf@ses-astra.com>
Subject: Check array for an element
Message-Id: <39A52436.CEC1E3FE@ses-astra.com>
Not that there is no workaround, but I would like to
know an elegant way to check wether an element is
already contained in an array or not.
E.g. when parsing an access-log for making a list of authenticated
users:
($ip, $user) = /([\d\.]+\s+.*(\w+|-)..../;
if (! &alreadyPresent($user,@allUsers) ) {
push(@allUsers,$user);
}
The question is:
Did anybody write a good &alreadyPresent-subroutine,
which does not go through the complete @allUsers to
compare each singel element agains the current $user,
which seems time-consuming.
I thought about searching @allUsers in scalar context,
but there might be s.th. better, he?
Hermann
------------------------------
Date: Thu, 24 Aug 2000 10:09:06 -0400
From: Joe Kline <jkline@one.net>
To: Hermann FASS <hf@ses-astra.com>
Subject: Re: Check array for an element
Message-Id: <39A52C82.AC7FDF00@one.net>
[posted and mailed]
Hermann FASS wrote:
>
> Not that there is no workaround, but I would like to
> know an elegant way to check wether an element is
> already contained in an array or not.
<SNIP>
> which does not go through the complete @allUsers to
> compare each singel element agains the current $user,
> which seems time-consuming.
> I thought about searching @allUsers in scalar context,
> but there might be s.th. better, he?
Huh? At the very least you have to walk part of the list using
something like foreach with an if inside. Why not use grep?
So you're "stuck" with:
foreach my $test ( @allUsers)
{
print "found" if $test eq $user;
}
or
print grep { if $_ eq $user } @allUsers;
--
Joe Kline
It takes a lot of brains to enjoy satire, humor, and wit;
but none to be offended by them. ---The Midnight Skulker
------------------------------
Date: Thu, 24 Aug 2000 14:46:08 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Check array for an element
Message-Id: <MPG.140fd2a0d5f16b0b9896e5@localhost>
[ posted to comp.lang.perl.misc and CCed to jkline@one.net
and hf@ses-astra.com ]
Joe Kline <jkline@one.net> wrote ..
>[posted and mailed]
>
>Hermann FASS wrote:
>>
>> Not that there is no workaround, but I would like to
>> know an elegant way to check wether an element is
>> already contained in an array or not.
><SNIP>
>> which does not go through the complete @allUsers to
>> compare each singel element agains the current $user,
>> which seems time-consuming.
>> I thought about searching @allUsers in scalar context,
>> but there might be s.th. better, he?
>
>Huh? At the very least you have to walk part of the list using
>something like foreach with an if inside. Why not use grep?
>
>So you're "stuck" with:
>
>foreach my $test ( @allUsers)
>{
> print "found" if $test eq $user;
>}
>
>or
>
>print grep { if $_ eq $user } @allUsers;
test your code before posting .. you probably wanted
print grep { $_ eq $user } @allUsers;
but of course there are other (better) methods using hashes explained in
perlfaq4 "How can I tell whether a list or array contains a certain
element?"
perldoc -q "array.*element"
moreover perlfaq4 specifically says
Please do not use
$is_there = grep $_ eq $whatever, @array;
reasons are explained in the FAQ
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 24 Aug 2000 14:06:09 GMT
From: ptomsic@my-deja.com
Subject: File handling and manipulation from function, help please?
Message-Id: <8o3a45$ith$1@nnrp1.deja.com>
Could someone please help me with the following:
Open a file, and pass it to a function and when
it's in the function, run thru the file and strip
out predesignated text, and return the desired
text...like the following:
(this is what I've got, but it's not working)
---FILE---
#!/usr/local/bin/perl
open(TEST, "text.txt");
$string = <TEST>;
close(TEST);
print "\ncontents of file:$string";
&subCall($string); # looking to pass file to sub
print "\nnew contents:$string:";
exit(1);
sub subCall {
my($filename) = @_;
#get the text contained within a <!-BEGIN-><!-END-
> tag
$filename =~ s/\n//g;
$filename =~ s/<!-BEGIN->|<!-END->/|/ig; #case
insensitive for the tags
#hoping to return the contents within the tags
back to the caller
return $filename
}
----TEXT.TXT----
----(contains several line breaks)----
This is the testing<!-BEGIN->text from the
desired file.<!-END->This text here, is not
needed.
---END TEXT----
thanks in advance,
AK
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 24 Aug 2000 14:08:15 GMT
From: arvind_kuk@hotmail.com
Subject: File handling and manipulation from function, help please?
Message-Id: <8o3a81$iur$1@nnrp1.deja.com>
Could someone please help me with the following:
Open a file, and pass it to a function and when it's in the function,
run thru the file and strip out predesignated text, and return the
desired text...like the following:
(this is what I've got, but it's not working)
---FILE---
#!/usr/local/bin/perl
open(TEST, "text.txt");
$string = <TEST>;
close(TEST);
print "\ncontents of file:$string";
&subCall($string); # looking to pass file to sub
print "\nnew contents:$string:";
exit(1);
sub subCall {
my($filename) = @_;
#get the text contained within a <!-BEGIN-><!-END-> tag
$filename =~ s/\n//g;
$filename =~ s/<!-BEGIN->|<!-END->/|/ig; #case insensitive for the tags
#hoping to return the contents within the tags back to the caller
return $filename
}
----TEXT.TXT----
----(contains several line breaks)----
This is the testing<!-BEGIN->text from the
desired file.<!-END->This text here, is not needed.
---END TEXT----
thanks in advance,
AK
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 24 Aug 2000 10:45:10 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: File handling and manipulation from function, help please?
Message-Id: <39A534F6.CCD266A5@attglobal.net>
arvind_kuk@hotmail.com wrote:
>
> Could someone please help me with the following:
>
> Open a file, and pass it to a function and when it's in the function,
> run thru the file and strip out predesignated text, and return the
> desired text...like the following:
> (this is what I've got, but it's not working)
"Not working" does not help anyone know what exaxtly is happening,
what error you are getting, what is happening instead of what you
expect, etc. Also, you aren't doing anything to help yourself
discover possible errors.
> ---FILE---
> #!/usr/local/bin/perl
You forgot to use warnings, invoked with the -w switch. Also you
should use strict;
> open(TEST, "text.txt");
Here you don't check for failure of the open. Like so:
open TEST, "<text.txt" or die "Can't open: $!\n";
> $string = <TEST>;
Here you get the first line of the file. Did you want that? If not,
you need to do something like:
{ #begin bare block for scope
local $/ = undef;
$string = <TEST>;
}
> close(TEST);
> print "\ncontents of file:$string";
> &subCall($string); # looking to pass file to sub
> print "\nnew contents:$string:";
> exit(1);
>
> sub subCall {
> my($filename) = @_;
Better written (IMO) as my $filename = shift;
As it is right now, $filename is set to 1. Certainly not what you
want.
> #get the text contained within a <!-BEGIN-><!-END-> tag
> $filename =~ s/\n//g;
no newlines in 1 =)
> $filename =~ s/<!-BEGIN->|<!-END->/|/ig; #case insensitive for the tags
> #hoping to return the contents within the tags back to the caller
The regex does noting of the sort. After running through your two
expressions, the string is "This is the testing<!-BEGIN->text from the"
(Cause you only read the first line)
Odd, eh?
Looks like you need to rething that match.
> return $filename
> }
>
------------------------------
Date: Thu, 24 Aug 2000 10:35:00 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Flipflop matching
Message-Id: <MPG.140f97c5481009d99896e2@localhost>
philhibbs@my-deja.com <philhibbs@my-deja.com> wrote ..
>In article <8o1922$81m$2@slb6.atl.mindspring.net>,
> ebohlman@netcom.com (Eric Bohlman) wrote:
>> philip.hibbs@tnt.co.uk wrote:
>> It's called the range operator. See perlop for details.
>>
>That's the fellah! Thanks, I had tried looking it up, but I was lost for
>keywords to look up on, and perldoc isn't much use on Win95.
just one small question (although this thread is certainly exhausted by
now) .. what about perldoc isn't much use on Win95 ?
perldoc perlop
works perfectly well
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 24 Aug 2000 03:48:09 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Flipflop matching
Message-Id: <39A4FD69.907B6807@vpservices.com>
jason wrote:
>
> philhibbs@my-deja.com <philhibbs@my-deja.com> wrote ..
> >In article <8o1922$81m$2@slb6.atl.mindspring.net>,
> > ebohlman@netcom.com (Eric Bohlman) wrote:
> >> philip.hibbs@tnt.co.uk wrote:
> >> It's called the range operator. See perlop for details.
> >>
> >That's the fellah! Thanks, I had tried looking it up, but I was lost for
> >keywords to look up on, and perldoc isn't much use on Win95.
>
> just one small question (although this thread is certainly exhausted by
> now) .. what about perldoc isn't much use on Win95 ?
>
> perldoc perlop
>
> works perfectly well
Also grep 'foo' c:/path-to-perl-docs/* works perfectly well. (either a
perl grep or ppt grep or cygwin grep)
Also the windows "find" command against the same directories.
Also a browser's "find" command on the HTML versions of perldoc that
comes with activePerl.
--
Jeff
------------------------------
Date: Thu, 24 Aug 2000 13:43:33 +0200
From: Jean-Damien Bouvier <wokup.balr005@rd.francetelecom.fr>
Subject: fork
Message-Id: <39A50A65.8B03C1D6@rd.francetelecom.fr>
Hi all !
I discovered Perl since 2 days and i'm facing my first serious problem :
I want to launch a little java program from within my script and be able
to kill it later. As the fork function is not implemented (under NT but
the script have to work on both NT and Linux), I've no idea how to deal
with it.
Thanks for your help
--
Jean-Damien Bouvier
jd.bouvier@wokup.com
------------------------------
Date: Thu, 24 Aug 2000 23:31:23 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: fork
Message-Id: <slrn8qa8tb.5ap.mgjv@martien.heliotrope.home>
On Thu, 24 Aug 2000 13:43:33 +0200,
Jean-Damien Bouvier <wokup.balr005@rd.francetelecom.fr> wrote:
>
> I want to launch a little java program from within my script and be able
> to kill it later. As the fork function is not implemented (under NT but
> the script have to work on both NT and Linux), I've no idea how to deal
> with it.
fork is implemented on NT in perl 5.6.0. It is not a real
implementation, but an emulaiton using threads. Read the perlfork
documentation:
# perldoc perlfork
In other cases you may be able to use open with a pipe, and get the pid
from that (see the perlipc documentation), however it is possible that
that uses fork behind the scenes, and doesn't work on ActiveState perl
before 5.6.0 either.
Martien
--
Martien Verbruggen |
Interactive Media Division | I took an IQ test and the results
Commercial Dynamics Pty. Ltd. | were negative.
NSW, Australia |
------------------------------
Date: 24 Aug 2000 10:41:10 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: how can I optimize a tied hash for speed
Message-Id: <967112326.20843@itz.pp.sci.fi>
In article <slrn8q95ng.tj3.abigail@alexandra.foad.org>, Abigail wrote:
>That is not a reasonable benchmark. The drawback of using 'keys %hash'
>is the (possible) large list it generates, and hence the allocation of
>memory to store that list in. But, you pay that price once, the other
>4095 times, you are reusing the allocated memory.
..which is not necessarily a bad simulation of quite common real life
situations. Listing the keys of a huge hash, just like slurping in a
huge file, is so obviously a bad idea that I didn't consider it worth
pointing out - and in any case MJD had already said that. Traversing
a reasonably small hash only once, on the other hand, is not going to
make a noticeable difference in either speed or memory anyway.
The reason I had for writing the benchmark in the first place was the
assumption I'd had that each() in list context would be faster than a
normal hash lookup. Apparently, it isn't.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla | "By promoting postconditions to
and its pseudonyms - | preconditions, algorithms become
do not feed the troll. | remarkably simple." -- Abigail
------------------------------
Date: Thu, 24 Aug 2000 11:57:54 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: How to Include a Perl script in a Perl script
Message-Id: <39a80d1f.42963531@news.newsguy.com>
Albert Dewey <timewarp@shentel.net> wrote:
>At the very end of the
>script that you wish to require add this line of code -
>
>return 1;
>
>Trust me - you will need this . . . .
The conventional way is just
1;
Using return() is confusing because you're not in a subroutine
(and it would be lead to unexpected results if your require() is
actually inside a subroutine).
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Thu, 24 Aug 2000 15:14:15 +0200
From: Adam Skora <ventuno@gmx.de>
Subject: how to round ?
Message-Id: <39A51FA7.A9ABE958@gmx.de>
Does exist any function to round floating-point numbers ?
------------------------------
Date: Thu, 24 Aug 2000 23:41:14 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: how to round ?
Message-Id: <slrn8qa9fq.5ap.mgjv@martien.heliotrope.home>
On Thu, 24 Aug 2000 15:14:15 +0200,
Adam Skora <ventuno@gmx.de> wrote:
>
> Does exist any function to round floating-point numbers ?
If you ever find yourself wondering if a problem or question you have is
possibly a common one, and one encountered or asked by many other
people, then you should consult the Perl FAQ[0]. The FAQ is shipped with
each version of perl, and gets installed as part of Perl[1]. Perl also
ships with a utility that can be used to access said documentation on
almost all platforms[2]. You can even use it to read about perldoc
perldoc. Get yourself to a prompt, and type (without the prompt itself!):
# perldoc perl
# perldoc perldoc
# perldoc ModuleName
# perldoc perlfaq
# perldoc -f function
# perldoc -q question
C:\DOS\MENU> perldoc perldoc
Some installations of Perl, noteably the ActiveState one, come with a
HTML version of the documentation _as well as_ the original pod that
gets read by perldoc. It's probably accessible through your graphical
menu systems (on Win and derivates: start
menu->programs->activestate->help or something like that).
Now to your question:
# perldoc -q round
Found in /opt/perl/lib/5.6.0/pod/perlfaq4.pod
Does Perl have a round() function? What about ceil() and
floor()? Trig functions?
[SNIP]
I'll leave it up to you to repeat the above, and read the rest of the
entry for yourself.
Martien
[0] FAQ = Frequently Asked Questions (list)
[1] An installation of Perl without accompanying documentation is
generally not seen as a complete installation, and some would even call
it broken. I'm of the that category of people.
[2] I believe that Mac users don't have this command line thing that
everyone keeps talking about?
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | What's another word for Thesaurus?
NSW, Australia |
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 4117
**************************************