[23297] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5517 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 17 18:05:50 2003

Date: Wed, 17 Sep 2003 15:05: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           Wed, 17 Sep 2003     Volume: 10 Number: 5517

Today's topics:
        Array slicing through a reference:  Inefficient? <ethan@draupnir.gso.saic.com>
    Re: Array slicing through a reference:  Inefficient? <tassilo.parseval@rwth-aachen.de>
    Re: Array slicing through a reference:  Inefficient? <pkent77tea@yahoo.com.tea>
    Re: copy list until... <pinyaj@rpi.edu>
    Re: copy list until... <uri@stemsystems.com>
    Re: copy list until... <brian_helterline@hp.com>
    Re: copy list until... <syscjm@gwu.edu>
    Re: current path <paanwa@hotmail.com>
    Re: current path (Tad McClellan)
        Database Record into a hash... (Donavon)
    Re: Database Record into a hash... (Tad McClellan)
        How do I change my directory back? (Victor)
    Re: illegal seek <flavell@mail.cern.ch>
    Re: kill command in a perl script (Daniel Berger)
    Re: OT:  WebGUI, any reviews? <dwilga-MUNGE@mtholyoke.edu>
    Re: OT:  WebGUI, any reviews? <glex_nospam@qwest.net>
        Problematic delay in script <ducott@hotmail.com>
    Re: Problematic delay in script (Tad McClellan)
    Re: Problematic delay in script (Tad McClellan)
    Re: Problematic delay in script (Beau Schwabe)
    Re: Problematic delay in script <ducott@hotmail.com>
    Re: Problematic delay in script <ducott@hotmail.com>
    Re: Problematic delay in script <usenet@dwall.fastmail.fm>
    Re: Problematic delay in script <ducott@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 17 Sep 2003 10:24:42 -0700
From: Ethan Brown <ethan@draupnir.gso.saic.com>
Subject: Array slicing through a reference:  Inefficient?
Message-Id: <vr1xufl44l.fsf@draupnir.gso.saic.com>

Dear Group--

I'm working on a project where I'm working with large arrays, and I'm
using references to pass arrays around to reduce memory use as much as
possible.  I often work with small subsets of a referenced array and
access it like:

my @subrange = @{$big_array_ref}[$start_idx .. $end_idx];

Also, to get the array size, I'll do:

my $num_points = @$big_array_ref;

Is this the best practice?  Do I need to be concerned in a statement
like

   @{$big_array_ref}[$start_idx .. $end_idx];

that the array referenced by $big_array_ref is being completely copied
before the subrange is taken?  Likewise for the $num_points example.

Thanks,

--Ethan Brown
--Keyboards: "The Fabulous Pelicans" (www.pelicans.com)
--In a band?  Use http://www.WheresTheGig.com for free.



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

Date: 17 Sep 2003 17:43:04 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Array slicing through a reference:  Inefficient?
Message-Id: <bka6f8$mea$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Ethan Brown:

> I'm working on a project where I'm working with large arrays, and I'm
> using references to pass arrays around to reduce memory use as much as
> possible.  I often work with small subsets of a referenced array and
> access it like:
> 
> my @subrange = @{$big_array_ref}[$start_idx .. $end_idx];
> 
> Also, to get the array size, I'll do:
> 
> my $num_points = @$big_array_ref;
> 
> Is this the best practice?  Do I need to be concerned in a statement
> like
> 
>    @{$big_array_ref}[$start_idx .. $end_idx];
> 
> that the array referenced by $big_array_ref is being completely copied
> before the subrange is taken?  Likewise for the $num_points example.

There is no need to worry here. If you have a reference to an array,
this means that the actual array also exists somewhere and you just
happen to access it through a reference. You're not duplicating any
arrays and no temporary huge arrays are built either.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 17 Sep 2003 20:44:43 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Array slicing through a reference:  Inefficient?
Message-Id: <pkent77tea-B2C094.20444217092003@pth-usenet-02.plus.net>

In article <vr1xufl44l.fsf@draupnir.gso.saic.com>,
 Ethan Brown <ethan@draupnir.gso.saic.com> wrote:

> Is this the best practice?  Do I need to be concerned in a statement
> like
> 
>    @{$big_array_ref}[$start_idx .. $end_idx];
> 
> that the array referenced by $big_array_ref is being completely copied
> before the subrange is taken?  Likewise for the $num_points example.

As far as I know - but I haven't read the friendly source - the array is 
not copied. In other words you're saying to perl "give me the slice 
$start to $end from the array _pointed to_ by $arrayref". So I'd say to 
you: don't worry , I think you're doing things the right way

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: Wed, 17 Sep 2003 11:17:10 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: copy list until...
Message-Id: <Pine.SGI.3.96.1030917110915.394136A-100000@vcmr-64.server.rpi.edu>

On Wed, 17 Sep 2003, Dave Saville wrote:

>On Wed, 17 Sep 2003 09:55:26 -0400, Jeff 'japhy' Pinyan wrote:
>
>>>my @presidents = ( 'Roosevelt' , 'Kennedy' , 'Reagan' , 'Clinton' , 'Bush' , 'Jenna Jameson' );
>>>my @oldpresidents;
>>
>>  @oldpresidents = grep { "true" .. $_ eq "Bush" } @presidents
>
>I was trying to understand how this worked but it seems it does not :-)

Wow, I did so many wrong things.  I thought the operand had to be numeric
for Perl to implicitly compare it to $., and I expected scalar context IN
the grep (shouldn't it be?), and I thought the flip-flop operator would
work in this case.  It doesn't seem to work easily.

Sorry I didn't test that code...

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Wed, 17 Sep 2003 18:37:40 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: copy list until...
Message-Id: <x765jrxnuz.fsf@mail.sysarch.com>

>>>>> "J'P" == Jeff 'japhy' Pinyan <pinyaj@rpi.edu> writes:

  >>> @oldpresidents = grep { "true" .. $_ eq "Bush" } @presidents
  >> 
  >> I was trying to understand how this worked but it seems it does not :-)

  J'P> Wow, I did so many wrong things.  I thought the operand had to be numeric
  J'P> for Perl to implicitly compare it to $., and I expected scalar context IN
  J'P> the grep (shouldn't it be?), and I thought the flip-flop operator would
  J'P> work in this case.  It doesn't seem to work easily.

grep EXPR is done in scalar context but the block provides list context
it seems. i don't think that is comparing anything to $. the problem is
 .. in list context is trying to make a range of vals from 'true' to
undef or whatever eq returns as false. so list .. barfs since one of the args
is a string and the other is a number.

and with a little fooling around i can't seem to get the .. to work
either. i think it seems to be freshly evaluated when entering the block
so it gets reset. not sure. but i have used scalar .. many times in
plain conditionals.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: Wed, 17 Sep 2003 12:26:54 -0700
From: "Brian Helterline" <brian_helterline@hp.com>
Subject: Re: copy list until...
Message-Id: <3f68b60e$1@usenet01.boi.hp.com>


<jimbo@jimbo.com> wrote in message
news:3f6860f0$0$58715$e4fe514c@news.xs4all.nl...
> Hi,
>
> I would like to copy the list of presidents up to but not including
current or
> future presidents (not for any particular reason):
>
> my @presidents = ( 'Roosevelt' , 'Kennedy' , 'Reagan' , 'Clinton' , 'Bush'
, 'Jenna Jameson' );

Last I checked, there is a 'Bush' on both sides on 'Clinton'


--
brian




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

Date: Wed, 17 Sep 2003 16:54:27 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: copy list until...
Message-Id: <3F68CA03.5000205@gwu.edu>

Brian Helterline wrote:
> 
> Last I checked, there is a 'Bush' on both sides on 'Clinton'
> 
Isn't there always?

                     Chris Mattern



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

Date: Wed, 17 Sep 2003 13:20:53 -0400
From: "Paanwa" <paanwa@hotmail.com>
Subject: Re: current path
Message-Id: <3f689802$0$12616$a0465688@nnrp.fuse.net>


"Jochen Friedmann" <jochen.friedmann2@de.bosch.com> wrote in message
news:bk9jel$nic$1@ns2.fe.internet.bosch.com...
> Hello together,
>
> how can I find the current path my Perlscript is started ?
>
> Jochen
>
>

You can also get this information from Environment Variables....check out
http://www.devdaily.com/perl/edu/articles/pl020001.shtml

PAW




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

Date: Wed, 17 Sep 2003 12:50:50 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: current path
Message-Id: <slrnbmh7nq.84q.tadmc@magna.augustmail.com>

Paanwa <paanwa@hotmail.com> wrote:
> "Jochen Friedmann" <jochen.friedmann2@de.bosch.com> wrote in message
> news:bk9jel$nic$1@ns2.fe.internet.bosch.com...


>> how can I find the current path my Perlscript is started ?


> You can also get this information from Environment Variables....check out
> http://www.devdaily.com/perl/edu/articles/pl020001.shtml


Perl is not CGI.

The OP made no mention of what environment his Perl program runs in...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 17 Sep 2003 11:38:04 -0700
From: djlerman@yahoo.com (Donavon)
Subject: Database Record into a hash...
Message-Id: <97ba267a.0309171038.79aeef1e@posting.google.com>

I am trying to load a database into a HASH of HASH.  For some reason
every instance of the HASH only contains the data from the last record
pulled?

So I have a 1000 copies of the same information with different HASH
keys.
Any suggestions??

 ...
 ...
 ...
# loads a record into a hash
while ($data = $sth->fetchrow_hashref) {

	%record = %$data;
	$key = $record{'ProjectNumber'};
	$hash{$key} = \%record;

};

$sth -> finish;
$dbh -> disconnect
	or warn "Disconnection failed: $DBI::errstr\n";

# prints out content of HASH
foreach $key1 (keys %hash) {
	print 'Level 1: ' . $key1 . "<BR>";

	foreach $key2 (keys %{$hash{$key1}}) {
		print $key2 . '=>' . $hash{$key1}{$key2} . "<BR>";
	};
};


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

Date: Wed, 17 Sep 2003 14:17:44 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Database Record into a hash...
Message-Id: <slrnbmhcqo.89l.tadmc@magna.augustmail.com>

Donavon <djlerman@yahoo.com> wrote:

> I am trying to load a database into a HASH of HASH.  For some reason
> every instance of the HASH only contains the data from the last record
> pulled?

> Any suggestions??


   use strict;


> 	%record = %$data;


   my %record = %$data;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 17 Sep 2003 14:58:39 -0700
From: gvictor97@yahoo.com (Victor)
Subject: How do I change my directory back?
Message-Id: <ab759f.0309171358.214bab39@posting.google.com>

1- create dir dd1
2- chdir to dd1
3- do things
4- chdir back to original dir
5- create dir dd2
6- chdir to dd2
7- do things

But, chdir to prev dir does not happen at step 4. 
The second dir at step 5 is actually gets created 
in dir dd1.

Here is the part of code:

$mydir = `pwd`;
&s1;
&s2;

sub s1 {
system "mkdir dd1";
chdir "dd1";
 ....
 ....
chdir $mydir;

}

sub s2 {
system "mkdir dd2";
chdir "dd2";
 ....
 ....
chdir $mydir;
}

Any help will be highly appreciated.
Thanks,
-V


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

Date: Wed, 17 Sep 2003 18:00:08 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: illegal seek
Message-Id: <Pine.LNX.4.53.0309171745460.16943@lxplus019.cern.ch>


Hi,

On Wed, Sep 17, news@roaima.freeserve.co.uk inscribed on the eternal scroll:

> Alan J. Flavell <flavell@mail.cern.ch> wrote:
> > Well, for the moment I second Chris's proposal, since, as you imply,
> > a more thoroughgoing answer may be too much to ask for.
>
> So where do we go from here?

Yeah, this one does seem to have flown as well as the proverbial lead
balloon, doesn't it?   I still think it's something that would be
useful, but I equally think that my first draft was too big.  I was
hoping for a second opinion to get the text more compact.

> Do you simply send your text as a patch to
> the doc maintainers?  Or does it need a consensus?

Judging from my last attempt to update a Perl FAQ (which languished
for quite some time, then was finally pushed through by brian d foy,
whose attention is I gather currently focussed on other matters...),
it does seem as if some supporting voices are better than mere
technical accuracy :-}

I'm willing to give it my best shot, but I'll have to find a time slot
to verify the procedure... unless someone cares to help me out with
it. What with major worm-fighting battles, fixing security bugs in
OSes, and a dept that expects a full day's work on top of all that,
I'm a bit zonked-out at the moment, tbh.

Cheers



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

Date: 17 Sep 2003 08:39:39 -0700
From: djberg96@hotmail.com (Daniel Berger)
Subject: Re: kill command in a perl script
Message-Id: <6e613a32.0309170739.2037fa99@posting.google.com>

"John W. Krahn" <krahnj@acm.org> wrote in message news:<3F680157.65BFBE0C@acm.org>...
> Ted Zlatanov wrote:
> > 
> > [lots of awkward ps -ef gymnastics omitted]
> > 
> > Good god, guys, why are you stubbornly trying to reinvent the wheel?
> > I mean, it's fun to do it sometimes, but Hugh (a new Perl programmer)
> > should absolutely not be trying to manually parse the output of
> > ps -ef, creating a nonportable script with weird bugs (what happens
> > if "grep" is in the process name you want, for instance?  what happens
> > on systems where ps -ef does not do what you think it does?)
> > 
> > Please use Proc::ProcessTable from CPAN.  It will save you time and
> > lots of headaches.
> 
> $ cat Proc-ProcessTable-0.38/README
> Proc::ProcessTable, version .38
> 
> STATUS
> ======
> This is BETA software; it seems to work, but use at your own risk :) 
> [snip]

Dan should really remove that.  His code has been around long enough,
and is stable enough, that I consider it production quallity.  Having
ported some of his code to Ruby, I can tell you that it's trustworthy,
i.e. passes all tests, no memory leaks, and does what it's supposed to
do.

> If that's not enough of a reason the module requires a C compiler to
> install and all the C code does (on FreeBSD, IRIX, DecOSF, NetBSD,
> Linux, UnixWare and Solaris) is access the /proc file system

It requires a C compiler - so what?  If you're on *BSD or Linux,
you've almost certainly have gcc anyway.  Solaris users will likely
have some compiler (gcc or Sun's Forte compiler).  I can't speak for
UnixWare, IRIX or DecOSF.

In addition, reading out of /proc for Linux and *BSD is simple enough
with pure Perl, but it will still be faster with C.  Parsing /proc
with pure Perl would be quite a challenge on Solaris, considering that
the information in /proc is NOT in plaintext format.
 
> A code example from ProcessTable.pm
> 
> sub _get_tty_list 
> {
>   my ($self) = @_;
>   undef %Proc::ProcessTable::TTYDEVS;
>   find({ wanted => 
>        sub{
>      $File::Find::prune = 1 if -d $_ && ! -x $_;
>      my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
>         $atime,$mtime,$ctime,$blksize,$blocks) =
> stat($File::Find::name);
>      $Proc::ProcessTable::TTYDEVS{$rdev} = $File::Find::name
>        if(-c $File::Find::name);
>        }, no_chdir => 1},
>        "/dev" 
>       );
> }
> 
> 
> Why are they stat()ing the same file FOUR times?

Hmm....I don't remember this code, so I can't say much about it.  The
author, Dan Urist, would probably be willing to explain this code if
you ask him.
 
> Not that I'm against using modules.  :-)  I just like to know what all
> my options are.
> 
> 
> John

Your choices are to parse 'ps' (blech) or use Proc::ProcessTable.  As
others have noted, parsing ps is utterly unreliable and not portable
because the options are different on different platforms, and
sometimes they're different on the *same* platform between releases. 
You can always submit pure Perl patches to Dan for Linux and the *BSD
family if the C compiler thing really bothers you that much.  Wouldn't
be that difficult.

If there's any "flaw" to Dan's code it's that he added the formatting
cruft, presumably because ps gives you output formatting options. 
I'll bet if he had to do it over again, he would rip that out, but
that's just a guess.  I can tell you that *I* will never add it. :)

Regards,

Dan (Berger)


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

Date: Wed, 17 Sep 2003 15:45:45 GMT
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: OT:  WebGUI, any reviews?
Message-Id: <dwilga-MUNGE-61C7FD.11454317092003@nap.mtholyoke.edu>

In article <e7774537.0309170624.20bf1f1@posting.google.com>,
 Prab_kar@hotmail.com (Prabh) wrote:

> Hello all,
> I know its not strictly PERL, but hey, WebGUI *was* developed in PERL
> :)
> I'm trying to find any reviews for the open-source , content
> management system, WebGUI and am unable to find many.
> 
> I'm interested to know if any of you here have used it and your
> experiences with it.
> 
> Amongst other things, I'm particularly interested in:
> 1) How safe is it?
> 2) Do I need to send my docs off-site?
> 3) How different is it from Xerox's DocUShare.
> 4) Your general experience with it, would you recommend it?

Last I checked, the source code is available. Why not download it and 
try it for yourself?

-- 
Dan Wilga          dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **


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

Date: Wed, 17 Sep 2003 12:09:28 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: OT:  WebGUI, any reviews?
Message-Id: <0x0ab.58$QC1.38102@news.uswest.net>

Dan Wilga wrote:
> In article <e7774537.0309170624.20bf1f1@posting.google.com>,
>  Prab_kar@hotmail.com (Prabh) wrote:
> 
> 
>>Hello all,
>>I know its not strictly PERL, but hey, WebGUI *was* developed in PERL
>>:)
>>I'm trying to find any reviews for the open-source , content
>>management system, WebGUI and am unable to find many.
>>
>>I'm interested to know if any of you here have used it and your
>>experiences with it.
>>
>>Amongst other things, I'm particularly interested in:
>>1) How safe is it?
>>2) Do I need to send my docs off-site?
>>3) How different is it from Xerox's DocUShare.
>>4) Your general experience with it, would you recommend it?
> 
> 
> Last I checked, the source code is available. Why not download it and 
> try it for yourself?
> 

Possibly Bricolage may be a better/more supported alternative, if you're 
looking for an open-source CMS:

http://www.bricolage.cc



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

Date: Wed, 17 Sep 2003 18:58:01 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Problematic delay in script
Message-Id: <Z82ab.971080$ro6.19191750@news2.calgary.shaw.ca>

Hello, I have created a mailing program for our company that sends out
emails to our client database. There seems to be a delay in the script or
the processing of the emails. Here is how it works. The email addresses are
stored in a simple text file, one on top of each other. Each email is sent
through a foreach loop. I use this code to get email addresses and send the
emails:

open (ADDRESSES, "<address.txt") or die "Can't open file: $!";
  @list=<ADDRESSES>;
close(ADDRESSES);

$mailprog="/usr/sbin/sendmail -t";

foreach $list (@list) {
chomp ($list);
($name,$email)=split(/\|/,$list);

open (MAIL, "|$mailprog") or die "Can't open main program: $!";
print MAIL "From: $adminname <$adminemail>\n";
print MAIL "To: $fullname <$email>\n";
print MAIL "Subject: $subject\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "X-MSMail-Priority: $priority\n";
print MAIL "Content-Type: multipart/alternative;\n";
print MAIL "  boundary=\"separator\"\n\n";
print MAIL "This is a multi-part message in MIME format.\n\n";
print MAIL "--separator\n";
print MAIL "Content-Type: text/plain;\n";
print MAIL " charset=\"iso-8859-1\"\n\n";
print MAIL "@textonly\n\n";
print MAIL "--separator\n";
print MAIL "Content-Type: text/html;\n";
print MAIL " charset=\"iso-8859-1\"\n\n";
print MAIL "@content\n\n";
print MAIL "--separator--";
close (MAIL);
}

print "Confirmation Message";

For testing purposes, the address.txt file contains 100 email addresses ...
all different, but in the end end up in my inbox ... so if I recieve 100
emails the script works. Well it does ... I do get the 100 emails but heres
the thing ... almost right away I get about 60-70 emails ... but then the
other 30 seem to get delivered at random intervals. Some take 5 minutes,
some take 5 hours. I am puzzled why so many take so long to get delivered?
Am I overloading sendmail? or maybe my email account? Your
thoughts/reccommendations are appriciated.

Randy




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

Date: Wed, 17 Sep 2003 14:19:52 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problematic delay in script
Message-Id: <slrnbmhcuo.89l.tadmc@magna.augustmail.com>

\"Dandy\" Randy <ducott@hotmail.com> wrote:

> Hello, I have created a mailing program for our company that sends out
> emails to our client database. 

> Your
> thoughts/reccommendations are appriciated.


   use Mail::Bulkmail;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 17 Sep 2003 14:22:05 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problematic delay in script
Message-Id: <slrnbmhd2t.89l.tadmc@magna.augustmail.com>

\"Dandy\" Randy <ducott@hotmail.com> wrote:

> print MAIL "@content\n\n";


That adds space characters to the body of the email message.

Is that what you want it to do?



   perldoc -q spaces

      Why do I get weird spaces when I print an array of lines?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 17 Sep 2003 19:19:57 GMT
From: bschwabe@atlanta.nsc.com (Beau Schwabe)
Subject: Re: Problematic delay in script
Message-Id: <3f68b315.19230392@usenet.nsc.com>

Just for test... try halving your database....i.e. send two chunks of
50 emails.   Does the first 50 go through ok? The second? or does it
stop at 20 or so and spit the remainder 30 out at intermittent
intervals?

-Beau Schwabe

>Hello, I have created a mailing program for our company that sends out
>emails to our client database. There seems to be a delay in the script or
>the processing of the emails. Here is how it works. The email addresses are
>stored in a simple text file, one on top of each other. Each email is sent
>through a foreach loop. I use this code to get email addresses and send the
>emails:
>
>open (ADDRESSES, "<address.txt") or die "Can't open file: $!";
>  @list=<ADDRESSES>;
>close(ADDRESSES);
>
>$mailprog="/usr/sbin/sendmail -t";
>
>foreach $list (@list) {
>chomp ($list);
>($name,$email)=split(/\|/,$list);
>
>open (MAIL, "|$mailprog") or die "Can't open main program: $!";
>print MAIL "From: $adminname <$adminemail>\n";
>print MAIL "To: $fullname <$email>\n";
>print MAIL "Subject: $subject\n";
>print MAIL "MIME-Version: 1.0\n";
>print MAIL "X-MSMail-Priority: $priority\n";
>print MAIL "Content-Type: multipart/alternative;\n";
>print MAIL "  boundary=\"separator\"\n\n";
>print MAIL "This is a multi-part message in MIME format.\n\n";
>print MAIL "--separator\n";
>print MAIL "Content-Type: text/plain;\n";
>print MAIL " charset=\"iso-8859-1\"\n\n";
>print MAIL "@textonly\n\n";
>print MAIL "--separator\n";
>print MAIL "Content-Type: text/html;\n";
>print MAIL " charset=\"iso-8859-1\"\n\n";
>print MAIL "@content\n\n";
>print MAIL "--separator--";
>close (MAIL);
>}
>
>print "Confirmation Message";
>
>For testing purposes, the address.txt file contains 100 email addresses ...
>all different, but in the end end up in my inbox ... so if I recieve 100
>emails the script works. Well it does ... I do get the 100 emails but heres
>the thing ... almost right away I get about 60-70 emails ... but then the
>other 30 seem to get delivered at random intervals. Some take 5 minutes,
>some take 5 hours. I am puzzled why so many take so long to get delivered?
>Am I overloading sendmail? or maybe my email account? Your
>thoughts/reccommendations are appriciated.
>
>Randy
>
>



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

Date: Wed, 17 Sep 2003 19:38:37 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Re: Problematic delay in script
Message-Id: <1L2ab.167822$la.3488616@news1.calgary.shaw.ca>

Yes, this \n\n is required at the end of the html body content, otherwise
the multipart html will send process the separators correctly.

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnbmhd2t.89l.tadmc@magna.augustmail.com...
> \"Dandy\" Randy <ducott@hotmail.com> wrote:
>
> > print MAIL "@content\n\n";
>
>
> That adds space characters to the body of the email message.
>
> Is that what you want it to do?
>
>
>
>    perldoc -q spaces
>
>       Why do I get weird spaces when I print an array of lines?
>
>
> -- 
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Wed, 17 Sep 2003 19:39:11 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Re: Problematic delay in script
Message-Id: <zL2ab.167825$la.3488636@news1.calgary.shaw.ca>

>    use Mail::Bulkmail;

I do not believe my hosting company had this module installed.

R




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

Date: Wed, 17 Sep 2003 20:09:49 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Problematic delay in script
Message-Id: <Xns93F9A46CFDBC6dkwwashere@216.168.3.30>

[TOFU rearranged to proper chronological order.  Please don't do 
that.]

"Dandy" Randy <ducott@hotmail.com> wrote:

> 
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnbmhd2t.89l.tadmc@magna.augustmail.com...
>> \"Dandy\" Randy <ducott@hotmail.com> wrote:
>>
>> > print MAIL "@content\n\n";
>>
>>
>> That adds space characters to the body of the email message.
>>
>> Is that what you want it to do?
>>
>>
>>    perldoc -q spaces
>>
>>       Why do I get weird spaces when I print an array of lines?

> Yes, this \n\n is required at the end of the html body content,
> otherwise the multipart html will send process the separators
> correctly. 

The "\n\n" is not what Tad was talking about.  If you read the FAQ 
entry he referred to you'll see what Tad was asking.

-- 
David Wall


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

Date: Wed, 17 Sep 2003 22:01:42 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Re: Problematic delay in script
Message-Id: <aR4ab.971590$ro6.19198897@news2.calgary.shaw.ca>

"Beau Schwabe" <bschwabe@atlanta.nsc.com> wrote
news:3f68b315.19230392@usenet.nsc.com...
> Just for test... try halving your database....i.e. send two chunks of
> 50 emails.   Does the first 50 go through ok? The second? or does it
> stop at 20 or so and spit the remainder 30 out at intermittent
> intervals?

Beau, I did a test a you suggested ...

Test #1
Sent: 50 emails all to my inbox
Result: All 50 delivered timely ... within 30 seconds

--- Waiting 2 minutes before next test

Test #2
Sent: 50 emails all to my inbox (again, same addresses)
Result: 49 delivered timely ... within 30 seconds. 1 email has not arrived.
most likely will at some point

--- Waiting 2 minutes before next test

Test #3
Sent: 100 emails all to my inbox (same addresses)
Result: 85 delivered timely ... within 30 seconds. 15 emails have not
arrived.




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

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.  

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 5517
***************************************


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