[18104] in Perl-Users-Digest
Perl-Users Digest, Issue: 264 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 10 00:10:27 2001
Date: Fri, 9 Feb 2001 21:10:12 -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: <981781812-v10-i264@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 9 Feb 2001 Volume: 10 Number: 264
Today's topics:
Re: Problem with regex and if/else expression (Tad McClellan)
Re: Problem with regex and if/else expression (Tad McClellan)
Re: Scaling up sample data in an array of hashes <bkennedy99@Home.com>
Re: Sending email from Perl Script on NT (Maggert)
Re: splitting a string on the / character <mischief@velma.motion.net>
Re: splitting a string on the / character <nospam@nospam.com>
Re: splitting a string on the / character <nospam@nospam.com>
Strange persistent list definition. <mcnuttj@nin.iats.missouri.edu>
Re: Strange persistent list definition. <joe+usenet@sunstarsys.com>
Web Mail Interfaces qurob@my-deja.com
Re: Web Mail Interfaces <kstep@pepsdesign.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 10 Feb 2001 02:54:45 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem with regex and if/else expression
Message-Id: <slrn98910v.fon.tadmc@tadmc26.august.net>
LK <lkenny@fisheries.org> wrote:
> if($_ !=~ /$num/){
^^^
^^^
Wassat?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 10 Feb 2001 02:54:46 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem with regex and if/else expression
Message-Id: <slrn98915u.fon.tadmc@tadmc26.august.net>
Faerloche <faerloche@arkansas.net> wrote:
> next if !~ m/$num/) {
^^ ^
^^ ^
Wassat too?
Have we slipped into the Twilight Zone with this thread?
Please post Perl code here in the Perl newsgroup, not some
made-up silliness.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 10 Feb 2001 03:35:01 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: Scaling up sample data in an array of hashes
Message-Id: <FF2h6.44088$49.7801713@news1.rdc2.pa.home.com>
"Philip Lees" <pjlees@ics.forthcomingevents.gr> wrote in message
news:3a8144be.82463806@news.grnet.gr...
> I'm quite pleased with myself for managing this at all, actually, but
> I can't help thinking that there might be a niftier way to do it,
> maybe using grep or map. Any ideas?
You could use map to create the new hash with something like
my($i,$tmpval);
my %newhash = map {
$i++ % 2 and $tmpval = int(rand(@patients));
($_, $patients[$tmpval]{$_} )
} qw(lastname ename1 firstname ename2 fathersnam ename3 birthdata);
++$max_id;
$newhash{patcode} = $max_id;
push @patients, \%newhash;
On each iteration of map, a new array index is picked on the 1st, 3rd, and
5th elements, then the key -> value pair is added to the hash
> By the way, the following lines are equivalent, right?
>
> $var->{ lastname } = 'foo';
> ${ $var }{ lastname } = 'foo';
> $$var{ lastname } = 'foo';
>
> Is there any reason for using one syntax rather than the other? (The
> last is the shortest, the first is the clearest, but the middle one is
> the prettiest - at least to my eye.)
They are the same - the first is best in my eyes because it makes
multidimensional referencing much clearer, esp when you start getting into
stuff like $ref->[1]{John}[3] etc etc
--Ben Kennedy
------------------------------
Date: Sat, 10 Feb 2001 02:16:50 GMT
From: perl@imchat.com (Maggert)
Subject: Re: Sending email from Perl Script on NT
Message-Id: <3a84a3e3.19413725@news.ionet.net>
On Fri, 09 Feb 2001 15:40:04 GMT, jgunnip@my-deja.com wrote:
>Hi,
>
>Does anyone know why the following code to send email works perfectly
>on Linux but not on Windows NT? It doesn't complain (i.e. die()) when
>I use it on NT. I just never receive the email.
>
I would hazard a guess that since Windoze systems have no
native emailing facilities that posting it without mentioning an smtp
server would just send it off to no mans land. Of course I could be
wrong. I've never seen anyone use LWP to send an email.
------------------------------
Date: Sat, 10 Feb 2001 02:19:39 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: splitting a string on the / character
Message-Id: <t8999r1brfa782@corp.supernews.com>
Studio 51 <leekembel@hotmail.com> wrote:
> "Chris Stith" <mischief@velma.motion.net> wrote in message
> news:t86bj87f02p880@corp.supernews.com...
>> You can do the same thing without the escape, since you use different
>> delimeters.
>> my @temp = split[/], $direntry;
> As mentioned, that doesn't work.
True. I overgeneralized. You can use most anything for the delimiters
with m, s, tr, q, qq, qx, or qw. The same does not hold true for split
(unless you feed split the results of m, as someone showed).
> Are you referring to me? The free email service is for spam, which that
> account gets plenty of. Studio 51 is not a pseudonym, it's the name of my
> company. If it really bothers you that you don't know anything about me,
> then my name is Lee Kembel and I live in Toronto.
I wasn't referring to only you, but yes, you did cross my mind as I
typed that. I read your earlier posts as very uncivil. Thank you for
being kind enough to try to appease me, but it's not necessary. I
was making a general statement which has exceptions (notably amonotod,
who is a regular here and is very nice), and I should not have lumped
you on one side of that line after so little interaction with you.
Chris
--
Christopher E. Stith
It's not the U in UBE that pisses people off. It's the B.
-- Martien Verbruggen in clp.misc
------------------------------
Date: 10 Feb 2001 03:10:19 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: splitting a string on the / character
Message-Id: <962ber$8cm$3@216.155.32.222>
In article <m1k871qrx9.fsf@halfdome.holdit.com>, merlyn@stonehenge.com
(Randal L. Schwartz) wrote:
| From the "worth repeating 27 more times department":
|
| THIS IS NOT A HELP DESK.
| THIS IS A COMMUNITY POTLUCK.
| DON'T BOGART THE POTATO SALAD.
| BRING A DISH IF YOU CAN.
| DON'T WHINE IF NOBODY BROUGHT ICE CREAM.
|
| There.
I swear to god that if I ever get the opportunity to be at a Perl
conference where Randal will miraculously be present, that I'll bring a
few t-shirts to give away that say merely "Don't bogart the potato
salad" :-D
rofl
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: 10 Feb 2001 03:22:25 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: splitting a string on the / character
Message-Id: <962c5h$8cm$4@216.155.32.222>
In article <3a835ad7.6ab1$df@news.op.net>, mjd@plover.com (Mark Jason
Dominus) wrote:
| I think this 'fish' thing is bullshit.
|
| If you give the guy a fish, he might stop panicking about whether
| he'll go hungry or not. Then eventually he'll wonder where you're
| getting all those fish. Then he'll be a lot more receptive to fishing
| lessons than if you had just said "Go learn to fish and stop bothering
| me, you lazy bastard!"
|
| I think RTFM-ism is mostly unkind and unhelpful, masquerading behind a
| rhetoric of helpfulness. If your goal is to get people to wash their
| hands of you and go away to use another language with a more
| supportive community, it's a great idea.
On this you and I can agree.
To a degree anyway.. :-)
Uri's comments to me about reading perldsc and perllol back when I was
first beginning all this delving into Perl's complexity back sometime
after May of last year was *exactly* what I needed.. but because he
explained (clearly) that I was better off KNOWING it and figuring it out
myself and offering a few helpful pointers to me about HOW to go about
studying it, and actually pointed to WHERE in the FM that I should go
'fish' ... THAT was truely helpful advice that has served me well ever
since.
simply saying to me "it's in the (fine) manual" wouldn't have helped me
one bit. Uri will probably get well tired of hearing me thank him before
I get tired of thanking him =8)
I'm of a mind that the form of RTFM I mention above is far and away more
helpful in the long term than the terse "RTFM and fuck off until you do"
that I see all too often.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: 10 Feb 2001 03:36:07 GMT
From: Justin McNutt <mcnuttj@nin.iats.missouri.edu>
Subject: Strange persistent list definition.
Message-Id: <962cv7$uf4$1@dipsy.missouri.edu>
[ This is a repost of the following article: ]
[ From: Justin McNutt <mcnuttj@nin.iats.missouri.edu> ]
[ Subject: Strange persistent list definition. ]
[ Newsgroups: comp.lang.perl.modules ]
[ Message-ID: <9625rl$jic$1@dipsy.missouri.edu> ]
Hey all,
I've come across a weird behavior of Perl and I'm hoping someone can tell
me why it's doing this.
I have a module called 'hubscanmod' that contains a single function
'hubscan'. It uses the SelfLoader. The only statement in the module
above the __DATA__ tag is the hubscan function prototype.
So the hubscan() function is loaded dynamically. This part works.
The hubscan function uses two internal lists, defined at the top of the
function like so:
sub hubscan($$$) {
.
.
.
my @chassis;
my @modules;
Later in the module (in a while loop), I do this:
if ( not defined @chassis ) {
@chassis = gettype(<insert args here>);
}
This way I only have to call gettype() once during the loop.
The problem is that hubscan() exits, and then gets called again later to
scan another device. When that happens, @chassis and @modules are still
defined, but contain no elements.
The way I understand it, when you do "my @blarg", you create an entry
'blarg' in the package's name space, where \@blarg is defined, but
$blarg[anything] is not.
Furthermore, 'undef @blarg' is not the same as '@blarg=()', since adding
undef lines at the top of my module solves the problem - although it seems
like a kludge to me - whereas the NULL-list assignment does not.
Is my problem related to using the SelfLoader, or is there something I
don't understand about the way Perl *really* handles variables?
Oh yeah, I have 'use strict' in all of my modules, including 'main', and
only one module exports its internal variables into the global namespace,
and none of those variable names collide with 'chassis' or 'modules'.
--J
------------------------------
Date: 09 Feb 2001 23:44:42 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Strange persistent list definition.
Message-Id: <m3y9vfm9j9.fsf@mumonkan.sunstarsys.com>
Justin McNutt <mcnuttj@nin.iats.missouri.edu> writes:
> sub hubscan($$$) {
> .
> .
> .
> my @chassis;
> my @modules;
>
> Later in the module (in a while loop), I do this:
>
> if ( not defined @chassis ) {
^^^^^^^^^^^^^^^
You don't want to do this. Use
if (@chassis) {
instead. From perlfunc:
% perldoc -f defined
...
Currently, using C<defined()> on an entire array or hash reports whether
memory for that aggregate has ever been allocated. So an array you set
to the empty list appears undefined initially, and one that once was full
and that you then set to the empty list still appears defined. You
should instead use a simple test for size:
if (@an_array){ print "has array elements\n" }
...
[...]
> The way I understand it, when you do "my @blarg", you create an entry
> 'blarg' in the package's name space, where \@blarg is defined, but
> $blarg[anything] is not.
That is not correct. You should read
% perldoc -q lexical
and perlsub's section on private variables.
>
> Furthermore, 'undef @blarg' is not the same as '@blarg=()', since adding
> undef lines at the top of my module solves the problem - although it seems
> like a kludge to me - whereas the NULL-list assignment does not.
Both are kludge when used like that.
> Oh yeah, I have 'use strict' in all of my modules, including 'main', and
> only one module exports its internal variables into the global namespace,
> and none of those variable names collide with 'chassis' or 'modules'.
Sounds great. Best of luck with it.
Joe Schaefer
--
"You may be a mighty king," he said. "But you're sitting in oobleck up to your
chin. And so is everyone else in your land. And if you won't even say you're
sorry, you're no sort of a king at all!"
-- Dr. Seuss
------------------------------
Date: Sat, 10 Feb 2001 02:28:05 GMT
From: qurob@my-deja.com
Subject: Web Mail Interfaces
Message-Id: <9628vg$5ci$1@nnrp1.deja.com>
Are there any pages which describe creating a
HTML based interface for accessing POP and SMTP
server, much like Hotmail can? I'd like to write
an interface for our mail server, which doesn't
have one. What tools would be useful, -Perl-, Java,
etc? I'd appreciate input on any ideas or success
stories on how to approach this.
TIA
qurob@hotmail.com
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 9 Feb 2001 22:08:27 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: Web Mail Interfaces
Message-Id: <962bcd$rmp$1@slb2.atl.mindspring.net>
<qurob@my-deja.com> wrote in message news:9628vg$5ci$1@nnrp1.deja.com...
> Are there any pages which describe creating a
> HTML based interface for accessing POP and SMTP
> server, much like Hotmail can? I'd like to write
> an interface for our mail server, which doesn't
> have one. What tools would be useful, -Perl-, Java,
> etc? I'd appreciate input on any ideas or success
> stories on how to approach this.
Check out the Net::POP3, Net::SMTP modules for server interaction and
MIME::Lite, MIME::tools or MailTools for generating and parsing MIME
messages. All of these are available on CPAN, or as ActivePerl packages if
that's your platform. All of these packages are quite mature and well
documented. The CPAN versions may come with some sample code as well.
For Net::POP3, Net::SMTP:
http://search.cpan.org/search?dist=libnet
Assorted MIME packages:
http://search.cpan.org/search?dist=MIME-Lite
http://search.cpan.org/search?dist=MIME-tools
http://search.cpan.org/search?dist=MailTools
ActiveState PPM Packages:
libnet
MIME-Lite
MIME-tools
MailTools
HTH
Kurt Stephens
------------------------------
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 264
**************************************