[29228] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 472 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 31 11:10:28 2007

Date: Thu, 31 May 2007 08:09:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 31 May 2007     Volume: 11 Number: 472

Today's topics:
    Re: Beyond Inside-Out anno4000@radom.zrz.tu-berlin.de
        contacting Alfred Reibenschuh, creator of (CPAN) PDF-AP <bugbear@trim_papermule.co.uk_trim>
    Re: Email::Folder->messages returns only one element <Michael.Yxf@gmail.com>
    Re: Email::Folder->messages returns only one element <Michael.Yxf@gmail.com>
    Re: Email::Folder->messages returns only one element <paduille.4061.mumia.w+nospam@earthlink.net>
    Re: Email::Folder->messages returns only one element <paduille.4061.mumia.w+nospam@earthlink.net>
    Re: Email::Folder->messages returns only one element <thepoet_nospam@arcor.de>
    Re: Email::Folder->messages returns only one element <noreply@gunnar.cc>
    Re: Email::Folder->messages returns only one element <Michael.Yxf@gmail.com>
    Re: Email::Folder->messages returns only one element <Michael.Yxf@gmail.com>
    Re: Email::Folder->messages returns only one element <Michael.Yxf@gmail.com>
    Re: FAQ 8.11 How do I decode encrypted password files? <baxter.brad@gmail.com>
    Re: FAQ 8.28 How can I call backticks without shell pro <baxter.brad@gmail.com>
    Re: FAQ 8.28 How can I call backticks without shell pro <bik.mido@tiscalinet.it>
        fork() and script execution afterwards <tom@snnap.net>
    Re: fork() and script execution afterwards <andrew.fedyashov@gmail.com>
    Re: fork() and script execution afterwards <bik.mido@tiscalinet.it>
    Re: get mail by POP3Client? <simon.andrews@bbsrc.ac.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 31 May 2007 15:04:15 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Beyond Inside-Out
Message-Id: <5c86ffF2vtt0qU1@mid.dfncis.de>

Michele Dondi  <bik.mido@tiscalinet.it> wrote in comp.lang.perl.misc:
> On 30 May 2007 09:37:22 GMT, anno4000@radom.zrz.tu-berlin.de wrote:
> 
> >Abigail  <abigail@abigail.be> wrote in comp.lang.perl.misc:
> [snip]
> 
> Anno,
> 
> 
> due to time constraints (in synergy with the fact that much of this is
> far above the top of my head) I've not been closely following the
> discussions either here or in PM, but for what I've read they're both
> extremely valuable and interesting. So may I ask you to be so gentle
> and for completeness to report there -as time permits- anything you
> judge to be worth of what's said here? The other way round is easy,
> because you already linked to the root node of the thread...

I think it would be disruptive to *report* the contents of this
thread on perlmonks (or the other way around).  I have pointed
out on monks that there is this parallel discussion, not prominently
but it's there.  And, of course, in participating in both threads I'm
ferrying information back and forth as opportunity allows or demands.  

Anno


------------------------------

Date: Thu, 31 May 2007 13:18:38 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: contacting Alfred Reibenschuh, creator of (CPAN) PDF-API2 ?
Message-Id: <465ebd1f$0$8759$ed2619ec@ptn-nntp-reader02.plus.net>

I've found (and I think fixed) a bug in this useful
module:

http://search.cpan.org/~areibens/PDF-API2-0.61/

I've tried emailing my work (test cases, documentation and code changes) to
the email address given here:

http://search.cpan.org/~areibens/

but got no response (email was sent 18/may/2007)

The module appears to be active, with a most
recent release date of 07 May 2007.

If anyone knows how I can get in touch, please tell me.

   BugBear


------------------------------

Date: 31 May 2007 00:11:24 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Email::Folder->messages returns only one element
Message-Id: <1180595483.910211.196240@g37g2000prf.googlegroups.com>

On May 31, 2:33 pm, "Mumia W." <paduille.4061.mumia.w
+nos...@earthlink.net> wrote:
> On 05/30/2007 11:11 PM, Michael Yang wrote:
>
>
>
> > I'm working on parsing multiple messages out of one msf file(mbox
> > folder type).
> > I took the module of  Email::Folder to construct with msf file, and
> > then get the list of all messages contained in the msf file.
> > But, the msf file is considered as a wholly one message, not multiple
> > messages (actually I have multiple messages within the msf file)
>
> > Here is my code snippet:
> > my $folder = Email::Folder->new($file);    //$file is a valid mbox
> > folder type
> > foreach ($folder->messages){
> >     print $_->header("Subject"), "\n";
> >     print $_->as_string(), "\n";
> >     //$imapserver->append($box, $_->as_string()); // i want to import
> > this message to my $imapserver, you can comment this one.
> > }
> > The result is:
> > The first print prints only the first message's subject.
> > The second print prints all the messages(all of the other messages) in
> > the msf file as a whole one.
> > The Email::Folder parses this file as one mail message.
>
> > Doesn't $folder->messages return a list of messages?
> > Is there any where I missed to set the preference of parsing rule?
>
> > Thanks.
>
> Your code, with minor modifications, works for me. Hint: C++ comments
> are not Perl comments ;-)
Is it because of the module version?
I tried Mail::Box::Manager to parse the same file, it works.
Because Mail::Box::Manager module has too many dependency modules to
attach, I want to try Email::Folder instead to parse the message data.
I need to wrap this harness as a package in the end.
>
> This is obviously not your real code, and you typed it in by hand
> without using cut-and-paste.
>
> http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
>
> When I read the POD for Email::Folder, I see this helpful message:
>
> > messages
>
> > Returns a list containing all of the messages in the folder.  Can only
> > be called once as it drains the iterator.
>
> Maybe in your real code, you're doing a while or something rather than a
> foreach.
>

The purpose of my script is quite simple. Parse the message data out
of the local msf file, and then import each messages into mail server
by Email::IMAPClient->append("INBOX", $msg);
This snippet only deals with parsing the message data out of the file.
There isn't anywhere Email::Folder module required anymore.

I typed this snippet to show the problems that Email::Folder->messages
doesn't function as it should do.

In my snippet, sorry for that I paste it again:

eval { require Email::Folder; };
die "The module Email::Folder is required for this script.\n" if $!;

my $file = "mail";   //$file is a valid mbox folder,with
"mail.msf"
my $folder = Email::Folder->new($file);
foreach ($folder->messages){
    print $_->header("Subject"), "\n";
    print $_->as_string(), "\n";
}

what I expected is that multiple messages contained in the "mail" file
will be outputed.
But only one is returned by this snippet.
It's RHEL AS4 distribution with Perl 5.8.5 installed on my pc.

I am wondering it...

> Anyway, a code snippet is inadequate. You should create the smallest
> program that demonstrates your problem and ask for help with that.




------------------------------

Date: 31 May 2007 00:22:10 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Email::Folder->messages returns only one element
Message-Id: <1180596130.505121.191340@x35g2000prf.googlegroups.com>

On May 31, 3:11 pm, Michael Yang <Michael....@gmail.com> wrote:
> On May 31, 2:33 pm, "Mumia W." <paduille.4061.mumia.w
>
> +nos...@earthlink.net> wrote:
> > On 05/30/2007 11:11 PM, Michael Yang wrote:
>
> > > I'm working on parsing multiple messages out of one msf file(mbox
> > > folder type).
> > > I took the module of  Email::Folder to construct with msf file, and
> > > then get the list of all messages contained in the msf file.
> > > But, the msf file is considered as a wholly one message, not multiple
> > > messages (actually I have multiple messages within the msf file)
>
> > > Here is my code snippet:
> > > my $folder = Email::Folder->new($file);    //$file is a valid mbox
> > > folder type
> > > foreach ($folder->messages){
> > >     print $_->header("Subject"), "\n";
> > >     print $_->as_string(), "\n";
> > >     //$imapserver->append($box, $_->as_string()); // i want to import
> > > this message to my $imapserver, you can comment this one.
> > > }
> > > The result is:
> > > The first print prints only the first message's subject.
> > > The second print prints all the messages(all of the other messages) in
> > > the msf file as a whole one.
> > > The Email::Folder parses this file as one mail message.
>
> > > Doesn't $folder->messages return a list of messages?
> > > Is there any where I missed to set the preference of parsing rule?
>
> > > Thanks.
>
> > Your code, with minor modifications, works for me. Hint: C++ comments
> > are not Perl comments ;-)
>
> Is it because of the module version?
> I tried Mail::Box::Manager to parse the same file, it works.
> Because Mail::Box::Manager module has too many dependency modules to
> attach, I want to try Email::Folder instead to parse the message data.
> I need to wrap this harness as a package in the end.
>
>
>
>
>
> > This is obviously not your real code, and you typed it in by hand
> > without using cut-and-paste.
>
> >http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
>
> > When I read the POD for Email::Folder, I see this helpful message:
>
> > > messages
>
> > > Returns a list containing all of the messages in the folder.  Can only
> > > be called once as it drains the iterator.
>
> > Maybe in your real code, you're doing a while or something rather than a
> > foreach.
>
> The purpose of my script is quite simple. Parse the message data out
> of the local msf file, and then import each messages into mail server
> by Email::IMAPClient->append("INBOX", $msg);
> This snippet only deals with parsing the message data out of the file.
> There isn't anywhere Email::Folder module required anymore.
>
> I typed this snippet to show the problems that Email::Folder->messages
> doesn't function as it should do.
>
> In my snippet, sorry for that I paste it again:
>
> eval { require Email::Folder; };
> die "The module Email::Folder is required for this script.\n" if $!;
>
> my $file = "mail";   //$file is a valid mbox folder,with
> "mail.msf"
> my $folder = Email::Folder->new($file);
> foreach ($folder->messages){
>     print $_->header("Subject"), "\n";
>     print $_->as_string(), "\n";
>
> }
>
> what I expected is that multiple messages contained in the "mail" file
> will be outputed.
> But only one is returned by this snippet.
> It's RHEL AS4 distribution with Perl 5.8.5 installed on my pc.
>
> I am wondering it...
>
> > Anyway, a code snippet is inadequate. You should create the smallest
> > program that demonstrates your problem and ask for help with that.

I wrote another script to demonstrate my problems:
      1 #!/usr/bin/perl -w
      2 # Author: Michael Yang
      3 # Date: May/31/2007
      4 # Purpose: To test the function of Email::Folder module.
      5
      6 use strict;
      7 use warnings;
      8
      9 my @mail_list = @ARGV;
     10
     11 die "Usage: $0 <.msf file> \n" if not @mail_list;
     12
     13 eval { require Email::Folder; };
     14 die "The module Email::Folder is required for this script.\n"
if $!;
     15
     16 foreach my $file (@mail_list){
     17     if ($file =~ m/^(.*)\.msf$/i){
     18         $file = $1;
     19         print "$file MSF file detected.\n"
     20     }
     21     die "can't access import file $file" unless -r $file;
     22
     23     my $folder = Email::Folder->new($file);
     24
     25     my @msg_list = $folder->messages();
     26     foreach(@msg_list){
     27         print $_->header("Subject"), "\n";
     28         #   print $_->as_string(), "\n";
     29     }
     30 }

To run this script, one valid *.msf file is required to pass in, which
contains multiple messages.
In this script, it will print out each message's subject data.
The result on my pc is that there is only one subject is printed out.

Thanks all!!



------------------------------

Date: Thu, 31 May 2007 08:44:28 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Email::Folder->messages returns only one element
Message-Id: <MVv7i.11867$296.7331@newsread4.news.pas.earthlink.net>

On 05/31/2007 02:22 AM, Michael Yang wrote:
> [ program demonstrating Email::Folder snipped ]

I ran your program. The only things I changed were lines 9 and 14:

  9: my @mail_list = glob('~/tmp/mozmail/*.msf');
14: die "The module Email::Folder is required for this script.\n" if $@;

I had to change $! to $@. Read "perldoc -f eval."

Your modified program ran properly; all of the message subjects were 
listed separately on my system:

Debian 3.1 (Linux).
Perl 5.8.4
Email::Folder 0.852
Email::Simple 1.9
Email::FolderType 0.7




------------------------------

Date: Thu, 31 May 2007 09:41:54 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Email::Folder->messages returns only one element
Message-Id: <CLw7i.16713$j63.237@newsread2.news.pas.earthlink.net>

On 05/31/2007 03:44 AM, Mumia W. wrote:
> Email::Folder 0.852
> Email::Simple 1.9
> Email::FolderType 0.7
> 
> 

I forgot to mention that I installed the Debian versions of these 
modules. That's probably not important, but Debian sometimes fixes bugs 
in software when the upstream authors have not fixed them.



------------------------------

Date: Thu, 31 May 2007 13:09:19 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Email::Folder->messages returns only one element
Message-Id: <465eace0$0$10187$9b4e6d93@newsspool4.arcor-online.net>

Michael Yang wrote:
> I wrote another script to demonstrate my problems:
>       1 #!/usr/bin/perl -w
>       2 # Author: Michael Yang
>       3 # Date: May/31/2007
>       4 # Purpose: To test the function of Email::Folder module.
>       5
>       6 use strict;
>       7 use warnings;
>       8
>       9 my @mail_list = @ARGV;
>      10
>      11 die "Usage: $0 <.msf file> \n" if not @mail_list;
>      12
>      13 eval { require Email::Folder; };
>      14 die "The module Email::Folder is required for this script.\n"
> if $!;
>      15
>      16 foreach my $file (@mail_list){
>      17     if ($file =~ m/^(.*)\.msf$/i){
>      18         $file = $1;
>      19         print "$file MSF file detected.\n"
>      20     }
>      21     die "can't access import file $file" unless -r $file;
>      22
>      23     my $folder = Email::Folder->new($file);
>      24
>      25     my @msg_list = $folder->messages();
>      26     foreach(@msg_list){
>      27         print $_->header("Subject"), "\n";
>      28         #   print $_->as_string(), "\n";
>      29     }
>      30 }
> 
> To run this script, one valid *.msf file is required to pass in, which
> contains multiple messages.
> In this script, it will print out each message's subject data.
> The result on my pc is that there is only one subject is printed out.

A possible cause could be recognition of line endings. Does the mbox
file stem from a different platform, was it transported via ASCII-FTP?
To check that, you can test with different values for the "eol"
parameter to Email::Folder's constructor:.
  # Windows-Format:
  my $folder = Email::Folder->new( $file, "eol" => "\r\n" );
  # Mac-Format:
  # my $folder = Email::Folder->new( $file, "eol" => "\r" );
  # Unix-Format:
  # my $folder = Email::Folder->new( $file, "eol" => "\n" );

-Chris


------------------------------

Date: Thu, 31 May 2007 14:19:51 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Email::Folder->messages returns only one element
Message-Id: <5c7t06F2on8kgU1@mid.individual.net>

Michael Yang wrote:
> On May 31, 1:44 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>> Michael Yang wrote:
>>> I'm working on parsing multiple messages out of one msf file(mbox
>>> folder type).
>>> I took the module of  Email::Folder to construct with msf file, and
>>> then get the list of all messages contained in the msf file.
>>> But, the msf file is considered as a wholly one message, not multiple
>>> messages (actually I have multiple messages within the msf file)
>>
>> Does the file have proper message separators?
>
> Actually I am not sure about what is the message separators the parser
> uses. The msf file and its mail content is generated by Thunderbird
> mail client locally.

I run your code successfully on a Thunderbird generated mbox file.

> Where can I get the rules on valid format of MBox file, so that I can
> check if the file generated by Thunderbird is a valid one for
> Email::Folder to parse.

Note that you stated in the OP that you used a valid mbox folder type...

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: 31 May 2007 07:48:36 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Email::Folder->messages returns only one element
Message-Id: <1180622915.864370.223830@q19g2000prn.googlegroups.com>

On May 31, 5:41 pm, "Mumia W." <paduille.4061.mumia.w
+nos...@earthlink.net> wrote:
> On 05/31/2007 03:44 AM, Mumia W. wrote:
>
> > Email::Folder 0.852
> > Email::Simple 1.9
> > Email::FolderType 0.7
>
> I forgot to mention that I installed the Debian versions of these
> modules. That's probably not important, but Debian sometimes fixes bugs
> in software when the upstream authors have not fixed them.

I think I found the possible causes.
The *.msf file I used to parse was generated on Window platform.
After "dos2unix" to convert its format, it works.

I then tried the file generated by thunderbird client on Linux
platform, it is working well.



------------------------------

Date: 31 May 2007 07:52:57 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Email::Folder->messages returns only one element
Message-Id: <1180623177.184747.189040@d30g2000prg.googlegroups.com>

On May 31, 8:19 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> Michael Yang wrote:
> > On May 31, 1:44 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> >> Michael Yang wrote:
> >>> I'm working on parsing multiple messages out of one msf file(mbox
> >>> folder type).
> >>> I took the module of  Email::Folder to construct with msf file, and
> >>> then get the list of all messages contained in the msf file.
> >>> But, the msf file is considered as a wholly one message, not multiple
> >>> messages (actually I have multiple messages within the msf file)
>
> >> Does the file have proper message separators?
>
> > Actually I am not sure about what is the message separators the parser
> > uses. The msf file and its mail content is generated by Thunderbird
> > mail client locally.
>
> I run your code successfully on a Thunderbird generated mbox file.
>
> > Where can I get the rules on valid format of MBox file, so that I can
> > check if the file generated by Thunderbird is a valid one for
> > Email::Folder to parse.
>
> Note that you stated in the OP that you used a valid mbox folder type...
yes, I used the file generated thunderbird, so that .... I assumed it
is a valid one.
:) Finally it turned out I was wrong.
I forgot about that it was generated on Window platform as I mentioned
in the above replies.

Thanks to all!

>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl




------------------------------

Date: 31 May 2007 07:54:30 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Email::Folder->messages returns only one element
Message-Id: <1180623270.158292.190620@d30g2000prg.googlegroups.com>

On May 31, 7:09 pm, Christian Winter <thepoet_nos...@arcor.de> wrote:
> Michael Yang wrote:
> > I wrote another script to demonstrate my problems:
> >       1 #!/usr/bin/perl -w
> >       2 # Author: Michael Yang
> >       3 # Date: May/31/2007
> >       4 # Purpose: To test the function of Email::Folder module.
> >       5
> >       6 use strict;
> >       7 use warnings;
> >       8
> >       9 my @mail_list = @ARGV;
> >      10
> >      11 die "Usage: $0 <.msf file> \n" if not @mail_list;
> >      12
> >      13 eval { require Email::Folder; };
> >      14 die "The module Email::Folder is required for this script.\n"
> > if $!;
> >      15
> >      16 foreach my $file (@mail_list){
> >      17     if ($file =~ m/^(.*)\.msf$/i){
> >      18         $file = $1;
> >      19         print "$file MSF file detected.\n"
> >      20     }
> >      21     die "can't access import file $file" unless -r $file;
> >      22
> >      23     my $folder = Email::Folder->new($file);
> >      24
> >      25     my @msg_list = $folder->messages();
> >      26     foreach(@msg_list){
> >      27         print $_->header("Subject"), "\n";
> >      28         #   print $_->as_string(), "\n";
> >      29     }
> >      30 }
>
> > To run this script, one valid *.msf file is required to pass in, which
> > contains multiple messages.
> > In this script, it will print out each message's subject data.
> > The result on my pc is that there is only one subject is printed out.
>
> A possible cause could be recognition of line endings. Does the mbox
> file stem from a different platform, was it transported via ASCII-FTP?
> To check that, you can test with different values for the "eol"
> parameter to Email::Folder's constructor:.
>   # Windows-Format:
>   my $folder = Email::Folder->new( $file, "eol" => "\r\n" );
>   # Mac-Format:
>   # my $folder = Email::Folder->new( $file, "eol" => "\r" );
>   # Unix-Format:
>   # my $folder = Email::Folder->new( $file, "eol" => "\n" );
>
> -Chris- Hide quoted text -
>
> - Show quoted text -

Yeah, I think that's the problem.

I need to add the OS check at the beginning for different
construction.
Thanks to all of your guys.

Really appreciated your helps!!

Cheers!
Michael



------------------------------

Date: 31 May 2007 06:35:33 -0700
From: Brad Baxter <baxter.brad@gmail.com>
Subject: Re: FAQ 8.11 How do I decode encrypted password files?
Message-Id: <1180618533.798828.218060@p77g2000hsh.googlegroups.com>

On May 31, 3:03 am, PerlFAQ Server <b...@stonehenge.com> wrote:
> 8.11: How do I decode encrypted password files?
>
>     Seriously, you can't if they are Unix password files--the Unix password
>     system employs one-way encryption. It's more like hashing than
>     encryption. The best you can check is whether something else hashes to
>     the same string. You can't turn a hash back into the original string.
>     Programs like Crack can forcibly (and intelligently) try to guess
>     passwords, but don't (can't) guarantee quick success.

That third sentence doesn't sound quite right to me. What about this:

The best you can do is check whether something else hashes to the same
string.

--
Brad



------------------------------

Date: 31 May 2007 06:02:32 -0700
From: Brad Baxter <baxter.brad@gmail.com>
Subject: Re: FAQ 8.28 How can I call backticks without shell processing?
Message-Id: <1180616552.861311.309730@g4g2000hsf.googlegroups.com>

On May 30, 3:03 pm, PerlFAQ Server <b...@stonehenge.com> wrote:
> 8.28: How can I call backticks without shell processing?
>
>     Note that if you're use Microsoft, no solution to this vexing issue is
>     even possible. Even if Perl were to emulate fork(), you'd still be
>     stuck, because Microsoft does not have a argc/argv-style API.

s/use/using/;
s/a argc/an argc/;

--
Brad



------------------------------

Date: Thu, 31 May 2007 16:53:21 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: FAQ 8.28 How can I call backticks without shell processing?
Message-Id: <r8ot531j3hmndq6a6tp22mveq0q6chdqk9@4ax.com>

On 31 May 2007 06:02:32 -0700, Brad Baxter <baxter.brad@gmail.com>
wrote:

>>     Note that if you're use Microsoft, no solution to this vexing issue is
>>     even possible. Even if Perl were to emulate fork(), you'd still be
>>     stuck, because Microsoft does not have a argc/argv-style API.
>
>s/use/using/;
>s/a argc/an argc/;

Incidentally, doesn't perl now emulate fork under Windows?

  C:\temp>perl -le "print fork"
  -948
  0


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Fri, 1 Jun 2007 00:08:53 +0930
From: "Tom Storey" <tom@snnap.net>
Subject: fork() and script execution afterwards
Message-Id: <135tnfui60r5d9e@corp.supernews.com>

Ive got a question about script execution after a fork() which I havnt been
able to find an answer to on google yet, but Im still looking (Ive fork'd my
searching :-P)

I have this simple test script:

==========================
#!/usr/local/bin/perl

use strict;
my ($pid, $x, @child, $ischild);

print "BEGIN\n\n";

for ($x = 1; $x <= 5; $x++) {
        if (not defined($pid = fork())) {
                die "couldnt fork: \"$!\"\n";
        } elsif ($pid) {
                push(@child, $pid);
        } else {
                print "This is child $x starting at " . localtime() . "\n";
                sleep($x);
                print "Child $x terminating at " . localtime() . "\n";
                exit(0);
        }
}

foreach(@child) {
        waitpid($_, 0);
}

1;

==========================

Fiarly straight forward, and it works beautifully.

My question is, for each of the child processes that are spawned, I dont see
"BEGIN" outputted to the screen.

Is this because the "program counter" in each of the childs continues from
where it was in the parent too?

The reason I ask is because Ive been trying to devise a way of executing a
child process without actually beginning the whole script over again. This
is because in my real script I want to perform a database query to determine
just how many childs I need to fork to complete my process.

But now Im beginning to wonder whether I actually need to borhter trying to
avoid executing the top half of the script each time the child is spawned,
if the PC continues from where it was in the parent, the child will never
return to the beginning of the script. That would be so nice! :-)

If this is true, where I print BEGIN I could place my database code, and
replace the for loop with a while loop that runs through each database
record and forks a new child if neccessary.

Thanks,
Tom




------------------------------

Date: 31 May 2007 07:54:02 -0700
From: Andrew Fedyashov <andrew.fedyashov@gmail.com>
Subject: Re: fork() and script execution afterwards
Message-Id: <1180623241.972166.21690@p47g2000hsd.googlegroups.com>

On May 31, 5:38 pm, "Tom Storey" <t...@snnap.net> wrote:
> [...]
> If this is true, where I print BEGIN I could place my database code, and
> replace the for loop with a while loop that runs through each database
> record and forks a new child if neccessary.
>
> Thanks,
> Tom

what you want is just the way fork() works.



------------------------------

Date: Thu, 31 May 2007 17:01:20 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: fork() and script execution afterwards
Message-Id: <loot535k7fsjnieh9bbr09do9er9lrh5lj@4ax.com>

On Fri, 1 Jun 2007 00:08:53 +0930, "Tom Storey" <tom@snnap.net> wrote:

>My question is, for each of the child processes that are spawned, I dont see
>"BEGIN" outputted to the screen.

Well, only ONE "BEGIN" should be printed, since it is *before* the
fork(). Or am I missing something?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Thu, 31 May 2007 14:20:00 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: get mail by POP3Client?
Message-Id: <f3mi22$iml$1@south.jnrs.ja.net>

jck11 wrote:
> "Brian McCauley" <nobull67@gmail.com> 
> ???????:1180161544.937981.69820@k79g2000hse.googlegroups.com...
>> On 26 May, 04:33, "jck11" <j...@msr.pchome.com.tw> wrote:
>>
>> What do you mean "reserve one copy"?
>>
>> The POP3 protocol does not delete anything from the server unless you
>> do so explicitly.
>>
> 
> The code below download the mail from the server and delete the mail from 
> the server.
> I don't know why it delete the mail but it 's ture.
> Because why I run the code second tims, I can't get any mail.

Odd.  The docs for POP3Client suggest that you need to do a 
$pop3->Delete() to remove a message.  Maybe your POP3 server 
automatically flags any read message to be deleted?  If so then add:

$pop3->Reset()

before

> $pop3->Close();

and see if that works.

Simon.


------------------------------

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 V11 Issue 472
**************************************


home help back first fref pref prev next nref lref last post