[17862] in Perl-Users-Digest
Perl-Users Digest, Issue: 22 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 9 03:05:41 2001
Date: Tue, 9 Jan 2001 00:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979027508-v10-i22@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 9 Jan 2001 Volume: 10 Number: 22
Today's topics:
Re: Creating simple GIF pictures??? <meisl@amvt.tu-graz.ac.at>
Re: getting bash output to a perl variable. (Chris Fedde)
Help sending a form info in HTML format BAQUANB@BELLATLANTIC.NET
How do I pass an object to a sub-routine <rrocky@bigfoot.com>
Re: How do I pass an object to a sub-routine <joe+usenet@sunstarsys.com>
Re: How do I pass an object to a sub-routine <rrocky@bigfoot.com>
Re: How do I pass an object to a sub-routine <uri@sysarch.com>
Re: How do I pass an object to a sub-routine <rrocky@bigfoot.com>
Re: How do I pass an object to a sub-routine <uri@sysarch.com>
Re: Jpeg width/height (Richard Zilavec)
Re: Mime parser (Chris Fedde)
Re: Pattern Matching <iboreham@my-deja.com>
Reset HTML::TokeParser <rrocky@bigfoot.com>
Sending SIGTERM to child process <nickw@ot.com.au>
Re: Shall use a reference instead? <joe+usenet@sunstarsys.com>
Re: Shall use a reference instead? <uri@sysarch.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 09 Jan 2001 06:49:39 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: Re: Creating simple GIF pictures???
Message-Id: <m34rz9qnpo.fsf@famvtpc59.tu-graz.ac.at>
mgjv@tradingpost.com.au (Martien Verbruggen) writes:
> Sounds like a job for GD (or maybe Image::Magick).
>
> If you insist on GIF, get an old version of GD, and if you want it
> compressed, make sure you pay Unisys a fee (Image::Magick can link in
> LZW compresion, but you still should pay Unisys).
Thanks, GD is perfect, and PNG is okay, as well...
Regards,
Christian
--
Christian Meisl <meisl@amvt.tu-graz.ac.at> www.amft.tu-graz.ac.at
Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
-------- A truly wise man never plays leapfrog with a unicorn. ---------
PGP fingerprint: DF48 2503 0411 F0EF 149C 851B 1EF0 72B9 78B6 034A
------------------------------
Date: Tue, 09 Jan 2001 06:45:00 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: getting bash output to a perl variable.
Message-Id: <Mry66.791$B9.192337920@news.frii.net>
In article <93e5o5$ovi$1@slb6.atl.mindspring.net>,
Aaron!@# <aaron@SPAM-O-RAMA.smalltime.com> wrote:
>Hey there. I'm having trouble getting a file from a linksys router on my
>LAN (so I can get a . Here's what I have so far:
>
>
>#########
># Stuff #
>#########
>
>$StatusPage ==
>`wget --http-user=$RouterUserName --http-passwd=$RouterPassword
>\"$RouterURL\" -O -`;
>print "StatusPage is $StatusPage";
>
It looks to me like you have == where you want to have =.
chris
--
This space intentionally left blank
------------------------------
Date: Tue, 09 Jan 2001 06:20:07 GMT
From: BAQUANB@BELLATLANTIC.NET
Subject: Help sending a form info in HTML format
Message-Id: <93eail$2et$1@nnrp1.deja.com>
I have a form on my webpage and would like to send the info in HTML
format not Plain Text format. I use a cgi script call Web2Mail is there
something in the code I can change to do this. Here's the code I use.
#!/usr/bin/perl
### web2mail -- An anonymous CGI mailer.
### See http://www.pobox.com/~cgires/web2mail/
### for usage and description.
### Copyright 1995-97, Sanford Morton <smorton@pobox.com>
### Thanks to Michael Grobe <grobe@ukans.edu> for a multiple
values fix.
###
### Configuration Variables
###
### The local mail program
### You may need to change the path to sendmail.
### If you don't have sendmail, you'll need to revise &send_mail
$mail_program = "/usr/lib/sendmail -t";
### Instructions page
### Used if the page owner forgets to supply .email_target hidden tag
$instructions_url = "http://www.pobox.com/~cgires/web2mail/";
###
### Main body of script
###
### parse the form data
&ReadParse;
### is required email address supplied
if ( ! $in{'.email_target'} ) {
print &instructions_page;
exit;
}
### any required data? if so, has user supplied it?
if ( $in{'.required_data'} && &missing_data ) {
print &incomplete_page;
exit;
}
### prepare first line of mail message
$message = $in{'.mail_intro'} ? "$in{'.mail_intro'}\n\n"
: "Form data submitted to $ENV{'HTTP_REFERER'}:\n\n";
### write the form data to the mail message
foreach (sort keys %in) {
next if /^\./; # skip hidden form data in mail message
$item = "$_: $in{$_}";
$item =~ s/^..// if $in{'.remove_indexing'};
# if multiple values, indent them on new lines
$item =~ s/\0/"\n\t".(" "x(2+length($_)))/ge;
$message .= "\t$item\n";
}
## do you want the environment variables?
if ( $in{'.environment'} ) {
$message .= "\nThe environment variables are:\n\n";
foreach (keys %ENV) {
$message .= "\t$_: $ENV{$_}\n";
}
} else {
## let's at least report a few
$message .= "\nReferring page: $ENV{HTTP_REFERER}";
$message .= "\nUser address: $ENV{REMOTE_ADDR}";
$message .= "\nUser host: $ENV{REMOTE_HOST}";
}
## prepare subject line in mail message
$subject_line = $in{'.mail_subject'} ? "$in{'.mail_subject'}"
: "Free Quote $ENV{'HTTP_REFERER'}";
## remove everything after the first comma in .email_target to
## prevent multiple recipients, eg, spam broadcasts
$in{'.email_target'} =~ s/,.*//;
## mail it (or web it if in test mode)
&send_mail ($mail_program, $in{'.email_target'}, $subject_line,
$message);
## Return an acknowledgement page
&acknowledge_page;
###
### End of main body of script.
### Subroutines below.
###
###
### Return an acknowledgement page.
### Look first for a matching custom response url,
### then for a thanks page, or send the default acknowledgement page.
###
sub acknowledge_page {
local($i, @triples);
## search for a match among custom responses
if ( $in{'.custom_response_url'} ) {
## for each custom response, the triple is:
## form tag name :: triggering value :: response url
@triples = split( /::/, $in{'.custom_response_url'} );
for ($i=0; $i < $#triples; $i+=3) {
## if name matches value
if ( $in{"$triples[$i]"} eq $triples[$i+1] ) {
## print URL
if ( $in{'.test'} ) { # test mode
print "The acknowledgement page that would be
returned is:
<A HREF=\"$triples[$i+2]\">$triples[$i+2]
</A>";
} else {
print "Location: $triples[$i+2]\n\n";
}
exit;
}
}
}
## if no custom response matches, return the supplied
## base thanks page, if any
if ( $in{'.thanks_url'} ) {
if ( $in{'.test'} ) { # test mode
print "The acknowledgement page that would be returned is:
<A HREF=\"$in{'.thanks_url'}\">$in{'.thanks_url'}
</A>";
} else {
print "Location: $in{'.thanks_url'}\n\n";
}
## or just return the built-in default
} else {
print &thanks_page;
}
}
###
### .email_target form data is missing, return an instruction page
###
sub instructions_page {
local ($page_source) = <<"INSTRUCTIONS_PAGE";
Content-type: text/html\n\n
<TITLE>Oops, .email_target is missing</TITLE>
<H1>Oops, .email_target is missing</H1>
You must include a hidden form tag called <CODE>.email_target</CODE>
whose value is the email address to which you want to mail the form
data.
Something like<PRE>
<INPUT TYPE="hidden" NAME=".email_target" VALUE="user\@site.com">
</PRE>For your information, the form elements and their values that
actually were supplied in this page were:<UL>
INSTRUCTIONS_PAGE
foreach (keys %in) {
$page_source .= "<LI>$_: $in{$_}\n";
}
$page_source .= <<"LAST_PART";
</UL>You can return to the
<A HREF="$instructions_url">instructions page</A>
describing the use of this mailing script, or press your
<STRONG>BACK</STRONG>
button to return to the web form.
LAST_PART
return $page_source;
}
###
### send mail containing the form data
###
sub send_mail {
local ($mail_program, $email_address, $subject, $message) = @_;
if ($in{'.test'}) { # test mode. Send mail to web page
print <<"TEST";
Content-type: text/html\n\n
<H1>Here is the letter that would be mailed:</H1><PRE>
To: $email_address
Subject: $subject
\n\n$message\n</PRE>
<H1>The rest of this page is the Thanks page</H1><HR>
TEST
} else { # production mode. Send mail to mail.
if ( !open(MAIL, "|$mail_program") ) {
print &error_page ($message);
exit;
}
print MAIL <<"EOM";
To: $email_address
Subject: $subject
\n\n$message
\n.\n
EOM
close (MAIL);
}
}
###
### Return the html source for an incomplete submission page
###
sub incomplete_page {
local ($page_source) = <<"FIRST_HALF";
Content-type: text/html\n\n
<TITLE>Thanks, but oops ...</TITLE>
<H2>Thanks, but oops ...</H2>
Your information is important to us, and the following items
on the form were not filled in:
<UL>
FIRST_HALF
foreach ( @missing_fields ) {
$page_source .= "<LI>$_\n";
}
$page_source .= <<"SECOND_HALF";
</UL>
Please click your <STRONG>BACK</STRONG> button to return to the form
and add that information. Your other answers should still be there.
SECOND_HALF
return $page_source;
}
###
### Return an array of missing fields among the Company data, or undef
### Need to name the fields descriptively so users will know what
### form data they are missing.
###
sub missing_data {
local ($result) = 0;
foreach ( split (/::/, $in{'.required_data'} ) ) {
unless ($in{$_}) {
s/^..// if $in{'.remove_indexing'};
push (@missing_fields, $_);
$result = 1;
}
}
return $result;
}
###
### Return the html source for an error page following a
### mail error. Includes the text of the mail.
###
sub error_page {
local ($message) = @_;
local ($page_source) = <<"ERROR_PAGE";
Content-type: text/html\n\n
<TITLE>System Form Error</TITLE>
<H2>Thanks, but oops ...</H2>
The system seems a bit confused right now, so your form
was not processed. You can try again a little later, or you can
mail us directly at
<A HREF="mailto:$in{'.email_target'}">$in{'.email_target'}</A>.
You can simply quote this page, since the following is the message
that would have been sent: <P><PRE>$message</PRE>
ERROR_PAGE
return $page_source;
}
###
### Return the html source for the acknowledgement page.
###
sub thanks_page {
local ($page_source) = <<"THANKS_PAGE";
Content-type: text/html\n\n
<TITLE>Form Acknowledgement</TITLE>
<H2>Thank You</H2>
Your quote has been submitted to
<A HREF="mailto:$in{'.email_target'}">$in{'.email_target'}</A>.
Thank you for taking the time to fill out the form.
THANKS_PAGE
if ( $in{'.back_to_url'} ) {
$page_source .=
"<P>Return to <A HREF=\"$in{'.back_to_url'}\">$in
{'.back_to_url'}</A>";
}
return $page_source;
}
###
### Parse the cgi form data.
### Adapted from cgi-lib.pl by S.E.Brenner@bioc.cam.ac.uk
### Copyright 1994 Steven E. Brenner
###
sub ReadParse {
local (*in) = @_ if @_;
local ($i, $key, $val);
if ( $ENV{'REQUEST_METHOD'} eq "GET" ) { # replaced his MethGet
function
## don't accept GET, to make it a little harder to spoof the
script
print "Content-type: text/html\n\n";
print "Sorry, this script only accepts METHOD=POST. ";
print "Use that inside your <FORM ...> tag";
exit;
} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
} else {
# Added for command line debugging
# Supply name/value form data as a command line argument
# Format: name1=value1\&name2=value2\&... (need to escape & for
shell)
# Find the first argument that's not a switch (-)
$in = ( grep( !/^-/, @ARGV )) [0];
$in =~ s/\\&/&/g;
}
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
# Convert plus's to spaces
$in[$i] =~ s/\+/ /g;
# Split into key and value.
($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
# Convert %XX from hex numbers to alphanumeric
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
# Associate key and value
# \0 is the multiple separator
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $val;
}
return length($in);
}
Thanks
Brian
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 08 Jan 2001 21:39:17 -0800
From: Rocky Raccoon <rrocky@bigfoot.com>
Subject: How do I pass an object to a sub-routine
Message-Id: <3A5AA405.AFC7E20E@bigfoot.com>
use HTML::TokeParser;
$p = HTML::TokeParser->new("./t.html") ;
I want to pass $p as parameter to my own sub-routine
$a = get_next_tag($p);
sub get_next_tag
{
$src = @_;
$x = $src->get_token; ### Line X
if($x->[0] eq "S" || $x->[0] eq "E")
{
return $x ;
}
}
This gives an error
Can't call method "get_token" without a package or object reference at
t.pl at line X.
What am I doing wrong ?
--
Rocky
http://www.slack.net/~shiva/rsc.html
------------------------------
Date: 09 Jan 2001 00:59:26 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: How do I pass an object to a sub-routine
Message-Id: <m3snmtxo3l.fsf@mumonkan.sunstarsys.com>
Rocky Raccoon <rrocky@bigfoot.com> writes:
> use HTML::TokeParser;
> $p = HTML::TokeParser->new("./t.html") ;
>
> I want to pass $p as parameter to my own sub-routine
>
> $a = get_next_tag($p);
>
> sub get_next_tag
> {
> $src = @_;
^^^^^^
You want the first item of @_ ($_[0] or shift @_)
but what you wrote places @_ in a scalar context.
In a scalar context, arrays return the number of
elements they contain. Here $src = 1, not $p.
> $x = $src->get_token; ### Line X
>
> This gives an error
> Can't call method "get_token" without a package or object reference at
> t.pl at line X.
>
> What am I doing wrong ?
$src is a number here, not an object reference. Change the
problem line to
my $src = shift @_;
or
my $src = $_[0];
and see if that helps. (Note the "my" prefix- it's always
a good idea to declare your variables using "my" to prevent
them from existing beyond the block in which you introduced
them. Bad side-effects can occur unless you're careful, so
be sure to enable "use strict;" in the future. )
HTH
--
Joe Schaefer
------------------------------
Date: Mon, 08 Jan 2001 22:06:46 -0800
From: Rocky Raccoon <rrocky@bigfoot.com>
Subject: Re: How do I pass an object to a sub-routine
Message-Id: <3A5AAA76.7F01309@bigfoot.com>
Joe Schaefer wrote:
> > What am I doing wrong ?
>
> $src is a number here, not an object reference. Change the
> problem line to
>
> my $src = shift @_;
Thank you.
I had just discovered it works by
$src = shift;
[ which I assume takes @_ as the default ]
--
Rocky
http://www.slack.net/~shiva/rsc.html
------------------------------
Date: Tue, 09 Jan 2001 06:21:53 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How do I pass an object to a sub-routine
Message-Id: <x7u2795jpa.fsf@home.sysarch.com>
>>>>> "RR" == Rocky Raccoon <rrocky@bigfoot.com> writes:
RR> I had just discovered it works by
RR> $src = shift;
RR> [ which I assume takes @_ as the default ]
why assume? you are learning about objects and subs and you assume
behavior? read perlsub and perlobj and the half dozen others that relate
to subs. then you won't have any assumptions. at the very least you
should read up on @_ and shift. this is how you learn something. you are
told how to correct your code, you then read about the operation in more
depth and how it relates t other things. you might follow a see-also
link and cross over to some related subject. you keep doing that until
you tire of it. then you go back to coding the original problem with a
totally new perspective on it.
so don't assume a perl feature. verify it in the fine manuals.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 08 Jan 2001 22:32:55 -0800
From: Rocky Raccoon <rrocky@bigfoot.com>
Subject: Re: How do I pass an object to a sub-routine
Message-Id: <3A5AB097.66FF1BDD@bigfoot.com>
Uri Guttman wrote:
>
> >>>>> "RR" == Rocky Raccoon <rrocky@bigfoot.com> writes:
>
> RR> I had just discovered it works by
>
> RR> $src = shift;
> RR> [ which I assume takes @_ as the default ]
>
> why assume? you are learning about objects and subs and you assume
> behavior? read perlsub and perlobj and the half dozen others that relate
> to subs. then you won't have any assumptions. at the very least you
> should read up on @_ and shift. this is how you learn something. you are
> told how to correct your code, you then read about the operation in more
> depth and how it relates t other things. you might follow a see-also
> link and cross over to some related subject. you keep doing that until
> you tire of it. then you go back to coding the original problem with a
> totally new perspective on it.
>
> so don't assume a perl feature. verify it in the fine manuals.
Thank you for the post.
Actually 'assume' was just a figure of speech there.
I had verified it was the same thing.
And my follow-up to Joe wasn't to ask him if shift & shift @_ are the
same. It was purely to thank him for his quick response.
I am learning Perl in a big hurry & getting something done. Till last
week,
I had hardly ever seen even a line of perl code. So I am learning on a
need to know basis (much as I don't like it). I have to get a demo ready
by Thursday. After which I will learn Perl more formally before getting
the
final thing done.
And things I have read seem to slip out of my mind becos of the huge
amount
of things in Perl. (especially since I spend 1/2 the day coding in a
different
language)
Perl is confusing for a newbie, believe me.
But, Perl still rocks, especially the CPAN modules.
--
Rocky
http://www.slack.net/~shiva/rsc.html
------------------------------
Date: Tue, 09 Jan 2001 06:43:31 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How do I pass an object to a sub-routine
Message-Id: <x7puhx5ip8.fsf@home.sysarch.com>
>>>>> "RR" == Rocky Raccoon <rrocky@bigfoot.com> writes:
RR> Actually 'assume' was just a figure of speech there.
RR> I had verified it was the same thing.
RR> And my follow-up to Joe wasn't to ask him if shift & shift @_ are the
RR> same. It was purely to thank him for his quick response.
well, you haven't fully read about shift. shift and shift @_ are not
always the same thing. there is a signifigant change in the behavior of
a naked shift depending on where it is.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 09 Jan 2001 05:44:24 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: Jpeg width/height
Message-Id: <3a5aa527.4199371@news.tcn.net>
On Tue, 09 Jan 2001 02:40:04 GMT, Mario <diab.lito@usa.net> wrote:
>How can I get width/height info of a JPEG file?
>Reading the 7 to 10 byte (as in GIF) doesn't work.
use Image::Size;
--
Richard Zilavec
rzilavec@tcn.net
------------------------------
Date: Tue, 09 Jan 2001 06:42:20 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Mime parser
Message-Id: <gpy66.790$B9.190388224@news.frii.net>
In article <3A5A779C.7F5621CF@home.com>, Manny <jagman98@home.com> wrote:
>I am trying to remove HTML and other MIME code from MIME message body
>using MIME:Parser but the message still does not remove anything.
>
>Can someone post an example of parser code?
>
>Thanks in advance!
>
I'm confused by your question. Are you asking if it is posible to create a
mime format message that does not contain HTML or are you asking if it
is posible to turn HTML into plain text? Or am I completely missing the
point? Maybe if you described the scenario it might help me figure out
what you are asking.
chris
--
This space intentionally left blank
------------------------------
Date: Tue, 09 Jan 2001 07:52:00 GMT
From: Ian Boreham <iboreham@my-deja.com>
Subject: Re: Pattern Matching
Message-Id: <93efuv$5t4$1@nnrp1.deja.com>
In article <93bv00$9r65@intranews.bank.dresdner.net>,
"Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com> wrote:
> I thought it is somewhere in the FAQ...
I don't know about the FAQ, but it's in Jeffrey Friedl's book (Mastering
Regular Expressions).
> What about
>
> /^(?:\d{1,3}\.){3}\d{1,3}$/
It depends on how accurately you want to match it with a regex, and how
much validation you want to do outside. This example will ensure you
have 4 full-stop-separated 1-3 digit numbers, but it doesn't stop
numbers like 999 appearing, and it doesn't prevent the invalid
"0.0.0.0". You might also want to restrict the range of allowed
addresses.
Putting together the pieces of JF's version (full range with 0.0.0.0
excluded - doesn't appear to have been spelt out completely), you get
something like:
^(?!0+\.0+\.0+\.0+$)([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$
I have just typed this in without testing it - I'd go to the book if I
were you, or just read it and work out what it is doing, rather than
cutting and pasting. I could very well have made a typo, and it would
take some time to test all parts of this, which I don't feel like doing.
To make it simpler, put the numerical expression in a string and
interpolate it four times with dots between.
The other main option is to just match 1-3 digit numbers with dots
between, capture the values, and check they are valid individually (and
that they aren't all zero).
Regards,
Ian
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 08 Jan 2001 21:12:20 -0800
From: Rocky Raccoon <rrocky@bigfoot.com>
Subject: Reset HTML::TokeParser
Message-Id: <3A5A9DB4.58263D4D@bigfoot.com>
Hi,
I parse a string containing HTML with the TokeParser.
$source = HTML::TokeParser->new(\$str_html);
# I do operations on it like get_tag, get_token etc
....
Now I want to reset the parser to the beginning.
Is reopening the Parser object i.e.
$source = HTML::TokeParser->new(\$str_html);
Is this the only way to reset the parser or are there any other
methods for that.
I couldn't find any in the docs.
--
Rocky
http://www.slack.net/~shiva/rsc.html
------------------------------
Date: Tue, 9 Jan 2001 17:36:07 +1100
From: "Nick Wilson" <nickw@ot.com.au>
Subject: Sending SIGTERM to child process
Message-Id: <979022209.290315@emissary>
I currently have a process (call it starter) which creates another process,
(say called child1), and this child 1 has some signal handlers set up for
it, ie
sub handler {
# kill all immediate children (gracefully)
@children = `ps -f`;
foreach $child (@children) {
$child =~ m/([0-9]+) +$$./ && kill 15, $1;
}
}
$SIG{TERM} = \&handler;
My problem lies in the starter function, when it tries to kill off the child
after a timeout, the following call doesn't work
kill 15, $pid
A couple of things, I'm sure that the handler works as I can do a kill -15
child_ps_id
which works fine. And I'm sure that 15 is set to TERM for my setup.
So why doesn't this term signal get trapped ?
Any ideas appreciated,
Nick
------------------------------
Date: 09 Jan 2001 00:05:29 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Shall use a reference instead?
Message-Id: <m3wvc5xqli.fsf@mumonkan.sunstarsys.com>
"Michael Mayo" <michael-a-mayo@worldnet.att.net> writes:
> Please show me how to:
> 1) create a new object of this class
> 2) access the object's color value
> 3) call the object's doThingamabob method
> all without using references.
#!/usr/bin/perl -wl
package Doohickie;
use strict;
use Tie::Hash;
use vars qw( @ISA );
@ISA = qw( Tie::StdHash ); # just lazy :)
sub new {
bless { color => "red" } , shift;
}
sub doThingamabob {
shift() -> {color} = "black";
}
sub TIEHASH {
shift() -> new;
}
1;
package main;
my %hash;
tie %hash, "Doohickie"; #1 create a new object
print $hash{color}; #2 access color value
tied(%hash)->doThingamabob; #3 call doThingamabob
print %hash; # w/o using references
__END__
outputs:
red
colorblack
HTH
--
Joe Schaefer
------------------------------
Date: Tue, 09 Jan 2001 06:13:45 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Shall use a reference instead?
Message-Id: <x7wvc55k2u.fsf@home.sysarch.com>
>>>>> "JS" == Joe Schaefer <joe+usenet@sunstarsys.com> writes:
JS> "Michael Mayo" <michael-a-mayo@worldnet.att.net> writes:
>> Please show me how to:
>> 1) create a new object of this class
>> 2) access the object's color value
>> 3) call the object's doThingamabob method
>> all without using references.
JS> tie %hash, "Doohickie"; #1 create a new object
JS> print $hash{color}; #2 access color value
JS> tied(%hash)->doThingamabob; #3 call doThingamabob
well, you are using references, you just hide them under tie's
skirts. read the chapter on tied objects in OOP. very
enlightening. tying is just wrapping an object with a standard set of
methods that get called by the generated code. there is still a blessed
reference that is created. rather referent as damian calls it. the bless
is done on the actual hash (the referent) and you have a reference to
that.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
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 V10 Issue 22
*************************************