[23939] in Perl-Users-Digest
Perl-Users Digest, Issue: 6140 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 16 09:05:46 2004
Date: Mon, 16 Feb 2004 06:05:11 -0800 (PST)
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, 16 Feb 2004 Volume: 10 Number: 6140
Today's topics:
[MIME] How to attach eMails? <Guru03@despammed.com>
Re: [MIME] How to attach eMails? <jwillmore@remove.adelphia.net>
Re: Choosing grouping of split items <krahnj@acm.org>
Re: configure problem <alansecker@globalnet.co.uk>
DBD::mysqlPP v DBD::mysql (Mike Solomon)
Emacs modules for Perl programming (Jari Aalto+mail.perl)
Re: Environment question <Joe.Smith@inwap.com>
Re: Example of web application done right? <ian.cass@mblox.com>
Re: Getting CGI to read from a different STDIN source nobull@mail.com
greedy v. non-greedy matching <matthew.garrish@sympatico.ca>
Re: greedy v. non-greedy matching <noreply@gunnar.cc>
Re: greedy v. non-greedy matching (Anno Siegel)
Re: greedy v. non-greedy matching <fifo@despammed.com>
How to read STDERR messages from a third party program? (Arne Goetje)
Re: How to read STDERR messages from a third party prog <josef.moellers@fujitsu-siemens.com>
Re: How to read STDERR messages from a third party prog <fifo@despammed.com>
Re: Perl and Quotas <usenet@morrow.me.uk>
Re: Perl and Quotas <jwillmore@remove.adelphia.net>
perl threads and inter thread communication (brad)
Re: perl threads and inter thread communication thumb_42@yahoo.com
Re: perl threads and inter thread communication <ian.cass@mblox.com>
Re: perl threads and inter thread communication <zentara@highstream.net>
Problems using Module PDF::Create (kielhd)
Re: Problems using Module PDF::Create <josef.moellers@fujitsu-siemens.com>
Re: Reading html into a source file (Chris)
Re: Reading html into a source file <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 16 Feb 2004 10:50:26 +0000 (UTC)
From: Guru03 <Guru03@despammed.com>
Subject: [MIME] How to attach eMails?
Message-Id: <Xns94917886FAB27Guru03despammedcom@193.43.96.1>
Hi, my question is a bit strange.
I use MIME::Entity to prepare email and send them.
I got an email (put it in a string) and I send it.
But when I open it in certain versions of Outlook the body of attached
email is not shown, and in none of these versions I can see the headers
(but From:, To: and Subject: yes).
i.e., a Mail received:
From: ee@qq.it
To: 11@ee.it
Date: Mon, 16 Feb 2004 10:56:26 +0100
MIME-Version: 1.0
Subject: rqweqwe
Message-ID: <4030A1DA.19777.7C4729@localhost>
Priority: normal
X-mailer: Pegasus Mail for Windows (v4.12a)
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body
prova
with
$myEmail -> attach (Data => $attachment,
Type => 'message/rfc822');
($myEmail is a MIME::Entity object)
the attachment:
------------=_1076925411-23871-9
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
From: ee@qq.it
To: 11@ee.it
Date: Mon, 16 Feb 2004 10:56:26 +0100
...
the MIME::Entity->stringify is used to send entire email to sendmail.
What's wrong with it?
------------------------------
Date: Mon, 16 Feb 2004 08:53:15 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: [MIME] How to attach eMails?
Message-Id: <pan.2004.02.16.13.53.13.924363@remove.adelphia.net>
On Mon, 16 Feb 2004 10:50:26 +0000, Guru03 wrote:
> I use MIME::Entity to prepare email and send them.
<snip>
I personally use MIME::Lite to send email with MIME attachments. It's
easier to use and you don't need to know much more than what MIME type
you're going to use in the email.
Just my $0.02
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
One monk said to the other, "The fish has flopped out of the net!
How will it live?" The other said, "When you have gotten out of
the net, I'll tell you."
------------------------------
Date: Mon, 16 Feb 2004 11:32:29 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Choosing grouping of split items
Message-Id: <4030AA4C.764CB854@acm.org>
fishfry wrote:
>
> If I have
>
> $text = 'abc - def - ghi - jkl";
>
> then
>
> @tokens = split(/-/, $text, 3);
>
> splits the line into abc, def, ghi - jkl (ignoring leading and trailing
> spaces).
>
> I have an application where there may be 3 or 4 items separated by '-'
> but if there are 4, I want them returned as abc - def, ghi, and jkl.
>
> Is there a one-liner for that?
$ perl -le'
$text = "abc - def - ghi - jkl";
@tokens = $text =~ /(.+)-(.+)-(.+)/;
print for @tokens;
'
abc - def
ghi
jkl
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 16 Feb 2004 11:47:06 +0000
From: Alan Secker <alansecker@globalnet.co.uk>
Subject: Re: configure problem
Message-Id: <4030ADBA.40407@globalnet.co.uk>
Sisyphus wrote:
> Alan secker wrote:
>
>> <START>
>> I used the command:
>>
>> gcc -o try -O3 -fno-strict-aliasing -I/usr/local/include
>> -L/usr/local/lib try.c -lnsl -lndbm -ldb -ldl -lm -lcrypt -lutil -lc
>> ./try
>>
>
> You mean you actually entered the above line ??
>
> Normally you just do as per instructions in the 'INSTALL' file (which
> can be found in the top level directory of the source distro).
>
> Building perl that way was trivial for me on Mandrake-9.1.
>
> Cheers,
> Rob
>
No I didn't key it in, the configure script informed that that is what
it did. Very impressive the way that interfaces with the user. On the
whole very user friendly. As t how I did it, I used the instructions
unbundled along with everything else (from the .tar, gz, .rpm etc) I'm
not in front of my machine right now, which is why I'm vague on that point.
I will follow up Ben Morrow's points within the next couple of hours.
Thanks for your help.
Alan
------------------------------
Date: 16 Feb 2004 05:38:27 -0800
From: mike_solomon@lineone.net (Mike Solomon)
Subject: DBD::mysqlPP v DBD::mysql
Message-Id: <56568be5.0402160538.45a40197@posting.google.com>
At present I am using DBD:mysqlPP to connect to MySql
is there any advantages or disadvantages to using mysqlPP compared with mysql ?
------------------------------
Date: 16 Feb 2004 10:03:17 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1076925476@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs/XEmacs
o Unix:
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
o Unix Windows port (for Unix die-hards):
install http://www.cygwin.com/ which includes native Emacs 21.x.
XEmacs port is bundled in XEmacs setup.exe available from
XEmacs site.
o Pure Native Windows port
http://www.gnu.org/software/emacs/windows/ntemacs.html
ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe
o More Emacs resources at
http://tiny-tools.sourceforge.net/ => Emacs resource page
Emacs Perl Modules
Cperl -- Perl programming mode
ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
http://www.perl.com/CPAN-local/misc/emacs/cperl-mode/
<ilya@math.ohio-state.edu> Ilya Zakharevich
CPerl is major mode for editing perl files. Forget the default
`perl-mode' that comes with Emacs, this is much better. Comes
standard in newest Emacs.
TinyPerl -- Perl related utilities
http://tiny-tools.sourceforge.net/
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Grep through all Perl manpages (.pod)
o Follow POD references e.g. [perlre] to next pod with RETURN
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o Update `$VERSION' variable with YYYY.MMDD on save.
o Load source code into Emacs, like Devel::DProf.pm
o Prepare script (version numbering) and Upload it to PAUSE
o Generate autoload STUBS (Devel::SelfStubber) for you
Perl Module (.pm)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in Tiny Tools Kit]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
how to set up dattabases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to to do the search, You can adjust
recursive grep options, set search case sensitivity, add user grep
options etc.
You can find latest `igrep.el' module at
<http://groups.google.com/groups?group=gnu.emacs.sources> The
maintainer is Jefin Rodgers <kevinr@ihs.com>.
TinyCompile -- To Browse grep results in Emacs *compile* buffer
TinyCompile is a minor mode for *compile* buffer from where
you can collapse unwanted lines or shorten file URLs:
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: Mon, 16 Feb 2004 06:11:43 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Environment question
Message-Id: <zaZXb.43834$_44.42024@attbi_s52>
Bill Staples wrote:
> And besides, I don't need advice from someone who knows even less about
> perl than I do.
Dear Bill,
You have just insulted a person who knows a lot more about Perl
than you do. You've also insulted the group as a whole.
> At least I know that the "include" statement is not a
> feature of perl and all your insisting is not making my system find it.
Are you an idiot, or what? Perl has four "include" features, none of
which are spelled 'include', yet all perform that function.
Take your program pieces and name them Part1.pm, Part2.pm, Part3.pm
and Part4.pm. Then use this code to bring them into Main.pl:
use Part1;
require Part2;
do "Part3.pm";
eval `cat Part4.pm`;
Have you actually tried any of those yet? If you did, you would not
be going on spreading falsehoods about perl's "include" functionality.
-Joe
------------------------------
Date: Mon, 16 Feb 2004 12:27:26 GMT
From: "Ian Cass" <ian.cass@mblox.com>
Subject: Re: Example of web application done right?
Message-Id: <OG2Yb.105$vM7.1969336@news-text.cableinet.net>
Glen Pfeiffer wrote:
> This is not a "What is the best language?" question. I merely want to
> look at an application that is easy to extend/modify/maintain which
> separates logic from display code, and compare it to some other
> applications done in other languages. I have experience building large
> sites in other languages, but not in Perl. Some thoughts I have had
> are WebGUI, YaBB and YAWP.
I always use Apache::ASP for my web stuff. www.apache-asp.org See their
Testimonials section for examples of large websites using Apache::ASP.
--
Ian Cass
------------------------------
Date: 16 Feb 2004 05:26:34 -0800
From: nobull@mail.com
Subject: Re: Getting CGI to read from a different STDIN source
Message-Id: <4dafc536.0402160526.5141deb4@posting.google.com>
junkmail@wirespring.com (Bill Gerba) wrote in message news:<7f2e88c6.0402141205.5c345731@posting.google.com>...
> Brian McCauley <nobull@mail.com> wrote in message news:<u9r7wyiq9f.fsf@wcl-l.bham.ac.uk>...
> >
> > You could just open the file as STDIN
> >
> ...
> >
> > How about
> >
> > # Untested
> > open(STDIN,"posted_data.txt") or die "can't open temp file: $!";
> > my $cc = new CGI;
>
> This was the first thing I tried. In my first post I noted that when
> I do this I not only get an empty CGI object, but I also get a
> peculiar message about STDOUT being opened for output only.
Sorry I missed the start of this thread originally.
I've gone back a copied the test script from the OP onto my web
server. I made only one small change - I added a chdir("/tmp")
because my httpd is not configured to set CGIs' CWD to a writable
directory. It worked perfectly.
Are you sure that your httpd _is_ configured to set CGIs' CWD to a
writable directory?
Are you sure you are using CGI at all (and not something like mod_perl
+ Apache::Registry)?
------------------------------
Date: Mon, 16 Feb 2004 07:52:12 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: greedy v. non-greedy matching
Message-Id: <X13Yb.2268$d34.363744@news20.bellglobal.com>
Would anynoe care to enlighten me as to why the (.*?) pattern matches
greedily in the following example:
my $text =<<TEXT;
I wouldn't expect the following text to match
xyz 12345 abc
but it does and I lose this text as well
xyz 12345 abc
xyz 12345 abc
xyz 12345 abc
TEXT
$text =~ s/(xyz(.*?)abc\s*)+$//s;
print $text;
But if I change the regex to:
$text =~ s/(xyz(.*?)abc\s*)\1+$//s;
It works as expected.
Matt
------------------------------
Date: Mon, 16 Feb 2004 14:16:08 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: greedy v. non-greedy matching
Message-Id: <c0qgaf$19atrf$1@ID-184292.news.uni-berlin.de>
Matt Garrish wrote:
> Would anynoe care to enlighten me as to why the (.*?) pattern
> matches greedily in the following example:
>
> my $text =<<TEXT;
> I wouldn't expect the following text to match
> xyz 12345 abc
> but it does and I lose this text as well
> xyz 12345 abc
> xyz 12345 abc
> xyz 12345 abc
> TEXT
>
> $text =~ s/(xyz(.*?)abc\s*)+$//s;
It doesn't. Making it non-greedy does not change the fact that it
matches the *first occurrence* of the pattern.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 16 Feb 2004 13:31:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: greedy v. non-greedy matching
Message-Id: <c0qgod$for$2@mamenchi.zrz.TU-Berlin.DE>
Matt Garrish <matthew.garrish@sympatico.ca> wrote in comp.lang.perl.misc:
> Would anynoe care to enlighten me as to why the (.*?) pattern matches
> greedily in the following example:
>
> my $text =<<TEXT;
> I wouldn't expect the following text to match
[...]
Greedy vs. non-greedy never decides *if* a pattern matches, it can only
modify *what* it matches. So your expectation is unjustified.
Anno
------------------------------
Date: Mon, 16 Feb 2004 13:46:54 +0000
From: fifo <fifo@despammed.com>
Subject: Re: greedy v. non-greedy matching
Message-Id: <20040216134651.GD21193@fleece>
At 2004-02-16 07:52 -0500, Matt Garrish wrote:
> Would anynoe care to enlighten me as to why the (.*?) pattern matches
> greedily in the following example:
>
> my $text =<<TEXT;
> I wouldn't expect the following text to match
> xyz 12345 abc
> but it does and I lose this text as well
> xyz 12345 abc
> xyz 12345 abc
> xyz 12345 abc
> TEXT
>
> $text =~ s/(xyz(.*?)abc\s*)+$//s;
>
> print $text;
>
You're trying to match the sub-expression /(xyz(.*?)abc\s*)/ repeatedly,
up to end of the string.
This initially matches the first "xyz 12345 abc\n", but this isn't
followed by either the end of the string, nor by something that matches
the expression again. Hence we have to backtrack, and we find that if
we use the /(.*?)/ part to match a bit more of the string, the
expression will next match this:
xyz 12345 abc
but it does and I lose this text as well
xyz 12345 abc
Now this _is_ followed by two more "xyz 12345 abc\n" strings, each of
which also matches the above sub-expression so we're done.
>
> But if I change the regex to:
>
> $text =~ s/(xyz(.*?)abc\s*)\1+$//s;
>
> It works as expected.
>
This expression requires that whatever it is that matches
/(xyz(.*?)abc\s*)/ is repeated verbatim (at least once) upto the end of
the string. This doesn't happen when that sub-expression matches the
"but it does" line, since this doesn't occur subsequently.
------------------------------
Date: 16 Feb 2004 01:01:24 -0800
From: 20030910antispam@gmx.net (Arne Goetje)
Subject: How to read STDERR messages from a third party program?
Message-Id: <626fa895.0402160009.53f6aeb9@posting.google.com>
Hi,
I want my perl script to start a third party program (daemon) in the
background and capture the messages it sends out onto STDERR
occasionally.
These messages should be processed by my perl script.
Any idea how to do this?
Please CC to me. Thanx.
------------------------------
Date: Mon, 16 Feb 2004 10:18:07 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
To: Arne Goetje <20030910antispam@gmx.net>
Subject: Re: How to read STDERR messages from a third party program?
Message-Id: <40308ACF.ED179E43@fujitsu-siemens.com>
Arne Goetje wrote:
> =
> Hi,
> =
> I want my perl script to start a third party program (daemon) in the
> background and capture the messages it sends out onto STDERR
> occasionally.
> These messages should be processed by my perl script.
> =
> Any idea how to do this?
If your daemon doen't do any output to stdout, you could just redirect
stderr to stdout:
open(DAEMON, "daemon 2>&1 |");
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Mon, 16 Feb 2004 12:36:49 +0000
From: fifo <fifo@despammed.com>
Subject: Re: How to read STDERR messages from a third party program?
Message-Id: <20040216123645.GB21193@fleece>
At 2004-02-16 10:18 +0100, Josef Möllers wrote:
> Arne Goetje wrote:
> > I want my perl script to start a third party program (daemon) in the
> > background and capture the messages it sends out onto STDERR
> > occasionally.
> > These messages should be processed by my perl script.
> >
> > Any idea how to do this?
>
> If your daemon doen't do any output to stdout, you could just redirect
> stderr to stdout:
> open(DAEMON, "daemon 2>&1 |");
>
Or if it does write to stdout, you can suppress this
with "daemon 2>&1 1>/dev/null |".
------------------------------
Date: Mon, 16 Feb 2004 05:48:07 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Perl and Quotas
Message-Id: <c0plin$nb5$1@wisteria.csv.warwick.ac.uk>
"John Call" <jcall@ellijay.com> wrote:
> I am trying to write a small script that will change quotas for me on a
> RedHat box. The following is my program (99% of which comes from the book
> Perl for System Administration).
> -----------
> #!/usr/bin/perl
>
use strict;
use warnings;
> use Quota;
>
> $filesystem = '/home/users/<username>';
my $filesystem = ...
> $soft = 5;
my $soft = ...
> $hard = 6;
&c.
> $isoft = 0;
> $ihard = 0;
>
> my($name,$paswd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell ) =
> getpwnam($ARGV[0]);
>
> $dev = Quota::getqcarg($filesystem);
>
> ($curblock, $soft, $hard, $curinode, $btimeout, $curinode, $isoft, $ihard,
> $itim
> eout) = Quota::query($dev, $uid) or die "Unable to query quota for
> $uid:$!\n";
>
> Quota::setqlim($dev, $uid, $soft, $hard, $isoft, $ihard, 1) or die "Unable
> to set quotas:$!\n";
> ---------------
>
> Quota::query returns the following error:
> Unable to query quota for 2977:No such process
This is an example of an Unhelpful Error Message (Not a typewriter!):
No such process is ESRCH, and the Quota docs say that Quota::query
fails with ESRCH if the user has no quota set. cf. Quota::strerr.
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
- Heraclitus
ben@morrow.me.uk
------------------------------
Date: Mon, 16 Feb 2004 08:49:02 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Perl and Quotas
Message-Id: <pan.2004.02.16.13.49.00.331007@remove.adelphia.net>
On Sun, 15 Feb 2004 23:29:21 -0500, John Call wrote:
<snip>
>
> Quota::query returns the following error:
> Unable to query quota for 2977:No such process
>
> If I REM out the Quota::query line, Quota::setqlim returns the following
> error:
> Unable to set quotas:No such file or directory
>
> I'm really not sure why this is happening. I checked the errata page for the
> book and found no errors for this section. I also check Google groups and
> found nothing.
Are you *using* quotas on your system? With SuSE, you have the option to
use or not use quotas. And, a quick glance at the LPIC preperation book
shows there are a few commands that you can use to check the status of
quotas on your system (quotacheck, quotaon, etc.). Type in 'man -k quota'
for a list of commands to verify the quotas on your system.
In order to solve your Perl issue, you may want to check the system over
first. If you *have* enabled quotas, and they are being enforced, then
I'm not sure what's going on.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
7:30, Channel 5: The Bionic Dog (Action/Adventure) The Bionic
<Dog gets a hormonal short-circuit and violates the Mann Act
<with an interstate Greyhound bus.
------------------------------
Date: 15 Feb 2004 21:55:30 -0800
From: spaughbradley@hotmail.com (brad)
Subject: perl threads and inter thread communication
Message-Id: <9b99b7f2.0402152155.ee65b47@posting.google.com>
Hi,
I am writing some test scripts where I want to fork() and in the child
I want to continually monitor one condition(if a chip resets) and if
that condition is met, I want to be able to send a message to the
parent and stop him and exit. Further more, If the child process
never gets satisfied, and the parent finishes its job, I want to be
able to stop the child process from within the parent and then exit
the parent thread. There must be a way to talk among threads, but I
have been searching with little luck. How can I send messages among
threads or share variables among them? Does anyone have any examples
of such a thing? Thanks
------------------------------
Date: Mon, 16 Feb 2004 08:28:11 GMT
From: thumb_42@yahoo.com
Subject: Re: perl threads and inter thread communication
Message-Id: <va%Xb.41408$yE5.168173@attbi_s54>
brad <spaughbradley@hotmail.com> wrote:
> Hi,
> I am writing some test scripts where I want to fork() and in the child
^^^^^?
Are you talking threads of processes? (I'm going to assume processes
but I could be wrong.)
> I want to continually monitor one condition(if a chip resets) and if
> that condition is met, I want to be able to send a message to the
> parent and stop him and exit.
What you could do is simply keep the parents process ID around in the child,
and use kill() to send the parent a message. Save a copy of $$ prior to
calling fork().
> Further more, If the child process
> never gets satisfied, and the parent finishes its job, I want to be
> able to stop the child process from within the parent and then exit
> the parent thread.
Again, you could use signals, (with kill()) if you're talking about
processes. since fork() returns the child PID on success.
> There must be a way to talk among threads, but I
> have been searching with little luck. How can I send messages among
> threads or share variables among them? Does anyone have any examples
> of such a thing? Thanks
Have a look at 'man perlipc' for more details.
There is shared memory, mmap, file handles, UNIX sockets, pipes, signals,
message queues, and several modules that interfaces with all the above. All
kinds of things to play with.
Each of them have their pros and cons. (mmap last I checked, required a
module and was not portable, but if you're talking to chips, portability is
probably a null issue eh? :-) ) Shared memory was nice, but it's not freed
when the processes leave, which can be a feature but it can also be a problem.
Jamie
------------------------------
Date: Mon, 16 Feb 2004 09:44:36 GMT
From: "Ian Cass" <ian.cass@mblox.com>
Subject: Re: perl threads and inter thread communication
Message-Id: <8i0Yb.50$yr6.1075368@news-text.cableinet.net>
brad wrote:
> Hi,
> I am writing some test scripts where I want to fork() and in the child
> I want to continually monitor one condition(if a chip resets) and if
> that condition is met, I want to be able to send a message to the
> parent and stop him and exit. Further more, If the child process
> never gets satisfied, and the parent finishes its job, I want to be
> able to stop the child process from within the parent and then exit
> the parent thread. There must be a way to talk among threads, but I
> have been searching with little luck. How can I send messages among
> threads or share variables among them? Does anyone have any examples
> of such a thing? Thanks
I've found http://search.cpan.org/~elizabeth/forks-0.15/lib/forks.pm to be
pretty useful for threaded applications that use forked processes instead of
the experimental thread architecture. The clever thing is, the 'use forks;'
API is the same as 'use threads;', so you should be able to flip between the
two.
To learn how to use this API, read the Perl thread tutorial
http://search.cpan.org/~nwclark/perl-5.8.3/pod/perlthrtut.pod . You can then
use what you've learnt by 'use forks' rather than 'use threads'.
YMMV.
--
Ian Cass
------------------------------
Date: Mon, 16 Feb 2004 08:38:27 -0500
From: zentara <zentara@highstream.net>
Subject: Re: perl threads and inter thread communication
Message-Id: <7ah130567t8q204hcj08iarvog9jcfd4ks@4ax.com>
On 15 Feb 2004 21:55:30 -0800, spaughbradley@hotmail.com (brad) wrote:
>Hi,
>I am writing some test scripts where I want to fork() and in the child
>I want to continually monitor one condition(if a chip resets) and if
>that condition is met, I want to be able to send a message to the
>parent and stop him and exit. Further more, If the child process
>never gets satisfied, and the parent finishes its job, I want to be
>able to stop the child process from within the parent and then exit
>the parent thread. There must be a way to talk among threads, but I
>have been searching with little luck. How can I send messages among
>threads or share variables among them? Does anyone have any examples
>of such a thing? Thanks
You are confusing terminology. You start out talking about fork and
exec, then end up asking about "talking amoung threads".
Forking and threading are 2 different things.
If you are forking, you will need IPC, like pipes and sockets.
That is the old, foolproof way for doing it.
Threads are recent to Perl, can be a little buggy, are not as efficient,
but are good if you need to share data.
If you are going to use threads, then "use threads::shared;
Threads are good if you want to share data between threads.
Here is a super-simple example on how to have a child thread
send a signal back to the parent. The rest is up to you.
#!/usr/bin/perl
use threads;
use threads::shared;
use strict;
our $a:shared = 1;
print "main start->$a\n";
threads->create(\&display);
threads->create(\&display1);
print "hit enter to finish\n";
<STDIN>; #pauses for keypress
print "main done-> $a\n";
sub display {
our $a = 2;
$a++;
print "from t1->$a\n";
}
sub display1 {
our $a = 99;
print "front2->$a\n";
$a++;
lock $a;
cond_broadcast($a);
}
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: 16 Feb 2004 04:44:53 -0800
From: kielhd@freenet.de (kielhd)
Subject: Problems using Module PDF::Create
Message-Id: <10a4173d.0402160444.2f461014@posting.google.com>
Hi all,
the module 'PDF::Create' works fine except the 'Rotate' Option.
I get the following error:
Can't use string ("90") as an ARRAY ref while "strict refs" in use at
C:/Perl/site/lib/PDF/Create.pm line 184, <GEN26> line 1.
when using the following code:
...
my $root = $pdf->new_page('MediaBox' => [ 0, 0, 612, 792 ],
'Rotate' => 90);
...
Any ideas ?
Best regards, Henning
------------------------------
Date: Mon, 16 Feb 2004 13:55:10 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Problems using Module PDF::Create
Message-Id: <4030BDAE.960390A8@fujitsu-siemens.com>
kielhd wrote:
> =
> Hi all,
> the module 'PDF::Create' works fine except the 'Rotate' Option.
> =
> I get the following error:
> Can't use string ("90") as an ARRAY ref while "strict refs" in use at
> C:/Perl/site/lib/PDF/Create.pm line 184, <GEN26> line 1.
> =
> when using the following code:
> ...
> my $root =3D $pdf->new_page('MediaBox' =3D> [ 0, 0, 612, 792 ],
> 'Rotate' =3D> 90);
Just a quick idea:
my $root =3D $pdf->new_page('MediaBox' =3D> [ 0, 0, 612, 792 ],
'Rotate' =3D> [ 90 ]);
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: 16 Feb 2004 01:15:35 -0800
From: chris.tunnecliff@markelintl.com (Chris)
Subject: Re: Reading html into a source file
Message-Id: <b8146f1.0402160115.9b1b68e@posting.google.com>
Thanks for the comments to my posting (not mail),
Will try your comments tonight Bill and post a follow up tomorrow, I'm
not running through a web server as I have downloaded perl 6.0 and am
running in DOS whilst having a permanent TCP/IP connection, the result
may be different when I run it from home as I was running it at work
behind a firewall.
Thanks for the input so far.
------------------------------
Date: Mon, 16 Feb 2004 07:11:15 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Reading html into a source file
Message-Id: <slrnc31gbj.3rn.tadmc@magna.augustmail.com>
Chris <chris.tunnecliff@markelintl.com> wrote:
> I have downloaded perl 6.0
I don't think you have.
There is no Perl 6 yet...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6140
***************************************