[11651] in Perl-Users-Digest
Perl-Users Digest, Issue: 5251 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 29 13:03:28 1999
Date: Mon, 29 Mar 99 10:00:22 -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 Mon, 29 Mar 1999 Volume: 8 Number: 5251
Today's topics:
Re: @ARGV question (Jonathan Stowe)
Re: Adding an $ENV variable? <aqumsieh@matrox.com>
Creating a LOL in an XSUB? <tf@cip.physik.uni-muenchen.de>
Datebase limitations and other Questions (Robert Saunders)
DOS system calls <bdaly@averstar.com>
Re: DOS system calls (Jonathan Stowe)
Re: How to redirect in new window? <aqumsieh@matrox.com>
Ibill scripts (URGENT) dsm_quake@my-dejanews.com
Re: Input Password (Greg Bacon)
Re: internal server error <aqumsieh@matrox.com>
module export not working (Jim and Paula)
Re: Need perl compiler (Larry Rosler)
Re: Newbie ques., clearing an array (Bart Lateur)
Perl tries to autoload packages that are already loaded <jsmith@mcs.drexel.edu>
Re: PWS, Win95, CGI and Perl <jonsmirl@mediaone.com>
Re: Q: redefined subroutines (M.J.T. Guy)
Re: qe:operation on binary files <loulou@ltt.ntua.gr>
Re: RE to match one line of Larry's quote <555034897s@acadiau.ca>
Re: sorting associative array by values (Abigail)
Re: sorting associative array by values (John Klassa)
Re: sorting associative array by values (Larry Rosler)
Re: system ('myproc &'); <aqumsieh@matrox.com>
Re: system ('myproc &'); <cassell@mail.cor.epa.gov>
undef values don't count in array length? <burton.not.spam@lucent.com>
Re: undef values don't count in array length? (Mark-Jason Dominus)
Use of uninitialized value at ... why? <fabascal@gredos.cnb.uam.es>
Re: Use of uninitialized value at ... why? <mamster@mamster.net>
Re: Very large float arrays and size problem <loulou@ltt.ntua.gr>
Re: Why am I stuck? <aqumsieh@matrox.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 29 Mar 1999 15:42:35 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: @ARGV question
Message-Id: <36ff9eb3.28562802@news.dircon.co.uk>
On Mon, 29 Mar 1999 16:54:24 +0200, Kamran Iranpour <kamran@norsar.no>
wrote:
>I am quite new to pearl and need some help.
>
>I am trying to split up ARGV into fields which later will be
>pushed into a hash. But I have problems splitting up the ARGV.
>Here is what I do:
>
>
>($id, $record) = split ' ', @ARGV, 2;
>
>and @ARGV is usually of this form :
>
>NOA__6C1 1999-088:08.44.24.000 accurate masked
>
>but I get nothing when I print the values of $id and $record out.
>
Why are you split on @ARGV like that - it is an array already. I think
you'll find that $ARGV[0] $ARGV[1] etc contain what you want.
/J\
------------------------------
Date: Mon, 29 Mar 1999 11:24:52 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Adding an $ENV variable?
Message-Id: <x3yzp4wqn58.fsf@tigre.matrox.com>
"Mike Watkins" <mwatkins@promotion4free.com> writes:
> I was just wondering, is there anyway to add a variable into the hash %ENV?
> What I want to do is what the .htaccess Authentication does, when it adds a
> $ENV{'REMOTE_USER'} variable to each person who logs in.
>
> I need the variable to "stick" though, after the script has finished running
> its process. It's for a control panel, so when a member logs in, the script
> will add his username into the %ENV hash, and that variable will remain
> there for everytime the member does something within the panel for that
> session.
>
> Any ideas?
yeah .. in perlfaq8, you can find:
I {changed directory, modified my environment} in a perl
script. How come the change disappeared when I exited the
script? How do I get my changes to be visible?
Also, how about dumping whatever you want into a file, which your
script can read everytime it runs, and updates its %ENV hash?
Any security holes with that?
HTH,
Ala
------------------------------
Date: 29 Mar 1999 17:00:29 +0200
From: Thomas Fischbacher <tf@cip.physik.uni-muenchen.de>
Subject: Creating a LOL in an XSUB?
Message-Id: <5nhfr4pche.fsf@glockner.cip.physik.uni-muenchen.de>
Dear perl hackers,
I have a problem where it would be very convenient to return a "list
of lists" (Of structure [[1,2,3],[4,5,6],[7,8,9]]) from within an
XSUB.
I tried a rather straightforward implementation and promptly fell onto
my nose; the code is a memory leak, but as far as I can tell, the
reference structure as well as the reference counts are set
right. Very strange.
Here my code:
build_simple() seems to work find and introduce no memory leak. (Good,
this means I can build and return array references in an XSUB.)
build_array(), however, is another matter. But as far as I can tell,
the standard perl documentation doesn't mention anything I should do
in a different way to produce correct behaviour. I'm rather
stuck. Could anyone be so kind as to tell me what's wrong here.
(refcount_referred_obj() may be ignored. I use it for testing.
(Well, erm, I use all this code for testing only.))
Atest.xs
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include <stdlib.h>
#include "XSUB.h"
#ifdef __cplusplus
}
#endif
MODULE = Atest PACKAGE = Atest
void
build_simple(a)
int a
PREINIT:
int i;
AV *arr;
PPCODE:
arr=newAV();
av_extend(arr,a);
for(i=0;i<a;i++)
{
if(0==av_store(arr, i, newSViv(i)))exit(1);
}
EXTEND(sp,1);
PUSHs(sv_2mortal(newRV_noinc((SV *)arr)));
void
build_array(a,b)
int a
int b
PREINIT:
int i, k;
AV *a_inner, *a_outer;
SV *aref_inner, *aref_outer;
PPCODE:
a_outer=newAV();
av_extend(a_outer, a);
for(i=0;i<a;i++)
{
a_inner=newAV();
av_extend(a_inner, b);
for(k=0;k<b;k++)
{
if(0==av_store(a_inner, k, newSVnv((double)(i+1)*(k+1)))) exit(1);
}
aref_inner=newRV_noinc((SV *)a_inner);
if(0==av_store(a_outer, i, aref_inner)) exit(1);
}
EXTEND(sp,1);
aref_outer=newRV_noinc((SV *)a_outer);
PUSHs(sv_2mortal(aref_outer));
int
refcount_referred_obj(...)
CODE:
RETVAL=SvROK(ST(0))?SvREFCNT((SV *) (SvRV(ST(0)))) : -SvREFCNT((SV *)(ST(0)));
OUTPUT:
RETVAL
--
regards, tf@cip.physik.uni-muenchen.de (o_
Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\
(lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y) V_/_
(if (= x 0) y (g g (- x 1) (* x y)))) n 1))
------------------------------
Date: Mon, 29 Mar 1999 17:48:50 GMT
From: robert@iminet.com (Robert Saunders)
Subject: Datebase limitations and other Questions
Message-Id: <7592241E71DAD9CD.D54D73531C54E52D.1B7E161CBC53300E@library-proxy.airnews.net>
I have a opportunity to lead up a team to write a program that will be
web based, and do something like free web pages.. the database will
need to handle about a million users..
My question would be what are the limitations of Perl.. and would a
flat file or a database file work with perl and handle that kind of
traffic or would I need to look at another language or solution, I am
a programmer of perl.. but not at this level.
And I am not even sure perl would be the best language to do a project
of this size..
Any ideas on limitations, or what kind of machines that I should be
running for a application like this.. currently most of the systems I
run are on a linux box usually a Pentium type of computer..
Please email me at robert@iminet.com with any ideas or solutions..
Robert
------------------------------
Date: Mon, 29 Mar 1999 15:40:08 GMT
From: Bob Daly <bdaly@averstar.com>
Subject: DOS system calls
Message-Id: <36FF9ED8.BC71FCD@averstar.com>
Is it possible to call MS Word in a Perl script?
I want to write form data to a text file and then use that file to
generate a Word doc on the fly with mail merge. This obviously requires
the ability to execute specific commands in Word, and I can't find any
information on how to do it if it's possible.
Thank you...
Bob Daly
------------------------------
Date: Mon, 29 Mar 1999 15:59:31 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: DOS system calls
Message-Id: <36ffa33f.29726686@news.dircon.co.uk>
On Mon, 29 Mar 1999 15:40:08 GMT, Bob Daly <bdaly@averstar.com> wrote:
>Is it possible to call MS Word in a Perl script?
>
>I want to write form data to a text file and then use that file to
>generate a Word doc on the fly with mail merge. This obviously requires
>the ability to execute specific commands in Word, and I can't find any
>information on how to do it if it's possible.
>
Win32::OLE is probably what you want to be looking at ...
/J\
------------------------------
Date: Mon, 29 Mar 1999 10:39:45 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: How to redirect in new window?
Message-Id: <x3y3e2os3su.fsf@tigre.matrox.com>
bruce <bruce@reedcommunications.com> writes:
> --------------C8AEB0F11701564A7F00F671
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
usenet is a text only medium.
> I think the question that should have been asked was, "How do I get my
> Perl
> script to redirect a visitor to a new browser window instead of the
> active
> window?". I would like to know to do that also.
Of course, this has nothing to do with Perl. You'll find the answer in
the proper HTML docs.
HTH,
Ala
------------------------------
Date: Mon, 29 Mar 1999 15:48:12 GMT
From: dsm_quake@my-dejanews.com
Subject: Ibill scripts (URGENT)
Message-Id: <7do7bp$bc6$1@nnrp1.dejanews.com>
Hi !I need URGENTLY a script to manage Ibill's username/password lists. I saw
the resource center but the demos are limited, and I'm finding a scriptto: -
Add the list (with username/password pair data delimited by ",") to .htpasswd
- Count used and remain - Allow to disable an account - If possible, allow to
include a "database" of expirations, to automatically delete from .htpasswd
users no longer valid. - Allow to "massive deletion" of expired users from a
txt based file (maybe like the one received from Ibill). I don't see demos
about this, and I can't buy any script if I cannot test it in my real
work.THANKS FOR YOUR HELP !!!!
Daniel......
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 29 Mar 1999 15:08:53 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Input Password
Message-Id: <7do525$g4o$2@info2.uah.edu>
In article <7dj28v$132$1@gemini.ntu.edu.tw>,
Huang Lee <hlee@ccserv2.ee.ntu.edu.tw> writes:
: but now,if I want to add another function like "Press any key to stop".
: I mean I can input "one key" without ENTER.
: and the program will not stop.until I type something....
: what should I do....(Under telnet mode,I am server on unix)
Give the client these suggestions
IAC DONT LINEMODE
IAC WILL ECHO
(The LINEMODE option is documented in RFC 1184.) Assuming it agrees
to both of these, send your prompt and the next data character you
receive (make sure it's not a command sequence, though!) will be the
character the user entered. With most of the telnet clients I've seen
(in fact, I can't think of any that don't behave this way), it's
sufficient to successfully negotiate control of echoing for the client
to put the client in character-at-a-time mode. However, these
semantics aren't guaranteed by RFC 857, so you might want to be more
careful.
This thread is straying pretty widely of Perl, so I've set followups.
Greg
--
In theory there is no difference between theory and practice. In practice,
there is.
------------------------------
Date: Mon, 29 Mar 1999 09:58:05 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: internal server error
Message-Id: <x3y4sn4s5qa.fsf@tigre.matrox.com>
Lars Plessmann <larsplessmann@gmx.de> writes:
> I create my perl scripts in windows. The are running without any problem
> on my Sambar Server 4.1
> When I trie to execute them on Linux, there is an error message
> "internal server error". What's wrong with my perl script?
What happened when you ran them from the command line?
------------------------------
Date: Mon, 29 Mar 1999 15:59:21 GMT
From: gemhound@gemhound.com (Jim and Paula)
Subject: module export not working
Message-Id: <36ffa351.4760808@news.primeline.com>
I'm trying to learn how to make modules. I used the standard h2xs
program and created one called cvthtml, that presently just says
"hello" for testing. I'm exporting and preloading the sub, as per
below -- the rest just being the autogenerated boilerplate, which
should be okay:
@EXPORT = qw( sayHello);
$VERSION = '1.00';
# Preloaded methods go here.
sub sayHello { print "\nHello, sucker!\n"; }
I also ran makefile.pl as directed in the directory where cvthtml is,
and it returned a-okay, although I'm not quite sure whate makefile.pl
is for.
The trouble is, sayHello only works in the calling program when I
qualify it totally in my program. i.e. even if my program has
use cvthtml;
in it I have to say
cvthtml::sayHello()
to get sayHello() to work. If I just use a bare sayHello() I get a
subroutine undefined message. Why isn't sayHello being exported into
my namespace?
I'm using ActivePerl for Win 32, which I think also does things a
little differently than the books I'm using. I know I had to do
perl makefile.pl which generated makefile. I have a feeling there is
a step after that, since makefile is just sitting there, but I can't
find any exes that do anything with it. I tried typing Make, but
there is no such executable anywhere in the activestate dist that I
can find. I'm a bit fuzzy on makefiles, as it's been thirty years
since I did any substantive programming and that was in cobol.
------------------------------
Date: Mon, 29 Mar 1999 06:56:11 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Need perl compiler
Message-Id: <MPG.1169346776c0e40c9897ea@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7dnhk7$p2n$1@nnrp1.dejanews.com> on Mon, 29 Mar 1999
09:37:12 GMT, ahoben@globeaccess.net <ahoben@globeaccess.net >says...
> Who can help me have a freeware perl compiler for ibm compatible pc
Go to http://www.activestate.com and download ActivePerl.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 29 Mar 1999 15:06:39 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Newbie ques., clearing an array
Message-Id: <36ff9561.22085122@news.skynet.be>
Neil Cherry wrote:
>1) How does one clear an array after it's bee filled?
Use smoke. That ought to take the sting out of them.
Bart.
------------------------------
Date: Mon, 29 Mar 1999 12:07:01 -0500
From: Justin R. Smith <jsmith@mcs.drexel.edu>
Subject: Perl tries to autoload packages that are already loaded!
Message-Id: <922727389.1069273271@news.icdc.com>
When I try to use a package in another, perl tries to autoload the functions in
it (even though the entire package has already been 'required').
In particular, I'm trying to use the Postgres package in another package
(as well as in 'mainwithout any success (I get an error message saying that
Tk::Error: Can't locate auto/Postgres/execute.al in @INC (@INC contains:
/usr/lib/perl5/5.00502/i686-linux-thread /usr/lib/perl5/5.00502
/usr/lib/perl5/site_perl/5.005/i686-linux-thread /usr/lib/perl5/site_perl/5.005
) at nexam.pl line 1696
[\&main::displayques,\137716704,\\137741624,\0,{},{},{}] ')
Any suggestions?
------------------------------
Date: Mon, 29 Mar 1999 11:18:52 -0500
From: "Jon Smirl" <jonsmirl@mediaone.com>
Subject: Re: PWS, Win95, CGI and Perl
Message-Id: <WHNL2.12419$_A2.38422@lwnws01.ne.mediaone.net>
I couldn't figure out exactly what registry entry PWS wanted so I made both
a string and a key with the default set for .pl and .plx. C:\perl\bin must
be on your path.
Stick with it, this setup can definitely be made to work. I'm not sure I
ever got .pl working but I know I got .plx working.
--
Jon Smirl
jonsmirl@mediaone.net
Robzenuk <robzenuk@aol.com> wrote in message
news:19990329092206.04694.00001898@ng13.aol.com...
> Thanks for the help, I appreciate the quick response.
>
> I had tried to follow the instructions in the perlwin32faq6 that suggested
the
> same thing.
>
> In regedit.exe on Windows95 I went to:
>
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters\Script
> Map
>
> Using Edit/New/String Value, I mapped:
>
> .pl => c:\perl\bin\perl.exe
> .plx => c:\perl\bin\perlIS.dll
>
> Initially, this made no difference. After a reboot the browser just went
out
> to lunch waiting for the response. This happened with both GET and POST.
>
> I had already set the execute and script permissions in cgi-bin directory.
>
> I have been using Perl successfully for quite a while. I'm new to using
and
> posting to the newsgroups and wonder if I'm not posting to the right
place. Is
> there somewhere else that may be more appropriate for this kind of post
(and/or
> research)?
>
> I already found a link in another posting to
> http://www.btinternet.com/~gellyfish/docs/map.html
> This contains a lot of detailed information on all the PWS registry
entries.
>
> I'm hoping someone has a cookbook for this or I'm just missing something
really
> obvious...
>
> Thanks,
>
> Rob
------------------------------
Date: 29 Mar 1999 17:46:43 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Q: redefined subroutines
Message-Id: <7doea3$gnp$1@pegasus.csx.cam.ac.uk>
Peter John Acklam <jacklam@math.uio.no> wrote:
>
>Thanks for the reply, but the code I gave was actually all there was.
>And I get the same even when I use just an EMPTY one-liner:
>
> c:\> perl -MFile::Spec -MDirhandle -we ""
^
H
> Subroutine new redefined at E:\PERL\lib/Dirhandle.pm line 32.
> Subroutine DESTROY redefined at E:\PERL\lib/Dirhandle.pm line 43.
> (...)
Perl module names are case sensitive. You're loading the module
DirHandle.pm (indirectly from File::Spec), which defines subroutines
in the package DirHandle. Then you're trying to load the non-existent
module Dirhandle.pm. On a Unix system, that would give an error.
But because you've got a PoB filing system, it spuriously tries to load
an inappropriate file, which redefines the subroutines as you see.
Mike Guy
------------------------------
Date: Mon, 29 Mar 1999 20:21:48 +0300
From: Costis Angelis <loulou@ltt.ntua.gr>
To: Nir Leshem <nirl@zoran.co.il>
Subject: Re: qe:operation on binary files
Message-Id: <36FFB6AC.9A6099DE@ltt.ntua.gr>
Nir Leshem wrote:
> hi there
> i wonder if anyone can help me:
> i need to bitswap each word in a binary file
> (i.e 0000_0000_0000_0001 becomes 1000_0000_0000_0000)
> how can i do that on a binary file without the trivial solution of
> translating it into ASCII?????
>
I am not very experienced, almost not at all, but having faced a similar
situation recently, check reverse in a scalar context. I could be all
wrong
of course.
Costis
----
Costis Angelis
cangelis@hpc.ntua.gr <-- Preferred
loulou@ltt.ntua.gr
>
> thanks
> nir.
> --
> --------------------------------------------------------------------
> Nir Leshem
> VLSI group E-mail nirl@zoran.co.il
> ZORAN Microelectronics LTD Tel : 972-4-8545911
> Advanced Technology Center Fax : 972-4-8551550
> P.O.B. 2495, Haifa 31204, Israel www : http://www.zoran.com
> --------------------------------------------------------------------
------------------------------
Date: Mon, 29 Mar 1999 13:13:45 -0400
From: Tong <555034897s@acadiau.ca>
Subject: Re: RE to match one line of Larry's quote
Message-Id: <36FFB4C9.112C3EFB@acadiau.ca>
My questions are all because of my misunderstanding, both Perl and
English. :-( Sorry for that. Thank you Tad for patiently pointed them
all out and show me the right direction, and thanks Sam too. Now with
all your help and clarification, I played with Perl RE again and
succeeded this time.
I've made greate improvement because of all your help, including Tad.
Thanks again!
--
Anti-Spam: Remove triple 5 to reply
------------------------------
Date: 29 Mar 1999 16:48:41 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: sorting associative array by values
Message-Id: <7doat9$j1f$1@client2.news.psi.net>
Hojoo Moon (hjmoon@netsgo.com) wrote on MMXXXVI September MCMXCIII in
<URL:news:1q6Jxoae#GA.273@news3.netsgo.com>:
`` Hello, help me, please.
``
`` Does anybody know how to sort an associative array by values?
`` I know there is a way sorting an associative array by indexes:
`` sort keys(%arrary)
No, that doesn't sort the hash. It sorts the keys of the hash.
`` But I would like to get an easy way to sort:
`` (apple 7, pear 15, mellon 5) ==> (pear 15, apple 7, mellon 5)
You can do that [1], but that doesn't make much sense. It won't help you
much either.
Suppose I make two hashes, like this:
%hash1 = (apple => 7, pear => 15, mellon => 5);
%hash2 = (pear => 15, apple => 7, mellon => 5);
What do think their difference will be?
[1] map {@$_}
sort {$_ -> [1] <=> $b -> [1]}
map {[$_, $hash {$_}]}
keys %hash;
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
------------------------------
Date: 29 Mar 1999 16:37:59 GMT
From: klassa@aur.alcatel.com (John Klassa)
Subject: Re: sorting associative array by values
Message-Id: <7doa97$egb$1@aurwww.aur.alcatel.com>
% man perlfaq4
--
John Klassa / Alcatel / Raleigh, NC, USA / $pm{Raleigh}[0] / \/\/&/\/\ / <><
------------------------------
Date: Mon, 29 Mar 1999 09:20:27 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sorting associative array by values
Message-Id: <MPG.11695635ee03702d9897eb@nntp.hpl.hp.com>
In article <7doat9$j1f$1@client2.news.psi.net> on 29 Mar 1999 16:48:41
GMT, Abigail <abigail@fnx.com >says...
...
> [1] map {@$_}
> sort {$_ -> [1] <=> $b -> [1]}
> map {[$_, $hash {$_}]}
> keys %hash;
There is a typo in the sort comparison. In any case, isn't this
Schwartzian Overkill? I get the identical output with simply this:
map {$_, $hash{$_}}
sort {$hash{$a} <=> $hash{$b}}
keys %hash;
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 29 Mar 1999 10:46:06 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: system ('myproc &');
Message-Id: <x3y1zi8s3i9.fsf@tigre.matrox.com>
sstarre@my-dejanews.com writes:
> system('myproc); #executes and the calling process waits for it to finish
>
> system('myproc &'); #should start my proc in the bg and return. it doesn't-
> instead it behaves just like the first case.
>
> I'll ask it another way - "why do these two calls behave the same?"
They don't. At least for me they don't.
The first one waits for myproc to finish. The second starts it in the
bg and returns, as you expect.
I can't think of why it is behaving differently from your end. What
kind of program is 'myproc'? Could it be the problem?
HTH,
Ala
------------------------------
Date: Mon, 29 Mar 1999 09:51:00 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: system ('myproc &');
Message-Id: <36FFBD84.6D5B6E6A@mail.cor.epa.gov>
sstarre@my-dejanews.com wrote:
>
> I'm not a "he", I did read Camel sections on exec, system, and fork, and I'm
> programming on a unix system, and I hate u-soft. Other than those few errors
> you've got me pegged!
Boy, that tchrist is already more accurate than Jean Dixon. I'd be worried
that right now he's divining your street address. :-)
> system('myproc); #executes and the calling process waits for it to finish
>
> system('myproc &'); #should start my proc in the bg and return. it doesn't-
> instead it behaves just like the first case.
>
> I'll ask it another way - "why do these two calls behave the same?"
Because the Camel says so. Really. Under 'system' it says:
"..it runs the program for you,and returns when it's done..."
I think what you want is to fork a child process to run off on its own, like
a daemon. Well, that's my guess anyway. And I'm *not* Jean Dixon. :-)
Check out perlfaq8, question "How do I fork a daemon process?" I think
that's what you want.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Mon, 29 Mar 1999 10:57:51 -0600
From: Burton Kent <burton.not.spam@lucent.com>
Subject: undef values don't count in array length?
Message-Id: <36FFB10F.C0E95F13@lucent.com>
I am trying to get the number of fields in a '~' separated
list. When I use "split", if any of the fields at the end
of the string are empty, they are omitted from the field
count.
Example code:
$string = "first~second~third";
print "Fields in $string: " . scalar(split /\~/, $string);
shows this: Fields in first~second~third: 3
$string = "first~~";
print "Fields in $string: " . scalar(split /\~/, $string);
shows this: Fields in first~~: 1
$string = "~~third";
print "Fields in $string: " . scalar(split /\~/, $string);
shows this: Fields in ~~third: 3
What I want is a field count of 3, even if the fields are
all empty.
Any ideas?
Thanks.
Burton
------------------------------
Date: Mon, 29 Mar 1999 17:14:26 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: undef values don't count in array length?
Message-Id: <7doccf$jsb$1@monet.op.net>
In article <36FFB10F.C0E95F13@lucent.com>,
Burton Kent <burton.not.spam@lucent.com> wrote:
>I am trying to get the number of fields in a '~' separated
>list. When I use "split", if any of the fields at the end
>of the string are empty, they are omitted from the field
>count.
The manual page for split says that by default trailing null fields
are omitted.
It also says how to prevent this if it si not what you want.
>Any ideas?
Look up `split' in the manual.
------------------------------
Date: Mon, 29 Mar 1999 17:34:47 +0100
From: Federico Abascal <fabascal@gredos.cnb.uam.es>
Subject: Use of uninitialized value at ... why?
Message-Id: <36FFABA6.EF06B727@gredos.cnb.uam.es>
Hello, Does anybody know why this code
my($buffer) = "";
my($someVariable) = "";
my($inputFile)=$ARGV[0];
local(*iFhandle);
open(iFhandle, $inputFile);
$someVariable=<iFhandle>;
while(<iFhandle>) {
$buffer = $_;
if($buffer =~ /^>/ || eof(iFhandle)) { ......
.......
.......
}
}
"perl -w" says "Use of uninitialized value at iss.pl line xxxx (the one
of eof()), <iFhandle> chunk 2."??
I would like to understand it, so thanks for your answers,
Fede
------------------------------
Date: Mon, 29 Mar 1999 12:21:55 -0500
From: Matthew Amster-Burton <mamster@mamster.net>
Subject: Re: Use of uninitialized value at ... why?
Message-Id: <Pine.GSO.3.96.990329121326.15802A-100000@wired.your-site.com>
On Mon, 29 Mar 1999, Federico Abascal wrote:
> Hello, Does anybody know why this code
There's a lot of trouble here. Let's have a look.
> my($buffer) = "";
my $buffer;
Putting parentheses around $buffer puts it into array context, which is
not what you want. And assigning it the empty string is redundant.
> my($someVariable) = "";
> my($inputFile)=$ARGV[0];
The usual way to write this is:
my $inputFile = shift;
> local(*iFhandle);
Why are you localizing this? It's probably not what you want.
> open(iFhandle, $inputFile);
Test the open and use upper-case names for filehandles.
open IFHANDLE, $inputFile or die "Couldn't open $inputFile: $!";
> $someVariable=<iFhandle>;
Are you trying to discard the first line here? Because $someVariable
doesn't get used later.
> while(<iFhandle>) {
> $buffer = $_;
> if($buffer =~ /^>/ || eof(iFhandle)) { ......
> .......
> .......
> }
> }
Why waste the magical $_?
while( <iFhandle> ) {
if( /^>/ ) { ... }
}
The test for EOF is already done in the condition of the while loop.
> "perl -w" says "Use of uninitialized value at iss.pl line xxxx (the one
> of eof()), <iFhandle> chunk 2."??
Probably because you didn't test the open.
Good luck,
Matthew
------------------------------
Date: Mon, 29 Mar 1999 20:18:24 +0300
From: Costis Angelis <loulou@ltt.ntua.gr>
Subject: Re: Very large float arrays and size problem
Message-Id: <36FFB5DF.528453BB@ltt.ntua.gr>
Jonathan Feinberg wrote:
> Costis Angelis <loulou@ltt.ntua.gr> writes:
>
> > It seems like perl requires something of the order of 40 or 50 bytes
> > to store just one number.
>
> You're right to an order of magnitude. Check out sv.h in the perl
> source. A scalar uses a bare minimum of eight bytes (one U32 for the
> ref count, one for flags), plus a pointer to the actual data (that's
> another four bytes on my box), and then allocates further space
> depending on the data. Numbers are stored as doubles (unless you ask
> otherwise with a pragma), so there's 8 more bytes for you off the bat,
> for a total of twenty. I couldn't quite follow the perl source for
> the workings of arrays, but one could imagine additional overhead per
> item.
>
So it seems like there is not much I can do to minimise memory usage.
However,
it seems very probable to me that there must be a way to at least reduce
it.
Thank you for the information, though I do not intend to dive any deeper
than this (checking perl source code for example). I'm a mechanical
engineer,
not a software one, thus my abilities are limited. Perhaps I will just
have to
parse my files many times, one for each field. Not optimal, but better
than
swapping out (as will happen with a more typical case than the small one
I work
on at the moment).
Still open to suggestions, of course, and thank you again.
Costis
----
Costis Angelis
cangelis@hpc.ntua.gr
>
> Corrections and clarifications from Ilya, Chip et al. gratefully
> accepted.
>
> --
> Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
> http://pobox.com/~jdf
------------------------------
Date: Mon, 29 Mar 1999 11:35:16 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Why am I stuck?
Message-Id: <x3yyakgqmnx.fsf@tigre.matrox.com>
Ophir Marko <ophir@saifun.com> writes:
>
> #! /local/perl/bin/perl -w
> $file = <ARGV>;
This reads the first line of the first file specified in your argument
list. If nothing was specified in your argument list, it reads the
first line of user input.
I believe this is not what you want. You want $file to be the first
argument you specify in your command line.
$file = shift || die "Must supply a file name.\n";
> open(FILE, "$file");
You should ALWAYS test to see if open() succeeded or not:
open FILE, $file or die "Couldn't open $file: $!\n";
> @lines = <FILE>;
> split @lines;
What is the above supposed to do?
It should generate a warning for you since you are using '-w'.
> $i=0;
> open(FILE2, ">file");
Again, check for the result of open().
> while ($lines[$i] = "abc"){
This will ALWAYS set $lines[$i] to "abc". Is that what you want?
What are you trying to do?
> print FILE2 $line[$i];
> ++$i;
> }
> close FILE;
> close FILE2;
>
> For some reason, the script continues in an infinite loop. I think it's
> the ++i$ ?
It probably is. You are reading lines into @lines from a file. Then
you are overwriting that data with "abc" everywhere. You are also
creating an infinite-sized array whose elements are all the same. It
won't be too long before your system crashes due to memory shortage
(that depends on your system ofcourse).
What is your script supposed to do? Did you try to address the warning
messages at least? Did you check each line of your code to see
whether it does what you expect it to do? Did you read the Llama book?
Please do all of the above, try again, and let us know if you have any
more problems.
HTH,
Ala
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5251
**************************************