[17470] in Perl-Users-Digest
Perl-Users Digest, Issue: 4890 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 14 21:05:57 2000
Date: Tue, 14 Nov 2000 18:05:10 -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: <974253910-v9-i4890@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 14 Nov 2000 Volume: 9 Number: 4890
Today's topics:
Re: A surprise with vec() (Martien Verbruggen)
Re: Alternate solution to (split)[2..-1] problem <simon@brecon.co.uk>
Re: beginner question regarding extracting email body w (Gwyn Judd)
Re: cgi.pm cookie path bug? <fchanny@lbl.gov>
Date (JOBBEY83)
Re: Date (JOBBEY83)
Re: Date <wyzelli@yahoo.com>
Re: Document management question! <dzade@bellatlantic.net>
Re: Does sub foo { 'A'..'Z' } return a list? (Martien Verbruggen)
Re: Does sub foo { 'A'..'Z' } return a list? (Martien Verbruggen)
Re: Does sub foo { 'A'..'Z' } return a list? <joe+usenet@sunstarsys.com>
Re: getting the real virtual host <nospam@david-steuber.com>
Re: IP geography <nospam@david-steuber.com>
Re: IP geography (Martien Verbruggen)
Re: IP geography (Martien Verbruggen)
IPC with Matlab question <david_zempel@excite.com>
linking Java and Perl khurana_monica@hotmail.com
Re: Looking for idiom for getting value from @ARGV, or <iltzu@sci.invalid>
Re: Mail <mesarch@ee.net>
Re: Mail <peter.sundstrom@eds.com>
Re: Please tell me why this code is wrong (ActiveState <jeff@vpservices.com>
Re: Please tell me why this code is wrong (ActiveState <nospam@david-steuber.com>
Re: Please tell me why this code is wrong (ActiveState <ren.maddox@tivoli.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 15 Nov 2000 10:59:35 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: A surprise with vec()
Message-Id: <slrn913kf6.gs3.mgjv@martien.heliotrope.home>
On 14 Nov 2000 11:09:26 -0500,
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> mgjv@tradingpost.com.au (Martien Verbruggen) writes:
>
>> as a number (chr, offset and length for substr, splice, etc.). In most
>> cases it is perfectly clear what you mean, and it is mostly clear to you
>> what the argument is supposed to be.
>
> Not always, though- the interpretation occasionally depends on your
> perl version:
Interesting. Both 5.004_05 and 5.003_03 do this. I don't have any older
versions around to test against.
However, what you have tested is that the LIST argument to pack is being
treated as a string or not, and that's not exactly what I said. I was
more implying that the return value of pack, or the EXPR argument to
unpack are forced to be strings, and documented to be treated as such.
In your case, the string needs to be converted to an integer, not the
other way around, and it happens internally to the pack, at runtime. it
is related, but not the same. I suspect that the way pack treated its
LIST arguments has been de-bugged for 5.6.0. You can see that it has
nothing to do with unpack or join:
print "Equal" if pack('i', "3626198025") eq pack('i', 3626198025);
If you run that through the various versions of Perl, you'll find that
this is where the difference occurs.
I have the feeling that the 5.6.0 behaviour is the intended behaviour,
and that it just has been buggy all this time, but I could be wrong. It
may also be that the old behaviour was the wanted one, and that it
inadvertently got changed with all the other things that were added to
pack().
Martien
--
Martien Verbruggen |
Interactive Media Division | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: 15 Nov 2000 01:02:52 +0000
From: Simon Cozens <simon@brecon.co.uk>
Subject: Re: Alternate solution to (split)[2..-1] problem
Message-Id: <87r94eujwj.fsf@pembro4.pmb.ox.ac.uk>
>>>>> "Ken" == Ken Williams <ken@forum.swarthmore.edu> writes:
Ken> I'm having a hard time imagining that [open-ended slices]
Ken> hasn't been proposed before though, so perhaps some people
Ken> (insightful people?) don't like it.
I had a patch to do this almost exactly a year ago; I initially
started off with [2..-1], but this was deemed to break old code. I
then tried [2..], but it was horrifically messy to implement.
The problem is that [2..] *isn't really* a list. It's something that
has to lay undetermined until runtime, until you know how big it
actually is. Worse, it's something that only makes sense as a
subscript; you have to treat it as a special form of subscript. Which
means that the cleanest way to implement it (and believe me, I tried
some pretty dirty ones) is as a new operator, and new operators are
pretty much verboten. (It also made the grammar unpleasant.)
--
You're all sick, except Simon. And he's sick, too. -- Kake Lemon Pugh
------------------------------
Date: Tue, 14 Nov 2000 23:18:19 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: beginner question regarding extracting email body with regexp
Message-Id: <slrn913i1o.9a0.tjla@thislove.dyndns.org>
I was shocked! How could Debian User <damajah@kzahq.ath.cx>
say such a terrible thing:
>Hi, I am trying to learn perl by starting with a simple email client,
>I can extract the From and Subject ok like this:
>
>#!/usr/bin/perl
>
>while (<STDIN>) {
> ($from) = /^From: (.+)$/;
> ($subject) = /^Subject: (.+)$/;
>
>Then I try and get the body, which I can't do. Now this program reads
>standard mailbox format files, a single message at a time
>from stdin, so I want to read from the first line following a line
>where \n is the first character up till eof.
$body .= $_ if (/^$/ .. eof());
See the documentation in 'perlop' regarding the flip-flop '..' operator.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
In the beginning, there was nothing, which exploded.
-Terry Pratchett (contributed by Nathan Poznick)
------------------------------
Date: Tue, 14 Nov 2000 16:08:07 -0800
From: Frank Hanny <fchanny@lbl.gov>
To: Dennis L Baker <DLBaker@lbl.gov>
Subject: Re: cgi.pm cookie path bug?
Message-Id: <3A11D3E7.BDEFEE3F@lbl.gov>
OK, in the face of resounding silence, I pursued this a bit further, and
discovered that it works, if I specify the -domain parameter, and the
-path parameter explicitly.
The fact that the path portion of the URL is case sensitive for purposes
of cookie sharing is probably outside the scope of this group, (and
known to all but me) but proved character-building during the debugging
process.
Frank Hanny
Frank Hanny wrote:
>
> If this has come up before, as seems likely, forgive me, as lengthy
> searches
> on dejanews did not turn it up.
>
> From http://www.perl.com/pub/doc/manual/html/lib/CGI.html:
>
> >3.a path If you provide a cookie path attribute, the browser will check it against your
> >script's URL before returning the cookie. For example, if you specify the path ``/cgi-bin'',
> >then the cookie will be returned to each of the scripts ``/cgi-bin/tally.pl'',
> >``/cgi-bin/order.pl'', and ``/cgi-bin/customer_service/complain.pl'', but not to the script
> >``/cgi-private/site_admin.pl''. By default, path is set to ``/'', which causes the cookie
> >to be sent to any CGI script on your site.
>
> My experience differs. My environment: ActiveState perl 5.005, cgi.pm
> version 2.46, on a
> Windows NT server running IIS. Browsers I have tried are Netscape 4.73
> and IE 5.00, and both
> behave the same for once.
>
> First, the default path, if none is specified in the call to the cookie
> method, is the
> current path of the perl program, not "/".
>
> Thus, the following call from
> http://mydomain.com/self_service/parking/cookie.pl
>
> $cookie = $q->cookie( -name => 'self_service',
> -value => '123',
> -expires => '+1h' );
>
> produces the following cookie:
>
> "self_service=123; path=/self_service/parking/; expires=Wed, 08-Nov-2000
> 22:57:58 GMT"
>
> This cookie does have the desirable attribute that it can be retrieved
> using
>
> $value = $q->cookie( -name => 'self_service' );
>
> Second problem: if I do specify the path, as follows
>
> $cookie = $q->cookie( -name => 'self_service',
> -value => '123',
> -path => '/self_service/',
> -expires => '+1h' );
>
> intending to share the cookie with other applications in the
> /self_service/ hierarchy,
> I can no longer retrieve the cookie with
>
> $value = $q->cookie( -name => 'self_service' );
>
> from the original application, nor can I retrieve it from any other
> application in the
> /self_service/ hierarchy, (though presumably I could retrieve it from an
> application
> running in /self_service/ itself?) If I specify -path => '/', the
> behavior is the same.
>
> Any suggestions?
>
> Thanks,
>
> Frank Hanny
------------------------------
Date: 15 Nov 2000 00:53:46 GMT
From: jobbey83@aol.com (JOBBEY83)
Subject: Date
Message-Id: <20001114195346.23068.00001459@ng-bh1.aol.com>
Hi, I am a total newbie and I am wondering how I can calculate the current date
mm/dd/yy. If it involves installing a module could you please direct me on how
to do so?
------------------------------
Date: 15 Nov 2000 00:57:06 GMT
From: jobbey83@aol.com (JOBBEY83)
Subject: Re: Date
Message-Id: <20001114195706.23068.00001463@ng-bh1.aol.com>
>Hi, I am a total newbie and I am wondering how I can calculate the current
>date
>mm/dd/yy. If it involves installing a module could you please direct me on
>how
>to do so?
>
forgot to mention: i am using active state on win 98
------------------------------
Date: Wed, 15 Nov 2000 10:34:56 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Date
Message-Id: <VdlQ5.4$OQ.3613@vic.nntp.telstra.net>
"JOBBEY83" <jobbey83@aol.com> wrote in message
news:20001114195706.23068.00001463@ng-bh1.aol.com...
> >Hi, I am a total newbie and I am wondering how I can calculate the
current
> >date
> >mm/dd/yy. If it involves installing a module could you please direct
me on
> >how
> >to do so?
> >
>
> forgot to mention: i am using active state on win 98
Look up the localtime function in the documentation (perlfunc)
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: Wed, 15 Nov 2000 00:16:15 GMT
From: "David Zade" <dzade@bellatlantic.net>
Subject: Re: Document management question!
Message-Id: <jBkQ5.7981$46.480649@typhoon1.ba-dsg.net>
Don't know if I would do use the following for a core business function, but
my team uses it to store our documentation:
NT Server
Internet Information Server
Index Server
Deposite documents in directory scanned by Index Server, and made avaiable
via IIS. Setup search page (example asp comes with IIS). Any workstation
that selects a MSWord doc returned by the search should have at least the
MSWord viewer from Microsoft, or the full MSword. Document displayed.
DONE.
Sorry for off-topic response.
DAvid zADE
dzade@bellatlantic.net
"Greg Griffiths" <greg2@surfaid.org> wrote in message
news:3A11AB1D.4ED278A9@surfaid.org...
> you could take a look at
>
> OpenText Livelink http://www.opentext.com
> Cardiff Software http://www.cardiff.com
>
> although you could always do you own.
>
> Gary wrote:
>
> > Hello,
> >
> > I work for a company that runs the following environment:
> >
> > OS: Freebsd for Intel machines
> > Database: Mysql
> > Languages: Perl, C
> >
> > We have a need to create a document management warehouse where
> > we can do the following:
> >
> > 1. take MS/word docs and save them to a database.
> > 2. be able to search those docs for words/phases and display a list of
> > which documents
> > contain the words/phrases.
> > 3. Be able to view the word documents that contain the phrases/words
> > with a www/browser.
> > 4. Be able to print the documents back out in MS/Word format.
> >
> > An additional item is:
> >
> > 1. To be able to scan document into the Database (mysql).
> >
> > I am basically looking for suggestions, maybe from someone who has done
> > something similar,
> > on what they found to be the best combination of tools/software to do
> > this.
> > We are open, with a limited budget, to paying for a bundled product that
> > would fit nicely into our
> > above mentioned environment.
> >
> > Thanks for any ideas, thoughts on this question!
> >
> > Gary Artim
> > Drogin, Kakigi and Associates
> > mailto:gary@dkstat.com
>
------------------------------
Date: Wed, 15 Nov 2000 11:01:07 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Does sub foo { 'A'..'Z' } return a list?
Message-Id: <slrn913ki3.gs3.mgjv@martien.heliotrope.home>
On 14 Nov 2000 08:38:48 -0500,
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> mgjv@tradingpost.com.au (Martien Verbruggen) writes:
>
>> If either
>> operand of scalar ".." is a constant expression, that
>> operand is implicitly compared to the `$.' variable, the
>> current line number.
>>
>>
>> The scalar context propagates into the subroutine, putting the flipflop
>> in a scalar context. This means it will work as described above. It will
>> return false, since $. is not equal to 'A'. So, it returns "", the empty
>> string.
>>
>
> Grrr...
>
> and yet not a single mention of the damned thing in perldoc -f readline.
The documentation isn't perfect, and especially cross-references are
missing in many places. Feel free to submit a patch to the perl porters
(with perlbug). Often it's just a matter of no one having noticed
missing pointers, and they'll be happy to add it to the docs.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | What's another word for Thesaurus?
NSW, Australia |
------------------------------
Date: Wed, 15 Nov 2000 11:17:38 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Does sub foo { 'A'..'Z' } return a list?
Message-Id: <slrn913lh2.gs3.mgjv@martien.heliotrope.home>
On 14 Nov 2000 09:25:03 -0600,
Ren Maddox <ren.maddox@tivoli.com> wrote:
> mgjv@tradingpost.com.au (Martien Verbruggen) writes:
>
>> On Tue, 14 Nov 2000 14:42:49 +0800,
>> John Lin <johnlin@chttl.com.tw> wrote:
>> > Dear all,
>> >
>> > Q1: Is it possible to write the following pieces of code in
>> > one statement (so we can save two variables $begin,$end).
>> >
>> > my ($begin,$end) = $object->iterate;
>> > print $object->get($_) for $begin..$end;
>>
>> Yes.
>
> Martien, you said "Yes" to the OP's question (above) about whether or
> not it was possible to omit the $begin and $end variables, but (unless
> I missed it) you never told him how. The OP apparently made the
> mistaken assumption that there was a scalar context here when there
> isn't, and that lead to the side discussion of the flip-flop operator.
Oops. I actually misread the question. I thought he asked whether is
was possible to write an iterate method that would allow im to write the
above. I didn't think it needed explanation. However, I misread.
> As to the original question, actually I do not think it is possible to
> get the magical for/range operator behavior (wherein, for efficiency,
> the list is *not* actually created) without it being explicit. I
> could easily be wrong about this, but the point is that I would expect
> that the optimization that allows:
>
> for (1..1_000_000) {}
>
> to avoid generating a million element list will not apply if this is
> used instead:
>
> sub million { 1..1_000_000 }
> for (million) {}
I think you are probably right. I don't know enough about the internals
to answer this authoritatively. I've been staring at the -MO=Terse and
-MO=Debug output for a while, but can't really answer it.
> Oh -- never mind. Changing it to 100 million demonstrates the
> difference right away:
[snip]
> % time perl -e 'sub million {1..100_000_000};for (million) {}'
> Out of memory!
Well, that's definitive then :)
Martien
--
Martien Verbruggen |
Interactive Media Division | Can't say that it is, 'cause it
Commercial Dynamics Pty. Ltd. | ain't.
NSW, Australia |
------------------------------
Date: 14 Nov 2000 20:36:11 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Does sub foo { 'A'..'Z' } return a list?
Message-Id: <m3hf5adnjo.fsf@mumonkan.sunstarsys.com>
Yet another repost- my newsfeed is seriously crappy
this week. Sorry if was is already posted.
mgjv@tradingpost.com.au (Martien Verbruggen) writes:
> On 14 Nov 2000 08:38:48 -0500,
> Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> > mgjv@tradingpost.com.au (Martien Verbruggen) writes:
> >
> >> If either
> >> operand of scalar ".." is a constant expression, that
> >> operand is implicitly compared to the `$.' variable, the
> >> current line number.
> >>
> >>
> >> The scalar context propagates into the subroutine, putting the flipflop
> >> in a scalar context. This means it will work as described above. It will
> >> return false, since $. is not equal to 'A'. So, it returns "", the empty
> >> string.
> >>
> >
> > Grrr...
> >
> > and yet not a single mention of the damned thing in perldoc -f readline.
>
> The documentation isn't perfect, and especially cross-references are
> missing in many places. Feel free to submit a patch to the perl porters
> (with perlbug). Often it's just a matter of no one having noticed
> missing pointers, and they'll be happy to add it to the docs.
I don't think you really mean that. My patch would be pretty, well, large-
beginning with a rewrite of IO::Handle and ending with one less entry
in perlvar ;)
--
Joe Schaefer
------------------------------
Date: Tue, 14 Nov 2000 23:13:23 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: getting the real virtual host
Message-Id: <m33dgujgfh.fsf@solo.david-steuber.com>
"Steve" <newsgroups@mail.ru> writes:
' Is there any way of getting the real host that the user requested in order
' to end up at my page?
If all your host names map to the same IP address then the answer is
no. You need the Host header to determine which site is asked for.
In its absense, you can send back a default page, but that is about it.
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: Tue, 14 Nov 2000 23:05:58 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: IP geography
Message-Id: <m37l66jgru.fsf@solo.david-steuber.com>
cfedde@fedde.littleton.co.us (Chris Fedde) writes:
' return "98.9% probability that $_[0] is within 20037.54 km of Tucson AZ US";
Extra-terrestrial IPs?
I guess when IPv6 rolls out, early in the 31st century (no, that isn't
a typo), each planet, station, moon, asteroid, etc, will get its own
set of subnets.
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: Wed, 15 Nov 2000 11:20:26 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: IP geography
Message-Id: <slrn913lma.gs3.mgjv@martien.heliotrope.home>
On 14 Nov 2000 18:46:28 GMT,
Eli the Bearded <elijah@workspot.net> wrote:
> In comp.lang.perl.misc, Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> ...
>> All you can do is make a guess at it, and get about 60% or so
>> (reasonably) right (and that would be based on host names, not IP
>> addresses). The other 40 or so % will simply be wrong, undetectably so.
>
> Some folks in my company have been working on this problem for
> demographics reasons. They are specifically looking at IP to US
> zip code or IP to country. They are using some commercial product
> and comparing the results to people who have volluntarily given
> us that data.
And this is the key to the whole exercise. Unless you have a database
that links these things, and that database is reliably kept up to date,
you have no chance.
> They find that for 30% of the cases they get a good match. The other
> 70% are unknown or widely off. They are pretty happy with that level
> of success.
I knew I was being optimistic, just not that I was being that optimistic
with my guesstimates.
> knowing 30% of your demographic is better than known none
As long as everyone fully understands that you only know that few, and
as long as it is possible to reliably identify the reliable 30% :)
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use
NSW, Australia | being a damn fool about it.
------------------------------
Date: Wed, 15 Nov 2000 11:21:42 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: IP geography
Message-Id: <slrn913lom.gs3.mgjv@martien.heliotrope.home>
On Tue, 14 Nov 2000 23:05:58 GMT,
David Steuber <nospam@david-steuber.com> wrote:
> cfedde@fedde.littleton.co.us (Chris Fedde) writes:
>
> ' return "98.9% probability that $_[0] is within 20037.54 km of Tucson AZ US";
>
> Extra-terrestrial IPs?
>
> I guess when IPv6 rolls out, early in the 31st century (no, that isn't
> a typo), each planet, station, moon, asteroid, etc, will get its own
> set of subnets.
There's enough room in that address space to individually address each
organ in everyone's body :)
Martien
--
Martien Verbruggen |
Interactive Media Division | I used to have a Heisenbergmobile.
Commercial Dynamics Pty. Ltd. | Every time I looked at the
NSW, Australia | speedometer, I got lost.
------------------------------
Date: Tue, 14 Nov 2000 14:59:15 -0800
From: David Zempel <david_zempel@excite.com>
Subject: IPC with Matlab question
Message-Id: <3A11C3C3.A0A1462A@excite.com>
I'm trying to fork a Matlab process to which I can send commands to and
receive data from. Problem is that I can startup Matlab using the
following commmands, but it "blocks" and never receives the commands I
send it. Any ideas?
use IPC::Open2;
my $matlab = "/disk1/matlab5.2.1/bin/matlab -c 1601\@young -nosplash";
my ($pid,$IN,$OUT);
print "$matlab\n" if ($debug == 1);
$pid = open2($IN,$OUT, "$matlab");
print $OUT "tlmlist\n";
while (<$IN>) {
print "$_\n";
}
close($OUT);
close($IN);
Thanks, Dave.
PS, I've tried using open3 in order to capture any errors, but there
weren't any.
------------------------------
Date: Wed, 15 Nov 2000 01:17:52 GMT
From: khurana_monica@hotmail.com
Subject: linking Java and Perl
Message-Id: <8uso7r$32g$1@nnrp1.deja.com>
HI!
I have some of my applications written in Java and some in Perl. I need
to call Perl scripts from a web based Java application and get the
returned values from the Perl scripts and format them and display on a
browser page.
I also have some perl programs that need to call Java programs and get
returned values and further process the data.
How can I do this?
Thanks
monica
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 14 Nov 2000 23:09:32 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <974243152.4216@itz.pp.sci.fi>
In article <m3hf5ah629.fsf@dhcp11-177.support.tivoli.com>, Ren Maddox wrote:
>Bart Lateur <bart.lateur@skynet.be> writes:
>>
>> $sh->{password} = shift(@args) || $ENV{DBI_PASS};
>
>But that still has a problem if "" (or 0) is passed via @args.
>
> $sh->{password} = @args ? shift @args : $ENV{DBI_PASS};
The _real_ reason why Perl needs a ?? operator is to remove the
temptation to "simplify" code or save keystrokes by using || in
cases like the one we've been discussing in this thread. IMHO.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Tue, 14 Nov 2000 18:05:00 -0500
From: "Mike Mesarch" <mesarch@ee.net>
Subject: Re: Mail
Message-Id: <8usghi$cib$1@sshuraaa-i-1.production.compuserve.com>
I know based on my message you probably don't think I already did that, but
I did... Would you be so kind as to show some example code?
-Mike
"Peter Sundstrom" <peter.sundstrom@eds.com> wrote in message
news:8usf8a$ar1$1@hermes.nz.eds.com...
>
> Mike Mesarch <mesarch@ee.net> wrote in message
> news:8us8gt$29i$1@sshuraab-i-1.production.compuserve.com...
> > Can someone provide me with some code to send a mail message in perl.
> > Typically I don't ask for something like this, but I have searched to no
> > avail on how to do this. In the doco it suggests using sendmail
> > Mail:Mailer. All i want to do is connect to a mail server
> > (smtp.something.com) and send a message. I haven't seen anything to do
> > this.
>
> There are lots of modules to do this. Check out the following list on
CPAN
>
> MailTools
> Mail-Sender
> Mail-Sendmail
> MIME-Lite
>
>
------------------------------
Date: Wed, 15 Nov 2000 13:50:14 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Mail
Message-Id: <8usmq0$n92$1@hermes.nz.eds.com>
Mike Mesarch <mesarch@ee.net> wrote in message
news:8usghi$cib$1@sshuraaa-i-1.production.compuserve.com...
> "Peter Sundstrom" <peter.sundstrom@eds.com> wrote in message
> news:8usf8a$ar1$1@hermes.nz.eds.com...
> >
> > Mike Mesarch <mesarch@ee.net> wrote in message
> > news:8us8gt$29i$1@sshuraab-i-1.production.compuserve.com...
> > > Can someone provide me with some code to send a mail message in perl.
> > > Typically I don't ask for something like this, but I have searched to
no
> > > avail on how to do this. In the doco it suggests using sendmail
> > > Mail:Mailer. All i want to do is connect to a mail server
> > > (smtp.something.com) and send a message. I haven't seen anything to
do
> > > this.
> >
> > There are lots of modules to do this. Check out the following list on
> CPAN
> >
> > MailTools
> > Mail-Sender
> > Mail-Sendmail
> > MIME-Lite
>
> I know based on my message you probably don't think I already did that,
but
> I did... Would you be so kind as to show some example code?
> -Mike
Most modules come with examples in the documentation. For instance:
---------------------------------------------------------
use Mail::Sender;
$sender = new Mail::Sender
{smtp => 'mail.yourdomain.com', from => 'your@address.com'};
$sender->MailFile({to => 'some@address.com',
subject => 'Here is the file',
msg => "I'm sending you the list you wanted.",
file => 'filename.txt'});
-------------------------------------------------------
use Mail::Sendmail;
%mail = ( To => 'you@there.com',
From => 'me@here.com',
Message => "This is a very short message"
);
sendmail(%mail) or die $Mail::Sendmail::error;
print "OK. Log says:\n", $Mail::Sendmail::log;
------------------------------
Date: Tue, 14 Nov 2000 15:53:47 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Please tell me why this code is wrong (ActiveState build 613 on Winblows)
Message-Id: <3A11D08B.DD156F6@vpservices.com>
David Steuber wrote:
>
> Does ActiveState Perl work with the -w option in the script?
Yes, definitely. Try it by running "perl scriptname" from the command
prompt rather than counting on the file association. Scripts with -w
(or other options) on the shebang line will run with those options.
--
Jeff
------------------------------
Date: Tue, 14 Nov 2000 23:32:28 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Please tell me why this code is wrong (ActiveState build 613 on Winblows)
Message-Id: <m3y9ymi0z8.fsf@solo.david-steuber.com>
garry@ifr.zvolve.net (Garry Williams) writes:
' On Tue, 14 Nov 2000 17:06:27 -0500, Jeff Pinyan <jeffp@crusoe.net>
' wrote:
' >On Nov 14, dsteuber@my-deja.com said:
' >
' >>my %foo_hash = { bar => "baz" };
This is a typo. My original script used:
my %foo_hash = (); # different name actually
And then added key/value pairs to it. Oh well.
' >This is incorrect. You want (...) instead of {...}. Next time, run Perl
' >with the -w switch turned on.
'
' Not sure why you think this wasn't done, but it will make no
' difference. The code will compile without any warnings. However, at
' *run time*, it will generate the warning "Reference found where
' even-sized list expected at...", if warnings are enabled. The
' original poster's code never made it to run time due to the compile
' time error that you correctly explained.
The problem, as pointed out by others, was a missing -> operator.
Once I caught that, I tried to cancel the post, but not all servers
honor that.
I made sure to pick up a good supply of arrows at the drug store ;-).
Does ActiveState Perl work with the -w option in the script? NT is
set up to run a .pl file with the Perl interpreter automatically. If
you look at my original script, the -w was in the #! line. But that
would likely as not be ignored by ActiveState.
Then again, earlier runs before I got to this point would spew
warnings when appropriate, so I think they are on. I will be hacking
away at it again tomorrow.
Thanks for the suggestions.
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: 14 Nov 2000 15:32:53 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Please tell me why this code is wrong (ActiveState build 613 on Winblows)
Message-Id: <m3itpqfddm.fsf@dhcp11-177.support.tivoli.com>
dsteuber@my-deja.com writes:
> #!/usr/bin/perl -w
> use strict;
>
> package Foo;
>
> my %foo_hash = { bar => "baz" };
Oops... the curlies create a hash *reference*, which isn't what you
want. Is that just a typo here, because if not then you should have
gotten an error: "Reference found where even-sized list expected".
> sub get_foo_hash {
> return \%foo_hash;
> }
>
> package main;
>
> my $foo_hash_ref = Foo::get_foo_hash();
>
> printf "%s\n", $foo_hash_ref{bar};
Here, $foo_hash_ref{bar} is the syntax for accessing the value
associated with the key "bar" in the hash, %foo_hash_ref. You need to
dereference it first:
printf "%s\n", $foo_hash_ref->{bar};
HTH,
--
Ren Maddox
ren@tivoli.com
------------------------------
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 V9 Issue 4890
**************************************