[7279] in Perl-Users-Digest
Perl-Users Digest, Issue: 904 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 22 11:18:54 1997
Date: Fri, 22 Aug 97 08:00:27 -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 Fri, 22 Aug 1997 Volume: 8 Number: 904
Today's topics:
Re: "-T" problem after building 5.0004_01 (Andrew M. Langmead)
Assinging values of HASH in to Array <ajiteshd@wiproge.med.ge.com>
Re: Assinging values of HASH in to Array <jpm@iti-oh.com>
Re: Assinging values of HASH in to Array <sfairey@adc.metrica.co.uk>
Compiling perl5.004.01 on solaris 2.5.1 <pmcpartl@motown.lmco.com>
Re: defined(<file>) bumps handle in perl5.004_1? (Andrew M. Langmead)
Re: delayed execution of a program?? (Daniel E. Macks)
Re: emacs? No thank you (Mark Cartwright)
Re: Error 49 in SDBM store -- what does it mean? (M.J.T. Guy)
Re: Error 49 in SDBM store -- what does it mean? (Michael Schuerig)
foreach and arrays denis@mathi.uni-heidelberg.de
Re: foreach and arrays <sfairey@adc.metrica.co.uk>
Re: foreach and arrays <tom@mitra.phys.uit.no>
Re: Help with catman/makewhatis <tom@mitra.phys.uit.no>
HELP!!!...Redirect output 2....... <devli002@gold.tc.umn.edu>
Re: Help: Is there a way to get disk and CPU usage usi <beadles@nt.com>
Re: How do I find the system date/time? <dewolf@teleport.com>
Re: How do I find the system date/time? <flavell@mail.cern.ch>
How to do: $object->$method(@args) <wiedmann@neckar-alb.de>
Re: How to do: $object->$method(@args) <tom@mitra.phys.uit.no>
Re: How to do: $object->$method(@args) (Andreas Schmidt)
Re: I have a forking problems <seay@absyss.fr>
Re: if (/htm/ && !/html/) { (robert)
Re: if (/htm/ && !/html/) { <seay@absyss.fr>
pack & format <dantin@icp.grenet.fr>
Perl & Shadow Passwords authentitacion. ldeath@seade.gov.br
Perl in EXE <serginho@mail.serve.com>
Re: Perl script calling an html file? (Robby)
reading a gz file <bb@b-b.nl>
Re: Reading in a file for use... <seay@absyss.fr>
Re: shell command "more" (Andrew M. Langmead)
Re: shift <ajiteshd@wiproge.med.ge.com>
Re: Substitution string problem (Matti Kinnunen)
Syntax Question <bob.buehler@cpa.state.tx.us>
Re: TCL 8.0: A whole lot of perl <tom@mitra.phys.uit.no>
Re: undeclared variables ??? (Andrew M. Langmead)
WILL PAY for help and or development work (Robby)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 22 Aug 1997 13:31:55 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: "-T" problem after building 5.0004_01
Message-Id: <EFBHL8.Htt@world.std.com>
Raymond W Yu <rayyu@cup.hp.com> writes:
>% perl -c hello.pl
>Too late for "-T" option at hello.pl line 1.
>This error message appears for every script with "-T" option.
>However, I can run hello.pl without any problem, except I can
>do perl -d hello.pl.
Every diagnostic message that comes from perl (and a few that don't
but are mistaken as perl errors by novices) is contained in the
perldiag man page. This is what it says about your error:
> Too late for '-T' option
> (X) The #! line (or local equivalent) in a Perl script
> contains the -T option, but Perl was not invoked with
> -T in its command line. This is an error because, by
> the time Perl discovers a -T in a script, it's too
> late to properly taint everything from the
> environment. So Perl gives up.
>
> If the Perl script is being executed as a command
> using the #! mechanism (or its local equivalent),
> this error can usually be fixed by editing the #! line
> so that the -T option is a part of Perl's first
> argument: e.g. change perl -n -T to perl -T -n.
>
> If the Perl script is being executed as perl
> scriptname, then the -T option must appear on the
> command line: perl -T scriptname.
So in your case, if you put
#!/usr/bin/perl -T
as your shebang line, then
perl -Tc hello.pl
will work to invoke the script.
--
Andrew Langmead
------------------------------
Date: Fri, 22 Aug 1997 16:14:05 -0530
From: Ajitesh Das <ajiteshd@wiproge.med.ge.com>
To: petri.backstrom@icl.fi
Subject: Assinging values of HASH in to Array
Message-Id: <33FE0825.15FB@wiproge.med.ge.com>
All,
I have a query...
Is there any way to assign values ( NOT KEYS ) in to an array.
whatta I want to mean
something like that :
@my_array = some_buildin_function_gets_values( %my_Hash );
let me know if there is any
Thanks in advance
> One way to sort by key:
>
> foreach ( sort keys %ENV ) {
> print "Key $_ has a value of $ENV{$_}\n";
> }
>
> See also, e.g., the frequently asked question (FAQ):
>
> "How do I sort a hash (optionally by value instead
> of key)?"
>
> You can find the FAQ through
>
> http://www.perl.com/FAQ/
>
> regards,
> ...petri.backstrom@icl.fi
> ICL Data Oy
> Finland
--
Rgds
Ajitesh
----
Ajitesh Das ajiteshd@wiproge.med.ge.com
---
"Golden Rule: never derive from a concrete class "
------------------------------
Date: Fri, 22 Aug 1997 09:30:34 -0400
From: Joshua Marotti <jpm@iti-oh.com>
Subject: Re: Assinging values of HASH in to Array
Message-Id: <33FD947A.F8ED148C@iti-oh.com>
Ajitesh Das wrote:
> All,
> I have a query...
> Is there any way to assign values ( NOT KEYS ) in to an array.
> whatta I want to mean
> something like that :
> @my_array = some_buildin_function_gets_values( %my_Hash );
How about using the 'values' command (same as 'keys' but gets the
values).
@my_array = values %hash;
Kinda simple, eh?
Hope this helps,
-Josh
------------------------------
Date: Fri, 22 Aug 1997 14:36:16 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Ajitesh Das <ajiteshd@wiproge.med.ge.com>
Subject: Re: Assinging values of HASH in to Array
Message-Id: <33FD95D0.1372@adc.metrica.co.uk>
Ajitesh Das wrote:
>
> All,
> I have a query...
> Is there any way to assign values ( NOT KEYS ) in to an array.
> whatta I want to mean
> something like that :
> @my_array = some_buildin_function_gets_values( %my_Hash );
> let me know if there is any
> Thanks in advance
>
No builtin function but how about:
%data = (qw(1 One 2 Two 3 Three 4 Four));
@values = @data{keys %data};
print join "\n", @values;
Simon
------------------------------
Date: Tue, 19 Aug 1997 10:15:06 -0400
From: Patrick McPartland <pmcpartl@motown.lmco.com>
Subject: Compiling perl5.004.01 on solaris 2.5.1
Message-Id: <33F9AA6A.7870@motown.lmco.com>
Hello,
I am trying to get perl 5.004.01 to compile on solaris 2.5.1 with
gcc-2.7.2.2 . Configure writes the Makefile, runs make depend, then
fails make on util.c with this error:
util.c: In function `Perl_form':
util.c:1107: number of arguments doesn't match prototype
proto.h:124: prototype declaration
util.c: In function `Perl_die':
util.c:1164: number of arguments doesn't match prototype
proto.h:69: prototype declaration
util.c: In function `Perl_croak':
util.c:1231: argument `pat' doesn't match prototype
proto.h:46: prototype declaration
util.c:1231: number of arguments doesn't match prototype
proto.h:46: prototype declaration
util.c: In function `Perl_warn':
util.c:1288: number of arguments doesn't match prototype
proto.h:525: prototype declaration
util.c: In function `Perl_my_popen':
util.c:1818: warning: return makes pointer from integer without a cast
*** Error code 1
make: Fatal error: Command failed for target `util.o'
I am accepting mostly all defaults, except I am specifying a different
install directory. This is the configure command...
sh Configure -Dcc=gcc -Dprefix=/home/pmcpartl/perl
-Doptimize='-xpentium' -des
Is this a bug? Any advice?
Please email me directly as I don't peruse the group frequently.
Thanks,
Pat
--
Patrick McPartland (609) 722-4767
------------------------------
Date: Fri, 22 Aug 1997 14:13:44 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: defined(<file>) bumps handle in perl5.004_1?
Message-Id: <EFBJIw.Dsz@world.std.com>
Nicholas Geovanis <nickgeo@merle.acns.nwu.edu> writes:
>It seems that using "defined(<STDIN>)" in an if-statement's
>expression in perl5.004_1 under HPUX 10.20 causes an iteration of the
>file-handle. My impression from pg. 53 of the 2nd ed. Camel book is that
>this isn't supposed to happen. Who's right? Perl or the Camel? Or am I
>just wrong?
<> is perl's "read a line from this filehandle" operator. It will
always cause iteration.
The reason that the discussion of the readline operator on page 53
does stuff with "defined()" is that the output of the readline
operator can under an single unusual circumstance return false
prematurely. When the output of the readline operator is checked with
the defined() function, then it will handle this unusual condition
correctly.
The unusual circumstance where the readline operator returns false, is
that if the last line of a file contains the single character "0", not
followed by a newline. If you want to see it in action try this at a
unix shell prompt:
perl -e 'print "0\n1\n2\n3\n4\n5\n4\n3\n2\n1\n0"' > showbug.txt
perl -e 'print $line while $line = <>' showbug.txt
perl -e 'print $line while defined($line = <>)' showbug.txt
If you were trying to see if the filehandle was opened or not, use
defined(fileno(FILEHANDLE)). If you were trying to see if data was
avaiable without reading it, see <URL:http://www.perl.com/CPAN/doc
/manual/html/pod/perlfaq5/How_can_I_tel_if_there_s_a_char.html>
--
Andrew Langmead
------------------------------
Date: 22 Aug 1997 10:07:09 GMT
From: dmacks@sas.upenn.edu (Daniel E. Macks)
Subject: Re: delayed execution of a program??
Message-Id: <5tjocd$l8j$1@netnews.upenn.edu>
If all you want is a way to say "execute this command at this time",
then you don't need perl at all. Unix has a builtin facility for doing
just this kind of job scheduling...look at the manpages for 'at' or
'cron' or 'crontab'. There's a similar thing for other (Mac, NT,
VM/ESA, whatever) platforms. If you need to perform some sort of
preliminary work in perl first, then just cron the perl script.
dan
Rich Bailey (ldusadev@kestrok.com) said:
: Hi:
: Does anyone know how to get perl to delay execution of another program. The
: user will specify the date and time, and I want my perl script to then run
: the program (called isql) at that date and time.
: I guess I could sleep for the time difference then do a system(isql ...),
: but there should be a more eloquent solution.
: Thanks for any ideas,
--
Daniel Macks
dmacks@a.chem.upenn.edu
dmacks@netspace.org
http://www.netspace.org/~dmacks
------------------------------
Date: Fri, 22 Aug 1997 12:47:30 GMT
From: cartwrightm@ssg.gunter.af.mil (Mark Cartwright)
Subject: Re: emacs? No thank you
Message-Id: <33fd89ed.80186860@news>
On Sun, 17 Aug 1997 19:51:30 -0600, Kenneth Vogt
<KenVogt@rkymtnhi.com> wrote:
>Kevin Lambright wrote:
>>
>{snip: lots of good stuff about the benefits of emacs}
>
>Thank you for all the details, Kevin. I didn't realize most of them. I
>guess I still go back to the same thing: why can't emacs be less
>cryptic or even (dare I say) visual? My research (and a lot of comments
>from good folks like you) have lead me to believe what I want does not
>yet exist.
>
>I come from the PC world, not the Unix world. I've got yet *another*
>learning curve to go through here (Perl is language number 14(!) and
>counting). I'm trying to make this as easy on myself as possible. Oh
>well, I guess this is why we make the big bucks! (Don't we?)
You may give xemacs a shot. I found it much more friendly than the
shell version. I have not tried the Win95/NT ver yet, so don't know
how it compares, but I can say that the X ver is wonderful and much
more intuitive than the shell. For us beginners, there are a lot more
buttons and online help, so you can learn the shortcut key combo's as
you go rather than be forced into them right of..
Just a suggestion..
------------------------------
Date: 22 Aug 1997 09:00:44 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Error 49 in SDBM store -- what does it mean?
Message-Id: <5tjkfs$f6f$1@lyra.csx.cam.ac.uk>
Mike Heins <mheins@prairienet.org> wrote:
>
>You should do:
>
> grep 49 /usr/include/errno.h /usr/include/*/errno.h
Or, if you're feeling Perlish, try
perl -e '$!=49; print $!'
which on SunOS 4.1.3 gives "Can't assign requested address", while
Solaris 2.5 gives "Disc quota exceeded".
So you'll have to check it out on your own platform.
Mike Guy
------------------------------
Date: Fri, 22 Aug 1997 12:25:52 +0200
From: uzs90z@uni-bonn.de (Michael Schuerig)
Subject: Re: Error 49 in SDBM store -- what does it mean?
Message-Id: <19970822122552246385@rhrz-isdn3-p21.rhrz.uni-bonn.de>
M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
> > grep 49 /usr/include/errno.h /usr/include/*/errno.h
>
> Or, if you're feeling Perlish, try
>
> perl -e '$!=49; print $!'
>
> which on SunOS 4.1.3 gives "Can't assign requested address", while
> Solaris 2.5 gives "Disc quota exceeded".
Yeah :-(
It's not only a braindead Perl installation with *nothing* beyond the
standard. Also there are only 2048KB alotted to the site.
Thanks for your help.
Michael
--
Michael Schuerig The usual excuse for our most unspeakable
mailto:uzs90z@uni-bonn.de public acts is that they are necessary.
http://www.uni-bonn.de/~uzs90z/ -Judith N. Shklar
------------------------------
Date: Fri, 22 Aug 1997 14:55:47 +0200
From: denis@mathi.uni-heidelberg.de
Subject: foreach and arrays
Message-Id: <33FD8C52.167E@mathi.uni-heidelberg.de>
hi,
i want to append cells in the middle of an array. i think the only way
is using splice. by how can i find out the offset i need, without
changing my foreach in a for to do...?
foreach $i (@array)
{
if ($i=~ /xxx/) {
#insert cell????
}
}
????
bye
denis
------------------------------
Date: Fri, 22 Aug 1997 14:28:24 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: denis@mathi.uni-heidelberg.de
Subject: Re: foreach and arrays
Message-Id: <33FD93F8.6956@adc.metrica.co.uk>
denis@mathi.uni-heidelberg.de wrote:
>
> hi,
>
> i want to append cells in the middle of an array. i think the only way
> is using splice. by how can i find out the offset i need, without
> changing my foreach in a for to do...?
>
> foreach $i (@array)
> {
>
> if ($i=~ /xxx/) {
> #insert cell????
> }
> }
>
> ????
>
> bye
>
> denis
I know this is not much help but I don't think you can easily. I had a
similar problem ( I didn't want to use subscripting for performance
reasons ) and had to resort to a for() loop so that I had access to some
form of index. Of course some guru may prove me wrong but I would be
v.interested to see how it could be done.
Sorry
Simon
------------------------------
Date: 22 Aug 1997 15:44:05 +0200
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: foreach and arrays
Message-Id: <nqo67syz61m.fsf@mitra.phys.uit.no>
denis@mathi.uni-heidelberg.de writes:
> hi,
> how can i find out the offset i need, without
> changing my foreach in a for to do...?
When you need the index in the array, it means you change foreach to for.
That's what for's for.
> denis
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: 22 Aug 1997 15:24:53 +0200
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: Help with catman/makewhatis
Message-Id: <nqoafiaz6xm.fsf@mitra.phys.uit.no>
trey@zipcon.net (Trey Valenta) writes:
> I'm crossposting this since I've seen this question in all three places
> now and no one had an answer (at least that I got).
I posted an answer to this question less than two weeks ago.
> The problem was that Solaris was not properly creating the windex file
> Sun's supplied /usr/lib/getNAME didn't account for man pages which
> have ".IX Header "NAME"" following the .SH NAME entry as almost (all?)
> the perl pages do.
The fix was to add one line to makewhatis that strips out the .IX lines
along with all the other garbage. It has worked for me on Solaris 2.5
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Fri, 22 Aug 1997 09:03:46 -0700
From: John Devlin <devli002@gold.tc.umn.edu>
Subject: HELP!!!...Redirect output 2.......
Message-Id: <33FDB862.420B@gold.tc.umn.edu>
I am having a difficult time running my script, that kicks off a server
level program, and appending the output to my log_file.
#This format works fine.
format LOG1 =
@<<<<<<<<<<<<<<<<<<<<
$STARS
@<<<<<<<<<<<<<<<
$TITLE
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$EXECUTION
.
open(LOG1,">/log_dir/log.txt") || die ("can't open");
write LOG1;
close(LOG1);
#I AM HAVING A PROBLEM WITH GETTING THIS LINE OF CODE TO WORK.
#I WANT TO KICK OFF THIS SCRIPT AND REDIRECT THE OUTPUT TO log.txt.
$_ = `cd /dir_where_script_resides; ./script >> /log_dir/log.txt`;
#This format works fine. Appends to the end of log.txt.
format LOG2 =
@<<<<<<<<<<<<<<<<<<<<
$Completion
@<<<<<<<<<<<<<<<
$STARS
.
open(LOG2,">>/log_dir/log.txt") || die ("can't open");
write LOG2;
close(LOG2);
Any help would be greatly appreciated.
Thanks...JOHN
------------------------------
Date: Fri, 22 Aug 1997 09:17:26 -0500
From: "John T. Beadles" <beadles@nt.com>
Subject: Re: Help: Is there a way to get disk and CPU usage using perl on a NT system?
Message-Id: <33FD9F76.269F@nt.com>
Richard wrote:
>
> Help: Is there a way to get disk and CPU usage using perl on a NT system?
> If you could tell me how or tell me where I may find out that would be
> great.
>
> Thank you in advance for your help.
>
> Richard
The NT Resource kit has a utility called DIRUSE
which lists the file space used for a set of
directories. It's relatively simple to have a
perl script run this and parse the output. I've
got mine set up to run once a day on sets of user
directories, sending the output to a web page.
------------------------------
Date: 20 Aug 1997 23:35:46 GMT
From: "Kelly Baxter" <dewolf@teleport.com>
Subject: Re: How do I find the system date/time?
Message-Id: <01bcadba$d8b4a150$0a646464@kelly>
I tried this and it didn't work... I'm in NT though... is this a unix
variable? (localtime that is)
Tom Phoenix <rootbeer@teleport.com> wrote in article
<Pine.GSO.3.96.970818063935.25618C-100000@julie.teleport.com>...
> On Sun, 17 Aug 1997, David Anderson wrote:
>
> > Subject: How do I find the system date/time?
>
> $date = localtime; # Get the date and time
>
> Hope this helps!
>
> --
> Tom Phoenix http://www.teleport.com/~rootbeer/
> rootbeer@teleport.com PGP Skribu al mi per Esperanto!
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
>
------------------------------
Date: Fri, 22 Aug 1997 12:40:00 GMT
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How do I find the system date/time?
Message-Id: <Pine.A41.3.95a.970822143811.19394C-100000@sp059>
On 20 Aug 1997, Kelly Baxter wrote:
> I tried this and it didn't work...
You wouldn't dream of sharing with us the code that you executed,
and the symptoms you encountered?
> > $date = localtime; # Get the date and time
------------------------------
Date: Fri, 22 Aug 1997 13:11:59 +0200
From: Jochen Wiedmann <wiedmann@neckar-alb.de>
Subject: How to do: $object->$method(@args)
Message-Id: <33FD73FF.60C7EC36@neckar-alb.de>
Hello,
while writing a certain Perl extension I encounter the problem
that I want an unkown object to execute an unknown method with
unknown args. In other words, I have an object $object, a method
$method and arguments @args. Using UNIVERSAL I can ask, whether
$object *can* execute method $method, but how do I really let it
execute it?
The only possibility I can currently think of is XS, by using
perl_call_method. (I'd be glad, if anyone knows a simpler idea!)
In other words, I'd like to write a perl function
@result = CallMethod($object, $method, @args);
However, there arises a new problem: I know how to access the
perl stack within an XS function and I know how to setup
the stack for perl_call_*, but how do I combine both? In other
words, how do I (within an XS function)
1.) prepare the stack for perl_call_method
2.) in a loop grab @args from the XS functions stack and put
it into the stack prepared for perl_call_method
3.) call perl_call_method in an array context
4.) prepare a result array of the XS function
5.) in a loop grab the result array of perl_call_method and
push it into my XS result array
6.) cleanup my stacks
I'll be happy about any help. :-)
Thanks,
Jochen
--
Jochen Wiedmann wiedmann@neckar-alb.de
07123 14887
------------------------------
Date: 22 Aug 1997 15:41:58 +0200
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: How to do: $object->$method(@args)
Message-Id: <nqo7mdez655.fsf@mitra.phys.uit.no>
Jochen Wiedmann <wiedmann@neckar-alb.de> writes:
> Hello,
> I want an unkown object to execute an unknown method with
> unknown args.
Since a method invocation is just a funny subroutine call, you could
check out my recent post on invoking named subroutines in named
packages via soft (symbolic) references. Don't remember exact
subject, something about "very late binding". You might tinker with
that for a bit.
> I'll be happy about any help. :-)
Hth,
> Jochen Wiedmann wiedmann@neckar-alb.de
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: 22 Aug 1997 14:21:00 GMT
From: schmidt@miserv2iai.kfk.de (Andreas Schmidt)
To: Jochen Wiedmann <wiedmann@neckar-alb.de>
Subject: Re: How to do: $object->$method(@args)
Message-Id: <5tk78c$et0$1@nz12.rz.uni-karlsruhe.de>
In article <33FD73FF.60C7EC36@neckar-alb.de>, Jochen Wiedmann <wiedmann@neckar-alb.de> writes:
|> Hello,
|>
|> while writing a certain Perl extension I encounter the problem
|> that I want an unkown object to execute an unknown method with
|> unknown args. In other words, I have an object $object, a method
|> $method and arguments @args. Using UNIVERSAL I can ask, whether
|> $object *can* execute method $method, but how do I really let it
|> execute it?
|>
when you have the object and the methodname you could do an 'eval(...)' call.
or take a look at the AUTOLOAD-Method in the perltoot manual.
hopethisisright
smiff
========================================================================
andreas schmidt email: schmidt@iai.fzk.de
institut fuer angewandte informatik (iai) phone: +49 7247 82 5714
forschungszentrum karlsruhe gmbh
- technik und umwelt -
postfach 3640 76021 karlsruhe (germany)
------------------------------
Date: Fri, 22 Aug 1997 15:13:46 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: I have a forking problems
Message-Id: <33FD908A.64E9CF@absyss.fr>
David Hayden wrote:
>
> I am quite new to Perl (about 4 weeks) and have written a few programs
> which worked fine. I now have a more complicated task to complete involving
> forking, parent and children. I have looked at all the various FAQ, web
> sites etc but all the information found is either too brief or too
> complicated for the novice like me to follow. I would really appreciate
> some help with this.
>
> Below is the forking section of my program, the program is written to wait
> for a response from 'MPP' for 20 seconds or timeout. 'MPP' will reply
> randomly between 1 and 30 seconds. If the program times-out then the child
> process is killed and I get the desired response, however if MPP replies in
> time, I cannot get the program to kill the other process.
[code snipped]
You have a number of problems here, some of them are quite serious.
First is fork(). You seem to think that the only two possible return
values are 0 or the child's pid. There is also a third, "undef" for
when the fork failed. There is no way to know if your fork() even
worked.
Your child loops 20 times, each one doing a sleep(1). When it is done,
it calls dokill(), which is a waste of time as you know that $child is
0. Next you set the variable $outdata, which you never use [more about
this below]. You never exit! This means that the child will continue
running whatever code is after the "if (fork) { child } else { parent }"
block of code. This is almost never what anyone wants (although it can
be useful from time to time). Child blocks normally end with an exit
statement.
The parent sleeps upto 30 seconds and then checks the uninitialized
variable $outdata. I bet you think that this $outdata is the same
$outdata that the child has. Well, it ain't so. The parent and the
child are two different processes. That means two different address
spaces. That means there is no way in hell that a child process can
modify a variable in its parent [*]. Give it up, what you wan't to do
can't be done this way. Read the "perlipc" man page. IPC is
Inter-Process Communication and that is what you need here. In this
simple case, I'd just have the child put the info in a print and have
the parent read this (ie - let "open" be your friend). For something a
bit more complicated, look into pipes, shared memory or even sockets.
Browse that man page, think about things, then read it in detail . This
is not a hard problem, but chosing the right tool for the job is always
good. Perl has several choices for IPC, getting familiar with them now
might help you out later on.
Hope this helps.
- doug
[*] at least not for Unix. If you are using DOS or one of its
offspring, this can be done.
------------------------------
Date: 22 Aug 1997 11:14:46 +0200
From: robert@ICK.il.fontys.nl (robert)
Subject: Re: if (/htm/ && !/html/) {
Message-Id: <5tjla6$fo@bsd1.hqehv-internal.ilse.net>
brenner@slpyff.ed.ray.com:
>I'll keep it brief, I know there another way but I'm braindead today.
> if (/\.htm/ && !/\.html/) {
> print "Changing file name!\n";
> }
if (/\.htm[^l]/)
{
...
}
robert
------------------------------
Date: Fri, 22 Aug 1997 16:02:42 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: if (/htm/ && !/html/) {
Message-Id: <33FD9C02.6E029128@absyss.fr>
Leonhard Brenner wrote:
>
> I'll keep it brief, I know there another way but I'm braindead today.
>
> if (/\.htm/ && !/\.html/) {
> print "Changing file name!\n";
> }
>
> Thank in advance for any help!
Help doing what? You're kinda vague on this one.
Simplifying the expression? This will do it, but only if there is at
least one character after the "m" to match as being "^l" (not ell). ie
- this won't work with .htm at the end of the name.
if ( m/\.htm[^l]/ )
{ print "changing file name\n"; }
Do you really want to allow .htm anywhere in the string, or just as a
suffix? If you want something for rename .htm files to .html files
(upgrading from a toy OS to a real one), something like this might do it
for you.
if ( m/\.htm$/ )
{ print "changing file name\n"; }
but if that is good enough, why bother using a RE? Just use substr()
and check the last 4 characters. That would be faster than a RE.
if ( substr($_,-4) eq '.htm' )
{ print "changing file name\n"; }
Hope this helps.
- doug
------------------------------
Date: Fri, 22 Aug 1997 14:20:37 +0200
From: Joelle D'Antin & Nicolas Gregoire <dantin@icp.grenet.fr>
Subject: pack & format
Message-Id: <33FD8415.3F6F@icp.grenet.fr>
hi,
i want to use pack to put a record in my database.
so, i do $value=pack($foramt, $name, $age, $comment);
but i don't know the length of $comment.
How to do without A.. (perhaps with p i can't make it works)
excuse my frenchy english :)
thanks
------------------------------
Date: Fri, 22 Aug 1997 08:51:36 -0600
From: ldeath@seade.gov.br
To: ldeath@seade.gov.br
Subject: Perl & Shadow Passwords authentitacion.
Message-Id: <872189839.19560@dejanews.com>
Hi there !!!
I'm having a "little" problem writing a CGI script with perl
authenticate users in a linux system that uses shadow passwords.
In fact are 2 problems as follows :
1) I Coudn't find any module at CPAN to get/set shadow password records.
Is there some SHADOW module that has something like getpwnam() ?
2) The /etc/shadow file is setmod 400, so the httpd process that runs as
nobody can't read the shadow file, unless it impersonates the root himself
(and of course I have no idea on how to do it :).
In an initial approach I was thinking about write a perl script to
validate the password using XS to export the shadow(3) functions, this
script would be run as root receiving an IPC semaphore or var from the
CGI script running as nobody. But again I have no idea on how...
Any help, package, module or clue ???
Thanks in advance,
Norival Toniato Junior
A.K.A. Lord Death
Network Manager
Fundacao SEADE.
PS : If you reply this post PLEASE send me a C/C to ldeath@seade.gov.br,
thanks.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 22 Aug 1997 12:13:03 GMT
From: "Sergio Stateri Jr" <serginho@mail.serve.com>
Subject: Perl in EXE
Message-Id: <01bcaef5$256f4140$ca75e7c8@AFXTD_202.Autofax>
Hi ! I did a Perl Script using cgi-lib package...Then I "compile" it with
perl2exe...But, in a machine that doesn't have Perl installed, the exe file
show a message that didn't find cgi-lib.pl. What have I do to to include
this package in exe ?
thanks !
--
--------------------------------------------------------------
Sergio Stateri Jr (Serginho)
Sao Paulo (SP) Brazil
e-mail : serginho@mail.serve.com
--------------------------------------------------------------
------------------------------
Date: Fri, 22 Aug 1997 10:17:06 GMT
From: rob@riverweb.co.uk (Robby)
Subject: Re: Perl script calling an html file?
Message-Id: <5tjp0m$3o4$4@ns2.aladdin.net>
>1. Can this be done?
Have a quick look at Matts Scripts : www.wordwidemart.com/scripts
The form prog does just such a thing.
R
------------------------------
Date: 22 Aug 1997 12:03:02 GMT
From: "David Smits" <bb@b-b.nl>
Subject: reading a gz file
Message-Id: <01bcaef3$c4118620$01006481@daafs>
Is there a possibility to read in a gz file with out unpacking it first.
Many thanks for your answers,
David
email: bb@b-b.nl
------------------------------
Date: Fri, 22 Aug 1997 15:54:27 +0200
From: Doug Seay <seay@absyss.fr>
To: Rene Rivers <rrivers@co.broward.fl.us>
Subject: Re: Reading in a file for use...
Message-Id: <33FD9A13.5029208D@absyss.fr>
[posted and mailed]
Rene Rivers wrote:
>
> Hi, I need a bit of help. I am trying to write a program that requires
> me to read some information from a text file and put it's contents into
> an array for use. How do I do this?
Rene,
It is extremly rude to ask this sort of question. You have basically
said "I want to do something, but I don't want to bother reading any of
the docs, so would one of you drones get off your ass and do it for
me". Forget it, toots. Pay someone to write your code. We help people
who are trying to learn more about the language. Why don't you put a
bit of effort into it and do it yourself? Start with "man perl". If
that doesn't cut it, try buying Randal's _Learning Perl_ (man
"perlbook" for the ISBN) and see what he has to say on the subject.
Sorry if you feel that you don't deserve harsh treatment, but this is
beyond being to lazy to read a FAQ. Simply opening a file, reading the
data into an array, and then closing the file is almost too easy. Show
us you have tried by giving us the code that didn't work, show us what
it did do, and tell us what you thought it should have done. That
implies you've put at least some effort into the problem. That will get
you some help. What you've done so far just doesn't cut it.
- doug
------------------------------
Date: Fri, 22 Aug 1997 13:51:47 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: shell command "more"
Message-Id: <EFBIIB.9In@world.std.com>
tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~) writes:
>Terry Michael Fletcher - PCD ~ (tfletche@pcocd2.intel.com) so eloquently and verbosely pontificated:
>> open (MORE,"|more") || die "oops\n";
>hey, while im at it, maybe i could also give you less information :)
>if you are unfamiliar with it, shell command "less" is more than "more",
>in that you can move backward through a file, and its quick at reading
>large files.
Maybe a better option would be to allow the user to choose their
favorite pager. A convention that is common in unix is to allow users
to set the PAGER environment variable to their pager of choice. If
that environment variable is not set, then you could default to "more"
which is standard among unix systems.
my $pager = $ENV{PAGER} || (-x '/usr/bin/more' ? '/usr/bin/more' :
(-x '/usr/ucb/more' ? '/usr/ucb/more' : 'more'));
open MORE, "|$pager" or die "oops\n";
--
Andrew Langmead
------------------------------
Date: Fri, 22 Aug 1997 16:29:03 -0530
From: Ajitesh Das <ajiteshd@wiproge.med.ge.com>
To: Russ Allbery <rra@stanford.edu>
Subject: Re: shift
Message-Id: <33FE0BA7.59E2@wiproge.med.ge.com>
Russ Allbery wrote:
>
> From man perlfunc:
>
> You may also use defined() to check whether a
> subroutine exists. On the other hand, use of
> defined() upon aggregates (hashes and arrays) is not
> guaranteed to produce intuitive results, and should
> probably be avoided.
>
> [snip]
>
> Currently, using defined() on an entire array or
> hash reports whether memory for that aggregate has
> ever been allocated. So an array you set to the
> empty list appears undefined initially, and one that
> once was full and that you then set to the empty
> list still appears defined. You should instead use
> a simple test for size:
>
yes! you are right!!
> if (@an_array) { print "has array elements\n" }
It can ckecked simply using $#an_arrray
> if (%a_hash) { print "has hash members\n" }
>
This can be using "keys" build in function
ain't these?
--
Rgds
Ajitesh
----
Ajitesh Das ajiteshd@wiproge.med.ge.com
---
"Golden Rule: never derive from a concrete class "
------------------------------
Date: 22 Aug 1997 16:17:35 +0300
From: matti@universe.pc.helsinki.fi (Matti Kinnunen)
Subject: Re: Substitution string problem
Message-Id: <lzu3gipdao.fsf@universe.pc.helsinki.fi>
In article <33f609c0.18624396@news.mindspring.com> jkhowes@mindspring.com (EboshiMan) writes:
Wrong:
$html =~ s/"/\"/g;
Correct:
$html =~ 's/\"/\\"/g'
--
* matti.kinnunen@helsinki.fi *
* http://universe.pc.helsinki.fi/~matti/contact.html *
* !!! +358-(0)40-593 50 91 but try first +358-(0)9-191 23978 *
------------------------------
Date: 22 Aug 1997 12:28:58 GMT
From: "Buehler, Bob" <bob.buehler@cpa.state.tx.us>
Subject: Syntax Question
Message-Id: <01bcaeff$12b9ef00$c546c6c0@bbue461.cpa.state.tx.us>
I browsed the FAQ and read my Learning PERL book, but can't figure out this
code for creating a database message handler. Could someone please assist?
<snip>
sub message_handler
{
my ($db, $message, $state) = @_;
}
Here's what I think:
subroutine definition, sub is named message_handler, a list of 3 variables
is assigned to the special variable @_. But, I don't understand the "my".
What am I missing?
------------------------------
Date: 22 Aug 1997 15:34:41 +0200
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: TCL 8.0: A whole lot of perl
Message-Id: <nqo90xuz6ha.fsf@mitra.phys.uit.no>
btlewis@Sun.COM (Brian Lewis) writes:
[my claim that tcl list indexing is still O(n)]
> Sorry Tom, but this isn't true. One of the major changes in Tcl 8.0 is
> to use "Tcl objects" to hold values instead of strings. These Tcl_Obj
> structures can hold an cached internal representation such as an array
> of element pointers for a list. This makes most list operations linear
> time.
Well, that change wasn't in the list. I had heard that it would be, so
I was surprised that it wasn't.
I did however say that *if* the list is comprehensive, then ...
> : > Of course, TCL has:
> : ... a long way to go? :-)
> Now, now... :-)
Well, better now than next year... :-)
> Brian
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Fri, 22 Aug 1997 13:37:16 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: undeclared variables ???
Message-Id: <EFBHu5.LCK@world.std.com>
"Jon Marshall" <xkn14@dial.pipex.com> writes:
>could someone please explain why the folllowing when run
>complains about an undeclared variable on line 28 - i have been
>working on this and it's driving me mad - the code works but
>i would like it to run with the -w switch
> my($size,$dir,$file,@whole,@direcs) = 0;
This isn't going to assign 0 to all of these variables, it is only
going to assign a 0 to $size, and leave the rest undefined.
--
Andrew Langmead
------------------------------
Date: Fri, 22 Aug 1997 10:11:36 GMT
From: rob@riverweb.co.uk (Robby)
Subject: WILL PAY for help and or development work
Message-Id: <5tjomd$3o4$3@ns2.aladdin.net>
MY requirement is to run a PERL database app off a CD, through the
browser window Netscape or IE (3 or 2's will do)
I have installed OMNIhttpd webserver and have got the system
functioning on a standlone machine.
I need to be able to bundle everythin, the server, the PERL
interpreter and the html and scripts onto a CD so it works on a
machine from scratch.
Will there be a problem with TCP/IP?
Does the server and interpreter have to be installed in the standalone
or can it run from CD?
Is there a better way (writing an executable from the PERL for eg.
that give the database output, hotlinks and all)
I wuold v. much appreciate any help and will PAY MONEY!
Thanks
Rob Oldham
Riverweb Ltd.
------------------------------
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 904
*************************************