[18111] in Perl-Users-Digest
Perl-Users Digest, Issue: 271 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 12 03:05:47 2001
Date: Mon, 12 Feb 2001 00:05:13 -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: <981965113-v10-i271@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 12 Feb 2001 Volume: 10 Number: 271
Today's topics:
На: sending attachments <ivanovsky_michael@hotmail.com>
A problem with sockets <anthonyc@mincom.com>
Re: A problem with sockets <jdf@pobox.com>
Data storage format. Help needed. <jonni@ifm.liu.se>
flock() strategy for Win95? - eval() etc <mkruse@netexpress.net>
Re: flock() strategy for Win95? - eval() etc <godzilla@stomp.stomp.tokyo>
Re: Getopts? <jdf@pobox.com>
Re: Getopts? (Chris Fedde)
Re: How to retrieve local machine ip address <jbuff1856@my-deja.com>
Re: LWP::Simple hangs? <brentdax1_@_earthlink.net>
more eval madness- need help <anon9266@hushmail.com>
Re: more eval madness- need help (Chris Fedde)
Re: more eval madness- need help <anon9266@hushmail.com>
Re: more eval madness- need help <jdf@pobox.com>
Re: NDBM_File and ndbm.h (Garry Williams)
Net::FTP - incomplete file transfer problem <eburger@my-deja.com>
Re: Net::FTP - incomplete file transfer problem <jdf@pobox.com>
Re: Net::FTP error - timeout on put() <lawrenceang@my-deja.com>
Re: Newbie's Stuck <peter.sundstrom-eds@eds.com>
Re: Perl CGI script & sendmail - timeout? (Chris Fedde)
postgres perl problem <to.da@spray.se>
Re: Really weird errors (Resolution) <brentdax1_@_earthlink.net>
Really weird errors <brentdax1_@_earthlink.net>
Re: Really weird errors (Chris Fedde)
reg exp question <johnm@acadiacom.net>
Re: reg exp question <wyzelli@yahoo.com>
Re: reg exp question (Garry Williams)
Re: reg exp question (Ben Okopnik)
Re: reg exp question (Garry Williams)
Re: reg exp question (Garry Williams)
Re: reg exp question <wyzelli@yahoo.com>
Re: reg exp question <godzilla@stomp.stomp.tokyo>
Re: sending attachments <peter.sundstrom-eds@eds.com>
TCP server <leekembel@hotmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 9 Feb 2001 17:33:28 +0300
From: "Michael Ivanovsky" <ivanovsky_michael@hotmail.com>
Subject: На: sending attachments
Message-Id: <967t59$2t04$1@serv2.vsi.ru>
use Mail::Sender;
$sender = new Mail::Sender{smtp => 'tl.ru', from => $frommessage, b_charset
=> 'Windows-1251'};
$sender->MailFile({to => $tomail, b_charset => 'Windows-1251', subject =>
$subj, msg => $bodymail, file => $filename}) or $returnmsg = "Can't send
message: $Mail::Sender::Error!\n";
$sender->Close or $returnmsg = "Can't send message:
$Mail::Sender::Error!\n";
"Troy Boy" <troyr@vicnet.net.au> сообщил/сообщила в новостях следующее:
news:jOHg6.146$FU5.4421@ozemail.com.au...
> Hi there,
> What module can be used for sending mail attachments?
>
> Does anyone have a pointer to a perldoc i can look at (which explains
adding
> attachments not just sending plain text messages) or an example?
>
> Cheers
>
> --
> ----------------------------------------------------------------
> Troy Rasiah
> Melbourne, Aus
>
>
------------------------------
Date: Mon, 12 Feb 2001 15:45:24 +1000
From: "Anthony Carbone" <anthonyc@mincom.com>
Subject: A problem with sockets
Message-Id: <967t75$9k6$1@sol.mincom.oz.au>
I have a problem when I use a socket as a two way pipe. Using IO::Socket, I
typically set up a server process listening on the socket waiting for
clients to connect.
if ($Client = $Server->accept()) {
$Client->autoflush(1);
$request = <$Client>;
When a client connects and writes, I read in the information and send a
confirmation back to the waiting client on the same socket.
print $Client $data;
However, if the client disappears before I get a chance to write back, the
server program crashes out - Nasty. I've been trying to find a method that
will test the client handle to see if it is still a valid connection to the
socket before
I do the write, but to no avail.
I've tried methods/functions within IO::Socket, IO::Handle, socket etc. The
closest I got was actually with function 'eof HANDLE', which fails if the
client handle is not vaild but BLOCKS if it is thus hanging the server
script.
A suggestion from this news group was to try the select 4 parameter
function. This
does not work either because I suspect that the FILEHANDLE is still valid
even
though the socket has been destroyed underneath it.
Any other suggestions ?
thanks in advanced.
anthonyc
------------------------------
Date: 12 Feb 2001 02:20:27 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: A problem with sockets
Message-Id: <ofw81i6c.fsf@pobox.com>
"Anthony Carbone" <anthonyc@mincom.com> writes:
> However, if the client disappears before I get a chance to write
> back, the server program crashes out - Nasty.
Do you mean that the program crashes, or that it throws an exception?
Those are two completely different things.
You might try putting the read in an eval {} block, as documented in
perlfunc. This serves as Perl's exception catching mechanism.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 12 Feb 2001 08:35:13 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Data storage format. Help needed.
Message-Id: <9683ll$2bc$1@newsy.ifm.liu.se>
I'm working with a database with a format like this.
$data={'types' => [qw(number number text CAS text text)],
'titles' => [qw(mp bp name cas synonyms comments],
'data' => [ \@mps, \@bps, \@names, \@cass, \@synonymss,
\@comments]
}
I'm storing and reading that data to and from disk using a fromat that I've
invented myself.
Now, I know there are more "standard" dataformats for storage (or ties)
supplied by modules. Can somone point me to what kind of database/module
that could fit my needs. There are about 1000 records, and everytime the
script is run via a web-interface, the whole database must be searched for
keywords using methods which depend on the fields in 'types'.
Actually i know nothing about databases so any hint or suggestion would be
appreciated.
And another question. Are there any OO modules that could handle my database
nicely and which would support userdefined search methods?
Maybe a bit of fuzzy questions, but that depends on that I'm new to both OOP
and databases. Please direct my to relevant reading.
/jN
--
_____________________ _____________________
| Jonas Nilsson | | |
|Linkoping University | | Telephone |
| IFM | | --------- |
| Dept. of Chemistry | | work: +46-13-285690 |
| 581 83 Linkoping | | fax: +46-13-281399 |
| Sweden | | home: +46-13-130294 |
|_____________________| |_____________________|
------------------------------
Date: Mon, 12 Feb 2001 04:51:57 GMT
From: "Matt Kruse" <mkruse@netexpress.net>
Subject: flock() strategy for Win95? - eval() etc
Message-Id: <NZJh6.114410$P5.2589875@news1.rdc1.il.home.com>
In previous versions of ActivePerl for Windows, any flock() call would die
in Win95.
With the current version, it doesn't cause any errors but instead just does
nothing.
I currently wrap the flock() call in an eval() to trap errors, but $@ is now
null after the flock() call. So, if the user is running in a Win95
environment, there is no way to tell that the flock failed!
I would like to trap the failure and do a crude work-around to do file
locking on win95, but I can't do this unless I trap the case where flock
doesn't work. And I'd rather not check the OS that the user is running in
case the same things happen in mac or other OS's, or in case flock does
begin working in a future version of ActivePerl.
Is there a preferred method to handle this?
Matt Kruse
http://www.mattkruse.com/
------------------------------
Date: Sun, 11 Feb 2001 23:24:55 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: flock() strategy for Win95? - eval() etc
Message-Id: <3A878FC7.3EF7A051@stomp.stomp.tokyo>
Matt Kruse wrote:
> In previous versions of ActivePerl for Windows, any flock() call would die
> in Win95. With the current version, it doesn't cause any errors but instead
> just does nothing.
(snipped)
Traditional file lock is not supported on Win 9.x systems.
Have a look at this page for an answer:
http://language.perl.com/newdocs/pod/perlopentut.html#File_Locking
Godzilla!
------------------------------
Date: 11 Feb 2001 22:45:30 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Getopts?
Message-Id: <1yt436p1.fsf@pobox.com>
jdb@ga.prestige.net writes:
> I am in need of a example or a url to a good example of getopts
> usage.
I have placed on the web a html-ized version of a brief Microsoft Word
document I wrote as an introduction to getopts for a class.
http://pobox.com/~jdf/options.html
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 12 Feb 2001 05:41:22 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Getopts?
Message-Id: <6IKh6.59$zN2.183124992@news.frii.net>
In article <3A86047D.73B4C945@ga.prestige.net>, <jdb@ga.prestige.net> wrote:
>-=-=-=-=-=-
>
>I am in need of a example or a url to a good example of getopts usage.
>So say if the user does not run the program with Name -flags -more
>flag's.. USAGE: blah -t -v.. etc.. Thanks ahead
>
The manual pages have a wealth of data about this. If you don't have them
locally you can look at
http://www.perldoc.com/perl5.6/lib/Getopt/Long.html
Another module that can be very useful when writing scripts with lots of
options is Pod::Usage.
good luck
chris
--
This space intentionally left blank
------------------------------
Date: Mon, 12 Feb 2001 02:47:25 GMT
From: jbuff <jbuff1856@my-deja.com>
Subject: Re: How to retrieve local machine ip address
Message-Id: <967irr$30h$1@nnrp1.deja.com>
In article <16370-3A86DF15-53@storefull-246.iap.bryant.webtv.net>,
dennis100@webtv.net (BUCK NAKED1) wrote:
> just wanted to let your know that not all internet surfers have static
> IP addresses. For example, on WebTV, our IP number changes every time
we
> log on.
>
> Regards,
> Dennis
>
>
Actually, WebTV (and AOL) use IPs in rotation. Successive requests from
the same client in the same session may use several different IPs.
-- jbuff
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 12 Feb 2001 05:19:42 GMT
From: "Brent Dax" <brentdax1_@_earthlink.net>
Subject: Re: LWP::Simple hangs?
Message-Id: <OnKh6.1353$kG2.151994@newsread1.prod.itd.earthlink.net>
Hash: SHA1
<cgould@gate.net> wrote in message
news:966mf8$cdi$1@nnrp1.deja.com...
> Simplified server-side web script for perl:
>
> #!/usr/local/bin/perl -w
> use CGI;
> use strict;
> use LWP::Simple;
>
> # OOP for CGI
> my $q = new CGI;
> my $urlname = $q -> param ('url');
> if ($urlname =~ /http\:/) { } else {die();}
> print $q -> header or die();
> my $content = get($urlname) or die("Net error!");
> print $content or die("$!");
> #END
>
> On occasions, this script seems to hang without being killed off.
> This leads to annoyingly large amounts of CPU time and memory
> usage. Can anyone think of a reason for this?
Hmm...do you know where this script hangs? It may be hanging on
get(), in which case you're looking at a net problem. I'd suggest
doing something like this:
warn "approaching get()";
my $content = get($urlname) or die("Net error!");
warn "passed get()";
If you see "approaching get()" on STDERR but not "passed get()", it's
hanging on the get() command. If you see both, it's hanging
somewhere after; if you don't see either, it's hanging before.
What version of Perl are you using? Paste the results of perl -v
into messages asking for help from now on.
Oh yeah, one more thing:
if ($urlname =~ /http\:/) { } else {die();}
is pretty ugly. I'd suggest something like:
die unless($urlname =~ m#http\:#); #fewer brackets, no Leaning
Toothpick Syndrome
BTW, this is not that newbie of a question. It took me a few minutes
to figure out what you were this code was supposed to do.
- --Brent Dax
brentdax1@earthlink.net
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBOodyWbJgQ5JqNEGyEQJsbwCgiXqeK4ILQDKKSEKx3/N3ALadCMMAn3m8
PjzdGYgYGiIaDyTE91mX9snQ
=kgJt
-----END PGP SIGNATURE-----
------------------------------
Date: 12 Feb 2001 05:22:16 GMT
From: "AC" <anon9266@hushmail.com>
Subject: more eval madness- need help
Message-Id: <967ru8$km4@dispatch.concentric.net>
Hi folks,
I'm having a bear of a time trying to get a particular variable
expansion to work. I have looked at the perldoc -q 'expand variables'
and the perl cookbook, but I still cannot get it to work. So my situation
is this: I have a script which looks something like this:
use lib 'my/lib/path';
use myPackage;
my ($username,$uid,$gid,$gecos,$homedir,$shell);
$user = "joeblow";
@user_attrs = ('username','uid','gid','gecos','homedir','shell');
# list_users returns a perlref to a hash, so we have to access
# variable values with a double dollar like so
# print "$$uid{$username}"
($username,$uid,$gid,$gecos,$homedir,$shell) = list_users();
Now I want to save some lines of code, by looking through the
attributes and evaluating "$nis_<attribute_name>{$user}.
I have been trying something like this:
foreach my $t (@user_attrs) {
my $tmp;
$tmp = "\$\$" . "$t" . "\{$user\}";
print "BEFORE: $tmp\n";
$tmp =~ s/(\$\$\S+$)/$1/g;
print "AFTER: $tmp\n";
}
But this does not work, it will not evaluate "$$username{$user}" to its
actual value. I have tried experimenting with more "e"'s and
different s// syntax, but $tmp always becomes blank. Can someone clue me
in on the right way to do something like this? Please respond by email as
well. Thanks in advance!
--Anindya
------------------------------
Date: Mon, 12 Feb 2001 05:27:56 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: more eval madness- need help
Message-Id: <wvKh6.57$zN2.188317696@news.frii.net>
In article <967ru8$km4@dispatch.concentric.net>,
AC <anon9266@hushmail.com> wrote:
>Hi folks,
>
> I'm having a bear of a time trying to get a particular variable
>expansion to work. I have looked at the perldoc -q 'expand variables'
>and the perl cookbook, but I still cannot get it to work. So my situation
>is this: I have a script which looks something like this:
>
>use lib 'my/lib/path';
>use myPackage;
>
>my ($username,$uid,$gid,$gecos,$homedir,$shell);
>$user = "joeblow";
>@user_attrs = ('username','uid','gid','gecos','homedir','shell');
>
># list_users returns a perlref to a hash, so we have to access
># variable values with a double dollar like so
># print "$$uid{$username}"
>
>($username,$uid,$gid,$gecos,$homedir,$shell) = list_users();
>
>Now I want to save some lines of code, by looking through the
>attributes and evaluating "$nis_<attribute_name>{$user}.
>I have been trying something like this:
>
>foreach my $t (@user_attrs) {
> my $tmp;
> $tmp = "\$\$" . "$t" . "\{$user\}";
> print "BEFORE: $tmp\n";
> $tmp =~ s/(\$\$\S+$)/$1/g;
> print "AFTER: $tmp\n";
>}
>
>But this does not work, it will not evaluate "$$username{$user}" to its
>actual value. I have tried experimenting with more "e"'s and
>different s// syntax, but $tmp always becomes blank. Can someone clue me
>in on the right way to do something like this? Please respond by email as
>well. Thanks in advance!
>
You appear to be trying too hard. It looks to me like you are
trying to simulate the behavior of a hash. Read up on then then
tell me why what you are doing is different than that.
good luck
chris
--
This space intentionally left blank
------------------------------
Date: 12 Feb 2001 05:46:04 GMT
From: "AC" <anon9266@hushmail.com>
Subject: Re: more eval madness- need help
Message-Id: <967tas$km4@dispatch.concentric.net>
In article <wvKh6.57$zN2.188317696@news.frii.net>,
cfedde@fedde.littleton.co.us wrote:
Actually it turns out all I needed to do was:
$tmp =~ s/(\$\$\S+$)/$1/eeg;
The two "e" evals did the trick. The whole point of this exercise
is to be able to resolve the perlref correctly: i.e, loop through
all the hashnames without having to resort to :
foreach my $key (@usernames) {
print "$$username{$key}\n";
print "$$uid{$key}\n";
print "$$gid{$key}\n";
print "$$gecos{$key}\n";
..
...bunch of other print()..
}
instead I can now do:
@attrs= ("username", "uid", "gid", "gecos");
foreach my $user (@usernames) {
foreach my $thing (@attrs)
$tmp = "\$\$" . "$thing" . "\{$user\}";
$tmp =~ s/(\$\$\S+$)/$1/eeg;
print "$tmp\n";
}
}
I should also point out that my example strips out all the other million
print() that I need to do, this will cut down on my codesize
considerably. How would you do this differently? I'd love to hear other
ideas.
Thanks,
--Anindya
> In article <967ru8$km4@dispatch.concentric.net>, AC
>
> You appear to be trying too hard. It looks to me like you are trying to
> simulate the behavior of a hash. Read up on then then tell me why what
> you are doing is different than that.
>
> good luck chris
>
------------------------------
Date: 12 Feb 2001 02:17:11 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: more eval madness- need help
Message-Id: <snlk1ibs.fsf@pobox.com>
"AC" <anon9266@hushmail.com> writes:
> @attrs= ("username", "uid", "gid", "gecos");
> foreach my $user (@usernames) {
> foreach my $thing (@attrs)
> $tmp = "\$\$" . "$thing" . "\{$user\}";
> $tmp =~ s/(\$\$\S+$)/$1/eeg;
> print "$tmp\n";
> }
> }
>
> How would you do this differently?
You're simulating the behavior of a hash, just as the FAQ warns
against. How about
my %users = ( jdf => { uid => 42, gid => 100,
gecos => 'Perl User, Brooklyn' },
ac => { uid => 57, gid => 100,
gecos => 'Anonymous Poster' }
);
Each key of %users is a username. Each value of %users is itself a
reference to a hash keyed by field name.
while (my ($user, $data) = each %users) {
print "$user:\n";
foreach my $field (sort keys %$data) {
print " $field: $data->{$field}\n";
}
}
To understand references and data structures in Perl, you'll have to
read perllol, perlref, and perldsc. I hope this helps.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 12 Feb 2001 04:00:52 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: NDBM_File and ndbm.h
Message-Id: <UdJh6.2109$ZS3.8892@eagle.america.net>
On Sun, 11 Feb 2001 23:08:00 GMT, Costin <tanase_costin@my-deja.com> wrote:
>In article <i6nh6.2380$OO2.16985@eagle.america.net>,
> garry@zvolve.com (Garry Williams) wrote:
>> On Sat, 10 Feb 2001 21:26:10 GMT, Costin <tanase_costin@my-deja.com> wrote:
>> > I create a data base with perl 5.005_03 using NDBM_File. When I try to
>> >read it with a C program using ndbm.h I obtain garbage.
>> ^^^^^^^^^^^^^^^
>> I wonder what that means?
>
> Sorry, I didn't want to post a long question, but if I have to, I do. I
>know that only half of my problem is Perl related, I hope nobody
>consider it totaly out of the topic.
>
>First: I create a database with this perl script
>
>----------
>#!/usr/bin/perl -w
>use NDBM_File;
>
>my $dbf = 'mydb';
>my %dbhsh;
>
>dbmopen(%dbhsh, $dbf, 0700) || die " can ' t open db \n ";
>$dbhsh{'a'} = 10;
>$dbhsh{'b'} = 20;
>$dbhsh{'c'} = 30;
>dbmclose %dbhsh;
So far so good. Of course, the dbmopen() and dbmclose() functions are
deprecated. You should be using tie() and untie(). Check these
functions in the perlfunc manual page.
> If read it back in Perl (no surprise) everything is OK.
>
>SECOND:
>
> I try to read it with the following C program
>
>-----------
>#include <stdio.h>
>#include <ndbm.h>
>#include <fcntl.h>
>main()
>{
> DBM* db;
> datum ldat, key;
>
> db = dbm_open("mydb", O_RDWR, 0660);
> for(key = dbm_firstkey(db); key.dptr != NULL; key = dbm_nextkey(db))
> {
> ldat = dbm_fetch(db, key);
> printf(" name = %s \n val = %s \n", key.dptr, ldat.dptr);
Here's your problem. The Perl script stored keys and values without
any nul terminators. You now treat the keys and values as if they
were nul-terminated strings. You should use strncpy() to copy the
datum members before using them in printf():
typedef struct {
void *dptr;
size_t dsize;
} datum;
[snip]
> the program produces:
>
> name = c20b10aЪЪЪЪ
^
> val = 30c20b10aЪЪЪЪ
^^
>which is the kind of garbage I was talking about, I would expect an
>output as
> name = c
> val = 30
[snip]
Which you would get, if your C program were correct. You were only
lucky that your program didn't produce a seg-fault accessing the datum
struct's this way.
Perl uses the same library to manipulate ndbm files. C programs will
have no problem co-existing with Perl programs using ndbm.
--
Garry Williams
------------------------------
Date: Mon, 12 Feb 2001 06:08:51 GMT
From: Eugene Burger <eburger@my-deja.com>
Subject: Net::FTP - incomplete file transfer problem
Message-Id: <967ulh$c2i$1@nnrp1.deja.com>
Hi,
I hope someone can help me with this. I am using the Net::FTP module
for automate file transfers between machines on either side of the (US)
coast. When I transfer files using put, only about 25% of the files are
transfered. I have this problem with both binary and ascii files. The
script works perfectly between machines where the connection speed is
higher - I only have this problem when the connection speed drops down
a bit. I doubt if the connection speed is the problem though, as I can
ftp from the command line using the slower connection and transfer the
files completely. Has anyone else had a problem like this using the FTP
module?
BTW - the files are not very large - only about 9K, and I do not have
the problem when 'get' ing files with the same script.
Thank you in advance,
Eugene
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 12 Feb 2001 02:22:13 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Net::FTP - incomplete file transfer problem
Message-Id: <k86w1i3e.fsf@pobox.com>
Eugene Burger <eburger@my-deja.com> writes:
> I am using the Net::FTP module for automate file transfers between
> machines on either side of the (US) coast. When I transfer files
> using put, only about 25% of the files are transfered. I have this
> problem with both binary and ascii files. The script works perfectly
> between machines where the connection speed is higher - I only have
> this problem when the connection speed drops down a bit.
Have you adjusted the timeout option in the Net::Ftp cpnstructor?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 12 Feb 2001 06:16:30 GMT
From: Lawrence Ang <lawrenceang@my-deja.com>
Subject: Re: Net::FTP error - timeout on put()
Message-Id: <967v3r$cfm$1@nnrp1.deja.com>
> I use "quot site submit" which is similar, I think. When putting
> to the internal reader, I have to give a second argument to put.
> I don't know why. It may be a quirk of the TCP/IP implementation
> we have and may not apply to you. Still, you can give it a try.
>
> $ftp->put('local_file_name', 'x');
But according to the debug logs, it seems like the timeout occured for
the earlier put, and not the trigger. And besides, the trigger is
really a tiny file (<1K) compared to the 'dataset' which runs into
~150K.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 12 Feb 2001 14:35:54 +1300
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: Newbie's Stuck
Message-Id: <967els$lec$1@hermes.nz.eds.com>
"jlm" <jlm@cca-int.com> wrote in message
news:961kct$dbc$1@stingray.cca-int.com...
> How would I search for the presense of @ in a string?
> Assume an email addr. in variable $email - how do I test $email for an at
> sign.
> many thanks for your help...
I'm using my ESP powers here and guessing that you are trying to test
whether an email is valid.
Have you seen the FAQ?
perldoc -q "valid mail"
------------------------------
Date: Mon, 12 Feb 2001 05:21:38 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Perl CGI script & sendmail - timeout?
Message-Id: <CpKh6.56$zN2.183123968@news.frii.net>
In article <96709p$k79$1@nnrp1.deja.com>, <john_harman@my-deja.com> wrote:
>I am using a Perl CGI script (Newspro) which has a mailing list function
>attached. The problem is that not all messages are getting through to all
>recipients each day (currently 810). The script calls sendmail but I think it
>is inefficient in the way it does so.
>
>Currently the script sends messages in batches of 50 Bcc: (blind copied)
>messages (approx 40 KB per message) so it actually should only call sendmail
>17 times (for 810 addresses)? Presumably these batches are implimented in the
>script to reduce load on sendmail but it doesn't appear to be working
>consistently as often only half of them get through.
>
>I have also tried calling sendmail with "-odq": sendmail -t -odq so that
>messages are queued for sending. This is more successful in terms of messages
>getting through - though not 100%. Additionally the last messages take as
>long as 5 hours to reach the last recipients - which is too slow for my
>purposes.
>
What you've said sounds like normal e-mail processing to me.
By it's nature you will find that some email messages will take longer to
deliver than others. The issues have to do with the vagaries of availability
on both ends plus the intervening netwwork. While in most cases your
message will get through in just seconds in any sizable mailing there
are bound to be messages that get queued and not delivered for several
minutes, hours, days or even never.
Look at a distribution of the delivery times of your messages by looking at
the delay= tag in sendmail's logs of stat=send messages. This might give
you some idea if anything odd is going on.
If you can you might try looking at mailq(1) to get the queueID of one of
your delaied envelopes and then running sendmail -v -qI<queueID> as root
(or your mailuser) on that server. This also might give you more idea of
what is happening.
Good Luck
chris
BTW using BCC for this is not the best approach for bulk newsleter
distribution. Better to have code that simply stuffs envelopes using a
generic To:
--
This space intentionally left blank
------------------------------
Date: Mon, 12 Feb 2001 08:33:37 +0100
From: "Tony Dalbrekt" <to.da@spray.se>
Subject: postgres perl problem
Message-Id: <9gMh6.935$hi2.2890@nntpserver.swip.net>
Can't locate pg.pm in @INC (@INC contains: /usr/lib/perl5/5.6.0/i386-linux
/usr/lib/perl5/5.6.0 /usr/lib/perl5/site_perl/5.6.0/i386-linux
/usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at
/home/toda/html//cgi-bin/test.cgi line 8.
Why do I get this error message every time I try to connect to my postgres
database.
------------------------------
Date: Mon, 12 Feb 2001 05:53:50 GMT
From: "Brent Dax" <brentdax1_@_earthlink.net>
Subject: Re: Really weird errors (Resolution)
Message-Id: <OTKh6.1425$kG2.170810@newsread1.prod.itd.earthlink.net>
Hash: SHA1
Oops...
After all of that, I finally realized what the problem was: I forgot
the semicolon on the end of my eval{} statement.
D'Oh!
- --Brent Dax
brentdax1@earthlink.net
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBOod6WbJgQ5JqNEGyEQLrWQCfZMAyhEWQxwZnkq+8thXnJCkeMwYAnAq3
q5ytcvJ7HcTduq7DVVK6WOHL
=KPEA
-----END PGP SIGNATURE-----
------------------------------
Date: Mon, 12 Feb 2001 05:02:19 GMT
From: "Brent Dax" <brentdax1_@_earthlink.net>
Subject: Really weird errors
Message-Id: <v7Kh6.1319$kG2.155900@newsread1.prod.itd.earthlink.net>
Hash: SHA1
I'm getting four errors on a piece of code I'm writing. It's a CGI
script, but I don't think the bugs are CGI-related. I've spindled
and mutilated the code for hours trying to fix these. Anyway, here
are the errors:
syntax error at ./page.pl line 106, near "print"
Bareword "STDOUT" not allowed while "strict subs" in use at ./page.pl
line 106 (
#1)
<<I haven't undef-ed or otherwise destroyed STDOUT, so what's with
this?>>
Semicolon seems to be missing at ./page.pl line 108 (#2)
<<108 is the end of the here-document started on 106, where that
STDOUT thing came up, so this is probably related to that. There is
a semicolon on the end ot that print line.>>
syntax error at ./page.pl line 111, near "$err_path
END
"
<<Probably related to the print line>>
syntax error at ./page.pl line 124, near "}"
<<This one I can't figure out. Just look at the code example below,
you'll see what I mean.>>
Here's the code I'm getting this on (most of the eval has been cut
out so I don't have a 300-line e-mail):
my($tem, $out, %files_text); #line 47
eval {
.
.
.
return $_; #line 100
}
}
if($@){
my $log=new FileHandle; #line 105
print STDOUT <<"END";
Location: $err_path
END
#line 110
$log->open(">>error.log") or die "unable to open error log: $!";
foreach(keys %files) {
$files{$_}||="(none)";
} #line 115
my($sec, $min, $hour, $mday, $mon, $year) = localtime();
$year += 1900;
flock($log, LOCK_EX); #line 120
$log->format_name("ERROR");
write $log;
}
#line 125
format ERROR =
@<:@<:@< @</@</@<<<:
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$hour, $minute, $second, $month, $day, $year, $err
~~
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$err
Parameters:
~~ @<<<<<<<<<<<<<<<<<<:
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
each(%files)
.
#line 135
sub runprogram($) {
local $_;
my $program=shift;
my($prog_stdin, $prog_stdout)=(new FileHandle, new FileHandle);
#line 140
.
.
.
That's it. I've re-written this code several times, using several
different techniques instead of the here-document, but things always
seem to get screwed up on that and at the end of the block.
I just have no idea where to go from here. Does anybody have any
idea what could be causing this? Thanks...
>perl -v
This is perl, version 5.005_03 built for i386-freebsd
- --Brent Dax
brentdax1@earthlink.net
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBOoduR7JgQ5JqNEGyEQKVGwCeNkGDp/gsxKN/JRX7nl5tGHp0k2MAnRgy
BYhjjqYdMylSO5hw5KPFuiZ0
=Fvj8
-----END PGP SIGNATURE-----
------------------------------
Date: Mon, 12 Feb 2001 05:32:58 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Really weird errors
Message-Id: <eAKh6.58$zN2.170608128@news.frii.net>
In article <v7Kh6.1319$kG2.155900@newsread1.prod.itd.earthlink.net>,
Brent Dax <brentdax1_@_earthlink.net> wrote:
>
>Hash: SHA1
>
>I'm getting four errors on a piece of code I'm writing. It's a CGI
>script, but I don't think the bugs are CGI-related. I've spindled
>and mutilated the code for hours trying to fix these. Anyway, here
>are the errors:
>
>
I'd recomend copying your code to a new name then commenting out bits of it
till you find where the missing semicolon, brace, quote, other
delimiter that is confusing the perl compiler.
Alternately get an editor that can find matching braces or provide
syntax highlighting to see if that can help find the missing punctuation.
Good luck
chris
--
This space intentionally left blank
------------------------------
Date: Sun, 11 Feb 2001 22:50:37 -0600
From: "John Michael" <johnm@acadiacom.net>
Subject: reg exp question
Message-Id: <3a876d61$1@news.acadiacom.net>
In perl reg expressions these chars mean:
Any Number * any number allowed but
optional
One or More + one required, additional
are optional
Optional(zero 0r More) ? one allowed but optional
What do you do if you want:
one required, no more allowed?
Thanks--
John Michael
------------------------------
Date: Mon, 12 Feb 2001 14:57:58 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: reg exp question
Message-Id: <gmKh6.22$Ba7.5671@vic.nntp.telstra.net>
"John Michael" <johnm@acadiacom.net> wrote in message
news:3a876d61$1@news.acadiacom.net...
> In perl reg expressions these chars mean:
> Any Number * any number allowed
but
> optional
> One or More + one required,
additional
> are optional
> Optional(zero 0r More) ? one allowed but optional
>
> What do you do if you want:
> one required, no more allowed?
>
Just specify what you want, ie if you want one c, put one c.
#regexp to match one c
m/c/
Note that will match the first 'c' in a string. You could also specify
the minumum and maximum number to match with {n,m}.
There also may be issues with lookahead to ensure there are no others of
that charcter in the string...
check perlre for details.
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Mon, 12 Feb 2001 05:38:43 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: reg exp question
Message-Id: <DFKh6.2225$ZS3.9621@eagle.america.net>
On Sun, 11 Feb 2001 22:50:37 -0600, John Michael <johnm@acadiacom.net> wrote:
>In perl reg expressions these chars mean:
>Any Number * any number allowed but
>optional
>One or More + one required, additional
>are optional
>Optional(zero 0r More) ? one allowed but optional
>
>What do you do if you want:
>one required, no more allowed?
You don't want a quantifier. Use a zero width negative look-ahead
assertion with a back-reference:
/(something)(?!\1)/
See the perlre manual page.
--
Garry Williams
------------------------------
Date: 12 Feb 2001 05:47:43 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: reg exp question
Message-Id: <slrn98eukj.hub.ben-fuzzybear@Odin.Thor>
The ancient archives of Sun, 11 Feb 2001 22:50:37 -0600 showed
John Michael of comp.lang.perl.misc speaking thus:
>In perl reg expressions these chars mean:
>Any Number * any number allowed but
>optional
>One or More + one required, additional
>are optional
>Optional(zero 0r More) ? one allowed but optional
>
>What do you do if you want:
>one required, no more allowed?
That takes a little more than just a modifier, but the regex isn't very
difficult:
print unless /$n.*$n/;
or
$n = 'j';
$str = 'jack be nimble, quick, and acrobatic';
if ( $str !~ /$n.*$n/ ) { print "$str\n"; }
Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
One of the most difficult things to contend with in a hospital is that
assumption on the part of the staff that because you have lost your gall
bladder you have also lost your mind. -- Jean Kerr
------------------------------
Date: Mon, 12 Feb 2001 06:00:22 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: reg exp question
Message-Id: <WZKh6.2230$ZS3.9621@eagle.america.net>
On Mon, 12 Feb 2001 14:57:58 +0930, Wyzelli <wyzelli@yahoo.com> wrote:
>"John Michael" <johnm@acadiacom.net> wrote in message
>news:3a876d61$1@news.acadiacom.net...
>> What do you do if you want:
>> one required, no more allowed?
>
>Just specify what you want, ie if you want one c, put one c.
>
>#regexp to match one c
>
>m/c/
But this matches "cc" and the OP specifically disallows that.
--
Garry Williams
------------------------------
Date: Mon, 12 Feb 2001 06:08:29 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: reg exp question
Message-Id: <x5Lh6.2232$ZS3.9621@eagle.america.net>
On 12 Feb 2001 05:47:43 GMT, Ben Okopnik <ben-fuzzybear@geocities.com> wrote:
>The ancient archives of Sun, 11 Feb 2001 22:50:37 -0600 showed
>John Michael of comp.lang.perl.misc speaking thus:
>>In perl reg expressions these chars mean:
>>Any Number * any number allowed but
>>optional
>>One or More + one required, additional
>>are optional
>>Optional(zero 0r More) ? one allowed but optional
>>
>>What do you do if you want:
>>one required, no more allowed?
>
>That takes a little more than just a modifier, but the regex isn't very
>difficult:
>
>print unless /$n.*$n/;
But in the context of quantifiers, it seems the OP wants to match
something like "none", where $n = "n".
--
Garry Williams
------------------------------
Date: Mon, 12 Feb 2001 15:50:14 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: reg exp question
Message-Id: <p6Lh6.27$Ba7.5942@vic.nntp.telstra.net>
"Garry Williams" <garry@zvolve.com> wrote in message
news:WZKh6.2230$ZS3.9621@eagle.america.net...
> On Mon, 12 Feb 2001 14:57:58 +0930, Wyzelli <wyzelli@yahoo.com> wrote:
>
> >"John Michael" <johnm@acadiacom.net> wrote in message
> >news:3a876d61$1@news.acadiacom.net...
>
> >> What do you do if you want:
> >> one required, no more allowed?
> >
> >Just specify what you want, ie if you want one c, put one c.
> >
> >#regexp to match one c
> >
> >m/c/
>
> But this matches "cc" and the OP specifically disallows that.
>
It does not match cc, It fails to exclude cc. Significant difference.
Hence my comment about 'this will match the first c in the string'.
Since the OP is looking for 'no more allowed' I pointed him to using a
lookahead, and perlre.
I probably could have been more detailed about the other things it will
fail to exclude though. :)
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: Sun, 11 Feb 2001 23:08:45 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: reg exp question
Message-Id: <3A878BFD.52712F2B@stomp.stomp.tokyo>
John Michael wrote:
> In perl reg expressions these chars mean:
> Any Number * any number allowed but optional
> One or More + one required, additional are optional
> Optional(zero 0r More) ? one allowed but optional
> What do you do if you want: one required, no more allowed?
Use substring.
* shrugs *
Godzilla!
------------------------------
Date: Mon, 12 Feb 2001 14:30:02 +1300
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: sending attachments
Message-Id: <967eas$kjl$1@hermes.nz.eds.com>
"Philip Obbard" <pobbard@hotresponse.com> wrote in message
news:9611gh$1mr$1@taliesin.netcom.net.uk...
>
> "Troy Boy" <troyr@vicnet.net.au> wrote in message
> news:jOHg6.146$FU5.4421@ozemail.com.au...
> > Hi there,
> > What module can be used for sending mail attachments?
> >
> > Does anyone have a pointer to a perldoc i can look at (which explains
> adding
> > attachments not just sending plain text messages) or an example?
>
> I'm sure there is a good module out there. We use a small script by 'Eryq'
> called mimesend.pl which allows attachments, HTML, etc., and can be called
> in a single line. It can even (optionally) delete attachments once you've
> sent them.
The module is called MIME::Lite
See http://search.cpan.org/search?dist=MIME-Lite
------------------------------
Date: Mon, 12 Feb 2001 08:04:20 GMT
From: "Studio 51" <leekembel@hotmail.com>
Subject: TCP server
Message-Id: <8OMh6.134661$V22.27645266@news4.rdc1.on.home.com>
Hi, I'm monkeying around with a simple TCP server, and I have a question
regarding how to handle signals.
I understand it's bad to put a whole lot of code into a handler for a
signal. Apparently (among other things) if you use a function in that
handler that was already in use when the signal arrived, Perl might dump
core. Well, I have a big fat mess of stuff I want to do when I get a SIGHUP
(Kill a bunch of child processes, write to a log, write to STDOUT, close
filehandles, exec(), etc...). The recommended way to handle incoming signals
seems to be to just set a simple flag that the rest of the program can deal
with. The problem is that I can't check that flag while I'm blocking with
accept(). My little server may not get a new connection for some time, and
if it gets the SIGHUP while it's waiting for accept() to return then it
won't get a chance to check for the flag till it gets a new connection.
Should I really be concerned with putting too much code in a Perl signal
handler?
LKembel
------------------------------
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 271
**************************************