[11593] in Perl-Users-Digest
Perl-Users Digest, Issue: 5193 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 21 19:07:17 1999
Date: Sun, 21 Mar 99 16:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 21 Mar 1999 Volume: 8 Number: 5193
Today's topics:
Re: 2nd Request, please help Re: newbie: how do I read (Abigail)
Re: 2nd Request, please help Re: newbie: how do I read <cassell@mail.cor.epa.gov>
Re: [Perl] How to find the Perl FAQ (EXCHANGE:SKY:1Z22)
Re: Accessing NT ACLs remotely <cassell@mail.cor.epa.gov>
Re: automatic converters of perl4 to perl5 (Mark-Jason Dominus)
Re: Can't read a text file with weird characters in it. <cassell@mail.cor.epa.gov>
FIDO <flanker@sonnet.ru>
Re: How to find individual undefined array values? (Bart Lateur)
HTML in email <brian@removethisnet-weaver.com>
Re: HTML in email (Earl Hood)
iPerl V0.2 documented & many bugs fixed (de, en & eo) <occitan@esperanto.org>
Re: Need Faster Approach (Earl Hood)
Re: newbie - counting words (Larry Rosler)
Perl question q969@truman.edu
Re: Perl scripts written for UNIX. Will they work on NT (Lee)
Re: Sending Mail Through SMTP (Ken Pizzini)
Re: Sending Mail Through SMTP <mfoster@spots.ab.ca>
Re: Sending to multiple recipients via Sendmail <mfoster@spots.ab.ca>
Re: Sending to multiple recipients via Sendmail <GLEdwards@christianfamilies.net>
Re: Sending to multiple recipients via Sendmail (Earl Hood)
Re: Several lines into one <flanker@sonnet.ru>
Sorting a file <bschand@math.clemson.edu>
Re: using passing delimiter of regexp to sub (Tad McClellan)
Weird Perl problem <kavian@nortelnetworks.com>
Re: What isn't getting reset? <bwegman@HiWAAY.net>
Re: Where to start with Perl <ewolfe@involved.com>
Re: Where to start with Perl <rwolfe@rwolfe.com>
Re: Why can't i create a file with >>$file? <cassell@mail.cor.epa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Mar 1999 22:46:21 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: 2nd Request, please help Re: newbie: how do I read in binary file, modify bytes and write out?
Message-Id: <7d3srt$mpb$1@client2.news.psi.net>
Joe (painter2000@Cybernex.Net) wrote on MMXXVIII September MCMXCIII in
<URL:news:7d3cv8$qvl$1@news.cybernex.net>:
[] I did RTFM, checked the FAQs, the books, dejanews and I cannot find an
[] answer....anyone? Can PERL do this?
I remember answering the question. The answer is: yes.
Perl doesn't give a damn what format your file is in. Just read it in
like any other file, analyze the data, modify it, and write it back.
Just like any other file.
Of course, when it comes to *interpreting* the data, you're on your own.
Just like with any other format....
Abigail
--
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-
------------------------------
Date: Sun, 21 Mar 1999 15:54:10 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: 2nd Request, please help Re: newbie: how do I read in binary file, modify bytes and write out?
Message-Id: <36F586A2.BAAA0F8C@mail.cor.epa.gov>
Joe wrote:
>
> I did RTFM, checked the FAQs, the books, dejanews and I cannot find an
> answer....anyone? Can PERL do this?
Yep. See below. There is an immense amount of documentation with Perl,
so it sometimes happens that one's extensive search turns into a scan, which
then turns into a missover. Oops.
> >I checked FAQ and dejanews and haven't seen this discussed. "Programmin Perl"
> >doesn't really explain it. My goal is to read an MP3 file, analyze the
> >data, then modify it and write it as a new MP3 file. It seems like a simple
> >thing to do but HOW DOES ONE DO IT???
If you have a modern version of ActivePerl (I have build 509 and like it),
you can pull up a MS-DOS Prompt box and type 'perldoc -q binary' to search the
FAQ for the word binary. You'll find just what you want there (I think).
Alternatively, use the HTML version form your start menu, and look through
the Core Perl FAQ.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sun, 21 Mar 1999 18:10:29 -0500
From: "Soulier, Michael (EXCHANGE:SKY:1Z22)" <msoulier@americasm01.nt.com>
Subject: Re: [Perl] How to find the Perl FAQ
Message-Id: <36F57C65.28038DBF@americasm01.nt.com>
I just tried accessing the html version:
Not Found
The requested URL /perl/nmanual/pod/perlfaq.html was not found on this
server.
Also, the pictures on the URL you mention are broken.
Cheers,
Mike
Tom Phoenix wrote:
>
> Archive-name: perl-faq/finding-perl-faq
> Posting-Frequency: weekly
> Last-modified: 10 Sep 1998
>
> [ That "Last-modified:" date above refers to this document, not to the
> Perl FAQ itself! The last major update of the Perl FAQ was in Summer of
> 1998; of course, ongoing updates are made as needed. ]
>
> For most people, this URL should be all you need in order to find Perl's
> Frequently Asked Questions (and answers).
>
> http://cpan.perl.org/doc/FAQs/
###################################################################
Michael Soulier SKYLINE: ESN 39-54699
Nortel, Dept:1Z22, MS:136, TEL: 613-765-4699
Carrier Packet Networks email: msoulier@nortelnetworks.com
Stream Management Fax: 613-763-1297
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort."
-Harley Hahn, A Student's Guide to UNIX
###################################################################
------------------------------
Date: Sun, 21 Mar 1999 15:43:24 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Accessing NT ACLs remotely
Message-Id: <36F5841C.DD7E5B0A@mail.cor.epa.gov>
Marquis de Carvdawg wrote:
>
> I am working on a way to access Registry and Dir/file
> ACLs within my domain, all from my box. I want to move
> away from using DumpACL and make it 100% Perl.
>
> Which modules can I use to get the Registry and Dir ACLs?
>
> Again, I need to do remotely...the assumption is that as I
> am Domain Admin, I will be able to do so.
You're in luck if you've got a modern version of ActivePerl.
Check out the Win32 modules. Particularly Win32::TieRegistry .
If you want to get really down and dirty, there's
Win32API::Registry too. And Win32::NetAdmin and
Win32::NetResource . There are some nice examples of NT admin
code in back issues of The Perl Journal too, and they're
well worth the price.
HTH,
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sun, 21 Mar 1999 23:03:54 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: automatic converters of perl4 to perl5
Message-Id: <7d3tr7$gkt$1@monet.op.net>
In article <36dde039.7009967@news.skynet.be>,
Bart Lateur <bart.lateur@skynet.be> wrote:
>Randal L. Schwartz wrote:
>
>>Nope. Consider the following:
>>
>> sub foo { print "hey @there"; }
>> @there = (1..5); &foo();
>>
>>That will give the fatal error described above, but we really want to
>>leave @there alone.
>
>In a way, you're right. But, you said it: "fatal error".
The original discussion was about whether code that causes that error
could be automatically fixed. It can't be. If it could, it wouldn't
have to be a fatal error; Perl would just do the right thing.
>It should have stayed as it is, if only the error wasn't fatal.
That's nice, but how is Perl supposed to know that? It looks just
like this:
>> sub foo { print "hey mjd-blacklist@plover.com"; }
>> @plover = (1..5); &foo();
where presumably you would want it to be changed to \@plover.
>I don't think that Perl4 would have "done the right thing" for this case,
>either.
% perl4
sub foo { print "hey @there"; }
@there = (1..5); &foo();
hey 1 2 3 4 5
Looks like the right thing to me.
Anyone who suggests that @foo can be replaced everywhere with \@foo
doesn't understand the issue.
------------------------------
Date: Sun, 21 Mar 1999 14:48:26 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Can't read a text file with weird characters in it. Help.
Message-Id: <36F5773A.6935E6B3@mail.cor.epa.gov>
M.J.T. Guy wrote:
>
> Jason Stanley <jstanley@mmm.com> wrote:
> >I am trying to read through the text file below, but when it hits the odd
> >(ascii?) characters it won't read the rest of the file. How do I get it to
> >ignore all the strange characters and read all the words.
>
> I'd guess it's barfing on the ^Z which is interpreted as end of file.
>
> perldoc -f binmode
But since that means Jason is probably using a Wintel box, he might not
have 'perldoc'. Jason, I hope you're using a modern version of ActivePerl.
If so; pull up the online docs, pick the perlfunc webpage, click on the
functions-in-alphabetical-order URI, and scroll down to read about binmode.
HTH,
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Mon, 22 Mar 1999 01:33:19 +0300
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: FIDO
Message-Id: <7d3s0m$kgb$1@bison.rosnet.ru>
Are there any Perl scripts to process FIDO files, such as *.MSG and *.PKT?
--
Best wishes,
Michael Yevdokimov
Email: flanker@sonnet.ru
ICQ: 30874618
-------------------------------------------------
>> Developers Support Site <<
Web: http://developer.tsx.org
http://www.basicnet.sonnet.ru
-------------------------------------------------
------------------------------
Date: Sun, 21 Mar 1999 22:02:59 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How to find individual undefined array values?
Message-Id: <36f765b1.1124973@news.skynet.be>
Larry Rosler wrote:
>> @zeropadded = map { $_ || 0 } @array;
>
>Well, all right, provided you don't mind replacing the null string "" by
>0. 'undefined' ne 'null'. FALSE has three flavors in Perl.
Assuming a numerical environment (and I did ;-), that is probably what
is wanted, anyway.
Bart.
------------------------------
Date: Sun, 21 Mar 1999 17:55:34 -0500
From: "Brian" <brian@removethisnet-weaver.com>
Subject: HTML in email
Message-Id: <7d3tcg$cgi$1@winter.news.rcn.net>
Hi.
I have created a script that sends a generated html page to an email
address. All works fine except that I get the actual html code in Outlook
Express and not the interpreted html page. Is there something I need to add
in my script to tell the email program that this is html and should be
displayed? When I use Outlook express to send Rich Text (HTML) email message
to myself, I get the interpreted HTML so, I don't think it's Outlook Express
that isn't configured correctly. Here is the ouput I send. Any help would be
greatly appreciated. Thanks. Brian
open(MAIL,"|$mailprog -t");
print MAIL "To: mymail@mydomain.com";
print MAIL "From: $in{'author'}\n";
print MAIL "Subject: Article Submission\n\n";
print MAIL "Content-Type: \"text/html;\"\n\n";
print MAIL "<HTML>\n";
print MAIL "<HEAD>\n";
print MAIL "<TITLE>[ $in{'arttitle'} ]</TITLE>\n";
print MAIL "<meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;
charset=windows-1252\">\n";
print MAIL "<meta NAME=\"keywords\" CONTENT=\"$in{'arttitle'}\">\n";
print MAIL "<link rel=\"stylesheet\" href=\"/css/common.css\">\n";
print MAIL "</head>\n";
print MAIL "<body LINK=\"#0000ff\" VLINK=\"#800080\">\n";
print MAIL "<table CELLSPACING=\"0\" BORDER=\"0\" WIDTH=\"400\">\n";
print MAIL "<tr>\n";
print MAIL " <td VALIGN=\"MIDDLE\">\n";
print MAIL " <p>\n";
print MAIL " <font SIZE=+2
COLOR=\"#023766\">$in{'arttitle'}</font><BR>\n";
print MAIL " <font SIZE=\"2\" color=\"#023766\"><em>by
$in{'author'}</em></font>\n";
print MAIL " <br>\n";
print MAIL " </p>\n";
print MAIL " <p>\n";
print MAIL " <font SIZE=\"2\" COLOR=\"#000000\">$in{'artbody'}\n";
print MAIL " </font><br>\n";
print MAIL " </p>\n";
print MAIL " </td>\n";
print MAIL "</tr>\n";
print MAIL "<tr>\n";
print MAIL " <td VALIGN=\"MIDDLE\">\n";
print MAIL " <p><br>\n";
print MAIL " <font SIZE=\"2\"
color=\"#000000\"><em>$in{'artauthorbio'}</em></font>\n";
print MAIL " </p>\n";
print MAIL " </td>\n";
print MAIL "</tr>\n";
print MAIL "</table>\n";
print MAIL "</body>\n";
print MAIL "</html>\n";
close (MAIL);
------------------------------
Date: 21 Mar 1999 23:04:26 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: HTML in email
Message-Id: <7d3ttq$p63@news.service.uci.edu>
In article <7d3tcg$cgi$1@winter.news.rcn.net>,
Brian <brian@removethisnet-weaver.com> wrote:
> print MAIL "From: $in{'author'}\n";
> print MAIL "Subject: Article Submission\n\n";
> print MAIL "Content-Type: \"text/html;\"\n\n";
--------------------------------^ ----------^
Why the double quotes? This is probably what is throwing the MUA off.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Sun, 21 Mar 1999 22:40:49 GMT
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: iPerl V0.2 documented & many bugs fixed (de, en & eo)
Message-Id: <7d3shf$6hj$1@nnrp1.dejanews.com>
Deutsch:
Der iPerl Interpreter ist ein transformierender Filter, der wie der C
Prdprozessor oder der m4 Makroprozessor funktioniert, nur, da_ die
eingebettete Sprache Perl in seiner ganzen Macht ist. Per SGML/HTML/XML ist
dies auch im Internet sehr interessant, wie mitgelieferte Beispiele zeigen.
Er ist nun ordentlich dokumentiert (wenn auch nur auf Englisch) und arbeitet
|berwiegend fehlerfrei.
English:
The iPerl interpreter is a transforming filter, that works much like the C
preprocessor or the m4 macro processor, only that the language embedded
into a document is full powered Perl. With SGML/HTML/XML this is also very
interesting in web-pages, as included examples show. It is now well
documented and works mostly without errors.
Esperanto:
La iPerl interpretilo estas aliformiga filtrilo kiu funkcias kiel la C
anta^uprocezilo a^u la m4 makroprocezilo, nur ke ^gi enmetebligas plenpovan
Perl en viajn dokumentojn. Kun SGML/HTML/XML tio estas interesega por
TTT-pa^goj, kiel kunliveritaj ekzemploj montras. ^Gi estas nun bone
priskribita (kvankam nur angle) kaj plejparte funkcias senerare.
http://beam.to/iPerl (de, en & eo)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 21 Mar 1999 21:53:10 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Need Faster Approach
Message-Id: <7d3po6$n4f@news.service.uci.edu>
In article <m3ww0aoo4x.fsf@joshua.panix.com>,
Jonathan Feinberg <jdf@pobox.com> wrote:
>ehood@medusa.acs.uci.edu (Earl Hood) writes:
>> What do you think split does internally?
>It certainly doesn't write a Perl loop that calls index() over and
>over!
Duh. What I was refering to is that split internally must iterate
over the entire string.
>Writing a loop in Perl is much more CPU-burning than calling a
>single Perl op. At any rate, the split() operator accepts a regex as
>its first argument, so it can't be implemented using index().
Duh. Note, the original problem is using a fixed string as a
delimiter so the regex capability with split is a non-advantage.
See Ronald's post that actually tests the two approaches.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Sat, 20 Mar 1999 21:53:55 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie - counting words
Message-Id: <MPG.115e294cee4a39df98979c@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <36F43F4B.F70E5AA5@iname.com> on Sat, 20 Mar 1999 18:37:31 -
0600, Rahul K <rahulk@iname.com >says...
>
> Thanks guys! What I want the program to do is get the value of the fourth
> item in a comma delimited file, calculate the number of occurences of
> those items, sort it descending order and display the first twenty values.
> Here is what I came up with. It works fine but I would like your feedback
> as to how to make it run faster. (the comma delimited file contains more
> than 500000 entries!).
>
...
> -----------------------snip-----------------------
> use Text::ParseWords;
>
> my @new = ();
> my @macham = ();
> open (IN,"logger.txt")|| die "unable to open logger";
Put $! in the diagnostic.
> @allentries = <IN>;
This reads the entire file into an array. It must be better to process
the file one line at a time.
> foreach $entry (@allentries) {
> @macham = parse_it($entry);
I won't argue with your use of this module for what seems like a very
simple task, but I will argue with the extra level of subroutine call.
> #ignore blank entries
> if ($macham[3] ne ""){
> push(@new, lc($macham[3]));
> }
And I wouldn't push these things onto an array just to process them
again in a loop. Do it here!
> }
>
> for(@new){
> chomp;
> $COUNT{$_}++;
> }
So, with personal stylistic changes, the data-gathering phase reduces
to:
my %count;
open IN, 'logger.txt' or die "unable to open logger. $!\n";
while (<IN>) {
chomp; # I'm not sure this is needed.
my $word = (quotewords(',', 0, $_))[3];
$count{lc $word}++ if length $word;
}
> my $k = 0;
> foreach $key(sort {$COUNT{$b} <=> $COUNT{$a}} keys %COUNT){
> #print only first twenty items
> if (($k < 21) ){
You should use 'last' to get out of the loop instead of spinning on.
> print "$key\t$COUNT{$key}";
> $k++;
> }
> }
>
> close(IN);
>
> sub parse_it {
> return quotewords(",",0,$_[0]);
> }
for ((sort { $count{$b} <=> $count{$a} } keys %count)[0 .. 19]) {
print "$_\t$count{$_}\n";
}
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 21 Mar 1999 22:23:27 GMT
From: q969@truman.edu
Subject: Perl question
Message-Id: <36f56f64.91746384@news.truman.edu>
I've never posted here before, and I'm unsure whether this is the
appropriate forum to ask perl question, but I'll try it anyway.
I'm new to perl and I've written a script to pull data from a
form-enabled web page. It then writes the data to a text file (this
is on a unix web server). It also has a feature by which the user can
revise previously entered data. In this case, it reads data from the
text file and displays as a web page.
It works fine except when a user tries to enter multiple lines
separated by an enter (newline). In this case, perl only displays the
first line (i.e. everything up to the newline character). I've been
told that this is because a newline is a default record delimeter.
I've tried to use the =~ command to parse out newlines and replace
them with spaces (though any character would do). The command I've
used is $value[$n] =~ s/\n/ /; But this never works (I've tried
changing the 's' to a 'tr'). I get the same output to the text file
whether I include this line or not.
I'd be grateful for any suggestions you have. If I should post this
message elsewhere, just let me know.
Nate Sternberg
------------------------------
Date: Sun, 21 Mar 1999 17:45:09 -0600
From: rlb@intrinsix.ca (Lee)
Subject: Re: Perl scripts written for UNIX. Will they work on NT?
Message-Id: <B31AE0A59668CC16E@0.0.0.0>
In article <MPG.115c6903f5d5f71498978f@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) wrote:
>None of my dictionaries contains 'snarky'.
Dictionaries never pick up the good words until after they've fallen out of
fashion.
>Oh, well. Whether or not this post is snarky, I hope it is sufficiently
>dismissive. Bye, bye!
The pleasure was mine.
Lee
------------------------------
Date: 21 Mar 1999 22:20:56 GMT
From: ken@halcyon.com (Ken Pizzini)
Subject: Re: Sending Mail Through SMTP
Message-Id: <slrn7fas4a.th9.ken@pulsar.halcyon.com>
On Sat, 20 Mar 1999 20:26:19 -0700, Martin Foster <mfoster@spots.ab.ca> wrote:
>Though I have a copy of sendmail on my system, I would much rather
>employ a SMTP connection to send out mail if needed. While this may
>seem pointless to some, it is necessary for me, to have portable code,
>and that means being able to local machines with Sendmail or systems
>that have access to a SMTP server but no direct access to sendmail.
I have successfully used the Net::SMTP module (GBARR/libnet)
for something like this in the past. Perhaps it will offer
you a better starting point?
--Ken Pizzini
P.S.: I have modified the Newsgroups: and Followup-To: headers
to redirect the crosspost to the obsolete ``comp.lang.perl'' newsgroup
to ``comp.lang.perl.misc''.
------------------------------
Date: Sun, 21 Mar 1999 15:43:17 -0700
From: Martin Foster <mfoster@spots.ab.ca>
Subject: Re: Sending Mail Through SMTP
Message-Id: <36F57605.481A83AF@spots.ab.ca>
Ken Pizzini wrote:
>
> On Sat, 20 Mar 1999 20:26:19 -0700, Martin Foster <mfoster@spots.ab.ca> wrote:
> >Though I have a copy of sendmail on my system, I would much rather
> >employ a SMTP connection to send out mail if needed. While this may
> >seem pointless to some, it is necessary for me, to have portable code,
> >and that means being able to local machines with Sendmail or systems
> >that have access to a SMTP server but no direct access to sendmail.
>
> I have successfully used the Net::SMTP module (GBARR/libnet)
> for something like this in the past. Perhaps it will offer
> you a better starting point?
>
> --Ken Pizzini
>
> P.S.: I have modified the Newsgroups: and Followup-To: headers
> to redirect the crosspost to the obsolete ``comp.lang.perl'' newsgroup
> to ``comp.lang.perl.misc''.
Hash: SHA1
I will look into it. This is a module that comes with the basic
distribution, or should I check CPAN to track it down. As for my
Example, it "almost" works. I think Learning Perl had managed to do
something like this by forking the code. One would write while the
other would read, but I am just not getting the logic of the matter.
Martin Foster
mfoster@spots.ab.ca.
Version: PGP 6.0.2
iQA/AwUBNvV1/fQbn7ugux5EEQJjhwCg3zuz31J4mzqia5hw0yNIl6lr2cwAmwVj
+JuiC4s3buAlqdlq4qwu7CrS
=qMMt
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 21 Mar 1999 15:06:31 -0700
From: Martin Foster <mfoster@spots.ab.ca>
Subject: Re: Sending to multiple recipients via Sendmail
Message-Id: <36F56D67.4B68F5AA@spots.ab.ca>
Jonathan Stowe wrote:
>
> In comp.lang.perl.misc Glen Lee Edwards <GLEdwards@christianfamilies.net> wrote:
> > I have a small mailing list, about 25, that I use from a mailing program I
> > wrote. Currently I am closing the pipe after each letter is sent and then
> > reopening it for the next letter. Is there a way from a PERL program to
> > notify Sendmail that one letter is finished and a new one is coming without
> > closing and reopening the pipe?
> >
>
> Err no you cant do that. But why would you want to ? there are other
> facilities available to send mail to multiple recipients. If you are
> using sendmail then you could set up an :include: file in your aliases file
> or alternativley you could just set the Bcc: header to a list of the
> intended recipients.
>
> If you do want to send each mail individually however (In the case say that
> you want to personalise each mail) then you will have to open a pipe to
> sendmail for each message send and close it before the next one - that is
> how it knows that the message text has ended.
>
Hash: SHA1
Could you not interface directly with the SMTP side of Sendmail. That
way you would alleviate the need for having to open multiple pipes and
it would allow you to make the script for system independent, since
some people use Qmail, and Sendmail, and MS Echange et cetera.
Of course you would have to read the RFC files on how the protocol
functions. This has been regarded as being very complex to do in the
PERL Cookbook. I myself have a very rudimentary script that will
perform the function, while generating error messages in the system
logs (version 0.0.1). Below are example commands to use when sending
mail.
ehlo IPADDRESS
mail from: whoever@who.care.com
rcpt to: first@person.com
rcpt tp: second@person.com
..
..
data
Marry had a little Lamb.
.
quit
And the list of these the message has gone two is not directly given
out since, you will also have to create the headers yourself (just rip
them off another E-Mail client and use that as a blueprint). It
actually works quite well once you figure out the protocol and
discover that though you really don't care what SMTP outputs, you need
to input it before sending out the next command.
Martin Foster
mfoster@spots.ab.ca
P-S. You can interface with SMTP directly by telneting into port 25
of the server you deal with. Which in most cases will be localhost.
Version: PGP 6.0.2
iQA/AwUBNvVtVvQbn7ugux5EEQJHnACg415MRVoYoAIfg5ts2fZ58pNbxkoAn1dU
eTFBS3k+rAGBj9cpmKye6HFK
=xqRd
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 21 Mar 1999 16:06:04 -0600
From: "Glen Lee Edwards" <GLEdwards@christianfamilies.net>
Subject: Re: Sending to multiple recipients via Sendmail
Message-Id: <7d3q7v$cfu1@iac7.navix.net>
Jonathan,
Thanks for replying. Some comments to follow:
>> reopening it for the next letter. Is there a way from a PERL program to
>> notify Sendmail that one letter is finished and a new one is coming
without
>> closing and reopening the pipe?
>>
>
>Err no you cant do that. But why would you want to?
Speed up execution of the program.
>there are other
>facilities available to send mail to multiple recipients.
I didn't know that.
>If you are
>using sendmail then you could set up an :include: file in your aliases file
I don't have root access. Is that necessary to do this?
>or alternativley you could just set the Bcc: header to a list of the
>intended recipients.
I've done that, and received some very rude automated replys from systems
for having a "rediculuously long header."
>If you do want to send each mail individually however (In the case say that
>you want to personalise each mail) then you will have to open a pipe to
>sendmail for each message send and close it before the next one - that is
>how it knows that the message text has ended.
Actually I don't care how the letters get there. Thanks for your help.
I'll check into the alias thing.
Glen
>
>/J\
>--
>Jonathan Stowe <jns@btinternet.com>
>Some of your questions answered:
><URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
>Hastings:
<URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 21 Mar 1999 23:11:05 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Sending to multiple recipients via Sendmail
Message-Id: <7d3ua9$p9p@news.service.uci.edu>
In article <7d3q7v$cfu1@iac7.navix.net>,
Glen Lee Edwards <GLEdwards@christianfamilies.net> wrote:
>>If you are
>>using sendmail then you could set up an :include: file in your aliases file
>
>I don't have root access. Is that necessary to do this?
>
>>or alternativley you could just set the Bcc: header to a list of the
>>intended recipients.
>
>I've done that, and received some very rude automated replys from systems
>for having a "rediculuously long header."
RTFM the manual for sendmail. If calling it to send a mail message,
each non-option related argument on the command line is treated
as a destination address. Make sure to not use the -t option since
this instructs sendmail to get receipient addresses from the
message header.
This allows you to send a message to many receipients w/o having
a long header.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Sun, 21 Mar 1999 21:21:14 +0300
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: Re: Several lines into one
Message-Id: <7d3rtc$kg3$1@bison.rosnet.ru>
Hi
>$text =~ s/\r\n\s+/\r\n /g; # to preserve (some) indentation.
>$text =~ s/\r\n/<br>/g; # to preserve line breaks when displaying as html.
It's a cool code! Works fine.
Could you also comment what does subexpressions \s+ mean and why you change
source value onto \r\n ?
But could you tell me how to check for empty line and to restore such lines
in HTML?
Best wishes,
Michael Yevdokimov
Email: flanker@sonnet.ru
ICQ: 30874618
-------------------------------------------------
>> Developers Support Site <<
Web: http://developer.tsx.org
http://www.basicnet.sonnet.ru
-------------------------------------------------
------------------------------
Date: Sun, 21 Mar 1999 17:06:17 -0500
From: Bernd Schandl <bschand@math.clemson.edu>
Subject: Sorting a file
Message-Id: <36F56D59.C7F50E1E@math.clemson.edu>
I have a file which looks basically like this:
\begin{person}{Dion, Celine}
\name{Celine Dion}
some text for CD
\end{person}
\begin{person}{Cooper, Gary}
\name{Gary Cooper}
some text for GC
\end{person}
\begin{person}{Day, Doris}
\name{Doris Day}
some text for DD
\end{person}
This file should be sorted and come out like this:
\begin{person}{Cooper, Gary}
\name{Gary Cooper}
some text for GC
\end{person}
\begin{person}{Day, Doris}
\name{Doris Day}
some text for DD
\end{person}
\begin{person}{Dion, Celine}
\name{Celine Dion}
some text for CD
\end{person}
How can I do this with PERL?
Thanks
Bernd
--
Bernd Schandl
Department of Mathematical Sciences
Clemson University
Clemson, SC 29634-1907
------------------------------
Date: Sun, 21 Mar 1999 11:29:20 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: using passing delimiter of regexp to sub
Message-Id: <0p63d7.0v3.ln@magna.metronet.com>
Zenno (zenno22@hotmail.com) wrote:
: How can I pass a char to a function and use that char as a delimiter in
: a regexp?
No problem if "the character" is not a regex metacharacter.
You need to escape it if it is a regex metacharacter.
: I have a file with words separated by a character. this may be a space,
: a '|' symbol or by any other char. Therefore I pass the delimiter as the
: last argument in the function call.
: I tried it like this:
: @LoL = get_FileText_LOL($aFilePath.'|'); # read the file in a LoL
: sub get_FileText_LOL {
: my($file) = @_;
: my($delimiter) = pop(@_);
The more usual idiom for getting two arguments is:
my($file, $delimiter) = @_;
: my(@LoL) = ();
: open(FILEHANDLE, "<$file") || &file_open_error("can\'t read open file
: $file $!\n");
: foreach $line(<FILEHANDLE>) {
: @tmp = split(/$delimiter/,$line); #The words in this file are
@tmp = split(/\Q$delimiter/,$line);
^^
: separated by a "|" symbol.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 21 Mar 1999 17:16:42 -0500
From: "Kavian Moradhassel" <kavian@nortelnetworks.com>
Subject: Weird Perl problem
Message-Id: <7d3r26$eu2$1@bmerhc5e.ca.nortel.com>
I'm having a rather odd problem with Perl 5.00502 that I'm hoping someone
else has run into.
Basically what's happening is when a variable is declared (using 'my'), and
then later accessed before it's assigned any value (ie. it's still 'undef'),
the tool just hangs--no error message, no 'die', nothing. It just stops
(since it's running as a CGI, the browser just keeps trying to load the page
until it times out). There are no compile errors, and everything that is
output before that point in the execution is fine.
The details: The script is a five-line driver script using a Perl module
(which subsequently 'use's three or four other modules) with 'use strict'
and the '-w' switch on. It's running as a CGI executing with Perl 5.00502
on an Apache server on an HPUX 10.20 machine (a Merlin, I believe).
I've never seen anything like this before; as far as I know, anything that
is 'undef' should be automatically translated to a value of 0 or an empty
string whenever it is accessed. And even if it is going to die, there
should be an error message! Needless to say, I'm at something of a loss.
Anyone have any ideas? (please!)
Thanks,
Kav Moradhassel
kavian@nortelnetworks.com
------------------------------
Date: Sun, 21 Mar 1999 16:00:12 -0600
From: Barron Michael Wegman <bwegman@HiWAAY.net>
Subject: Re: What isn't getting reset?
Message-Id: <KQW2xY#c#GA.202@pet.hiwaay.net>
Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
: What version of Perl are you using?
:
: This is likely a bug in earlier versions of Perl which has now been
: fixed.
I'm using a fairly recent version, 5.004_04 built for alpha-dec_osf.
Sorry, I meant to mention this in my question, but I forgot.
------------------------------
Date: Sun, 21 Mar 1999 15:25:48 -0800
From: Ed Wolfe <ewolfe@involved.com>
Subject: Re: Where to start with Perl
Message-Id: <36F57FFC.2D2D86E5@involved.com>
Rick Poleshuck wrote:
[snip]
> If you have the time, _Teach Yourself Perl 5
> in 21 Days_ from Sams is an unlikely, but excellent book. I have used this
> book to teach Perl in training seminars.
Would you recommend that book to someone with no programming experience
or knowledge at all? (Not counting what I did at home with a TI back in
'82.)
There are a lot of resources online and in print, but everything I've
seen so far assumes pre-existing programming knowledge, EVEN when it
specifically says it doesn't assume such.
The closest thing I've found so far to an introduction to Perl for
non-programmers is at:
http://www.netcat.co.uk/rob/perl/win32perltut.html
It goes great until I get to accessing arrays and then I start losing
it. The next section is on for loops and all hope is lost.
Example:
@names=("Muriel","Gavin","Susanne","Sarah","Anna","Paul","Trish","Simon");
for ($x=0; $x <= $#names; $x++) {
print "$names[$x]\n";
}
$x has the value of 0 and there's an end of line semicolon. But then it
says lesser than equals the array "names" then increment 0 one time??
Then print the name Muriel??
So, I'm looking for a way to learn Perl that doesn't assume I know
how to program already or know Unix. I'm using the latest release of
Perl from Active State on Win95.
I read a review that said Perl For Dummies has some really bad
technical errors so that scared me out of buying what would probably
be the most introductory thing I could find.
I also have Learning Perl but after page 12 it starts turning
into Greek.
Does anyone have any online or print recommendations for a total
beginner?
Thanks.
Ed
------------------------------
Date: Sun, 21 Mar 1999 23:58:05 GMT
From: Richard Wolfe <rwolfe@rwolfe.com>
Subject: Re: Where to start with Perl
Message-Id: <36F5A3C0.7CC46158@rwolfe.com>
Ed-
If you fit the following criteria (and it seems like most everyone who
is learning Perl now does...I know I did about six months ago):
1. You want to learn Perl to develop CGI scripts.
2. You'll be running your scripts on a UNIX server.
3. You don't know anything about UNIX.
If that's you, I would HIGHLY recommend Peachpit's "Visual QuickStart
Guide: Perl and CGI for the World Wide Web." Start there, and THEN move
on to the "llama" book.
HTH,
Richard
Ed Wolfe wrote:
>
> Rick Poleshuck wrote:
>
> [snip]
>
> > If you have the time, _Teach Yourself Perl 5
> > in 21 Days_ from Sams is an unlikely, but excellent book. I have used this
> > book to teach Perl in training seminars.
>
> Would you recommend that book to someone with no programming experience
> or knowledge at all? (Not counting what I did at home with a TI back in
> '82.)
>
> There are a lot of resources online and in print, but everything I've
> seen so far assumes pre-existing programming knowledge, EVEN when it
> specifically says it doesn't assume such.
>
> The closest thing I've found so far to an introduction to Perl for
> non-programmers is at:
>
> http://www.netcat.co.uk/rob/perl/win32perltut.html
>
> It goes great until I get to accessing arrays and then I start losing
> it. The next section is on for loops and all hope is lost.
>
> Example:
>
> @names=("Muriel","Gavin","Susanne","Sarah","Anna","Paul","Trish","Simon");
>
> for ($x=0; $x <= $#names; $x++) {
> print "$names[$x]\n";
> }
>
> $x has the value of 0 and there's an end of line semicolon. But then it
> says lesser than equals the array "names" then increment 0 one time??
> Then print the name Muriel??
>
> So, I'm looking for a way to learn Perl that doesn't assume I know
> how to program already or know Unix. I'm using the latest release of
> Perl from Active State on Win95.
>
> I read a review that said Perl For Dummies has some really bad
> technical errors so that scared me out of buying what would probably
> be the most introductory thing I could find.
>
> I also have Learning Perl but after page 12 it starts turning
> into Greek.
>
> Does anyone have any online or print recommendations for a total
> beginner?
>
> Thanks.
>
> Ed
------------------------------
Date: Sun, 21 Mar 1999 14:29:40 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Why can't i create a file with >>$file?
Message-Id: <36F572D4.78113913@mail.cor.epa.gov>
Larry Rosler wrote:
>
> [usual sage advice snipped]
> > Poohba <poohba@io.com> wrote in message
> > news:Pine.BSF.4.05.9903181406190.16980-100000@dillinger.io.com...
> > > I am trying to append to a file and it won't append nor will it create the
> > > file if it isn't there. Why? I am using:
> > >
> > > $file = "file.dat";
> > > open (FILE, ">>$file") || die "Can't open $file: $!\n";
> > > print FILE "print all of this junk\n";
> > > close(FILE);
> > >
> > > I can't get it to open or append to file. Why?
>
> That is a good diagnostic on the failure to open the file. What does it
> report on STDERR? If for some reason you can't read STDERR, simply
> print the diagnostic to STDOUT and exit.
>
> Some possibilities are: no permission to write to an existing file; no
> permission to create a file in the current directory; no space in the
> file system.
And because of such problems, it is also a good idea to run the
same diagnostic on your 'close':
close(FILE) or die "Can't close $file properly: $!\n";
as Larry has pointed out himself in endless numbers of previous posts.
BTW, if you don't need to interpolate your filename, you can use
single quotes:
$file = 'file.dat';
I find it helps the readability and maintainability if you know when
there is no need to do further interpolation, and when there is such
a need.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5193
**************************************