[13520] in Perl-Users-Digest
Perl-Users Digest, Issue: 931 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 28 14:32:57 1999
Date: Tue, 28 Sep 1999 11:10:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <938542217-v9-i931@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 28 Sep 1999 Volume: 9 Number: 931
Today's topics:
print buck_naked@NOiname.SPAMcom
Reliable UK ISP with Perl <jerryp.usenet@connected.demon.co.uk>
Re: remove the html tag in the file (Abigail)
Re: running other programs from perl (James Stevenson)
Simple Mail Transfer Protocol ... Not So Simple! <majid.sharif@mci.com>
Re: Slice in scalar context (Greg Bacon)
Re: Sorting weird numeric data <aqumsieh@matrox.com>
Re: Sorting weird numeric data (Larry Rosler)
Re: Stored encrypted messages in database <rootbeer@redcat.com>
Re: Suggestion - comp.lang.perl.flame (was Re: You shou (Abigail)
Re: Trouble with matching. Help appreciated. <par@removethis.bahnhof.se>
UNIX (Solaris 2.6) to NT ACCESS DB? <GPlumfield@worldnet.att.net>
Re: UNIX (Solaris 2.6) to NT ACCESS DB? (Scott McMahan)
Re: Using LWP and looking exactly like a web browser (Sean McAfee)
Re: using System function to run other programs (Larry Rosler)
why use references - in laymans terms? jdkronicz@my-deja.com
Re: why use references - in laymans terms? <crdevilb@mtu.edu>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 28 Sep 1999 11:28:12 -0500
From: buck_naked@NOiname.SPAMcom
Subject: print
Message-Id: <Pine.GSO.4.10.9909281123540.3920-100000@allegro>
I have possibly a two-fold question. I am avoiding using format for
this because it does not play well with variables scoped locally in a
sub or in a specific while loop of a sub. Maybe I just don't know how
to make it play well, but I have always had to use global variables
with a format. Anyway, I need to print something with a set amount of
spaces between two words. I am planning to just get the length of the
first word and then add spaces based on that. That's easy, but is
there a way for me to tell 'print' to print something a certain number
of times instead of saying 'print " "' I could say 'print " "*6
or something.
---
Mark
buck_naked@iname.com
------------------------------
Date: Tue, 28 Sep 1999 16:29:28 +0100
From: Jerry Pank <jerryp.usenet@connected.demon.co.uk>
Subject: Reliable UK ISP with Perl
Message-Id: <EC1AGUAY7N83Ew1C@btinternet.com>
Recommendations wanted for reliable UK/European ISP running Perl.
Our Web Hosters are Demon Internet but we are currently having terrible
reliability/resource problems with their CGI server.
I know there are plenty of other sources for this info but I would
really rather not do one this by trial and error.
Please e-mail if you can help.
-- Jerry Pank:wq connected@btinternet.com
OK, enough hype.
-- Larry Wall in the perl man page
------------------------------
Date: 28 Sep 1999 12:21:10 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: remove the html tag in the file
Message-Id: <slrn7v1uml.9kl.abigail@alexandra.delanet.com>
Samuel Kilchenmann (skilchen@swissonline.ch) wrote on MMCCXIX September
MCMXCIII in <URL:news:lK%H3.19563$m4.77238483@news.magma.ca>:
-- Earl Hood <ehood@medusa.acs.uci.edu> wrote in:
-- news:7sh9gr$5lc@news.service.uci.edu...
-- > In article <EVRG3.18678$m4.75164111@news.magma.ca>,
-- > Samuel Kilchenmann <skilchen@swissonline.ch> wrote:
-- >
-- [pointer to REBOL and example which was not good enough to convice
-- anybody]
-- >
-- > Does it properly handle
-- >
-- > <IMG SRC="goo.fig" ALT="This is > than that">
-- >
-- > Or comment declarations?
-- >
-- No, but the regexp in perlfaq9 does neither.
Perlfaq9 clearly says the regex offered is simple-minded, and wrong
for many cases.
-- So what Perl has to offer:
-- TOMC's striphtml (which may be good enough for most purposes, but which
-- does not handle nested comments (are they illegal?))
--
-- HTML::Parser which is unusable for newbies without a working example
-- which should be urgently added to perlfaq9.
Parsing HTML shouldn't be done by newbies, because it's non-trivial.
-- (and it doesn't handle nested comments either, but they may be indeed
-- illegal in HTML)
You can't even make nested comments in HTML, so the question whether
it's legal or not is a non-question.
Perl also has to offer:
open (NSGMLS, "| /usr/local/bin/nsgmls")
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 28 Sep 1999 00:14:39 +0000
From: James@linux.home (James Stevenson)
Subject: Re: running other programs from perl
Message-Id: <slrn7v023f.nkm.James@linux.home>
Hi
ahh sorry i did not see the &
but how do i know when the program exits?
thanks
James
On Mon, 27 Sep 1999 20:45:07 GMT, Kragen Sitaker <kragen@dnaco.net> wrote:
>In article <slrn7uvabp.td2.James@linux.home>,
>James Stevenson <mistral@stevenson.zetnet.co.uk> wrote:
>>i kind of want to run more than 1 program at once
>>i need to run about 6 or more
>
>I explained how to do this in the post to which you are replying. I
>have again included the solution below.
>
>>On Mon, 27 Sep 1999 14:25:02 GMT, Kragen Sitaker <kragen@dnaco.net> wrote:
>>>The simplest way to do this is like this:
>>>system("program1 &");
>>>system("program2 &");
>>>system("program3 &");
>--
><kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
>Mon Sep 27 1999
>42 days until the Internet stock bubble bursts on Monday, 1999-11-08.
><URL:http://www.pobox.com/~kragen/bubble.html>
--
---------------------------------------------
Check Out: http://www.users.zetnet.co.uk/james/
E-Mail: mistral@stevenson.zetnet.co.uk
12:10am up 11 days, 6:54, 4 users, load average: 1.26, 1.39, 1.75
------------------------------
Date: Tue, 28 Sep 1999 15:26:05 GMT
From: "Majid Sharif" <majid.sharif@mci.com>
Subject: Simple Mail Transfer Protocol ... Not So Simple!
Message-Id: <h65I3.1637$Lh.209598@pm02news>
Dear helper,
I writing a Multiscreen CGI Script (Form) that is to email some of the forms
input within that email.
The issue that I'm having is the email is not implementing the form fields
that I'm referencing.
For example, If the user inputs "TTI National" in the Account Name Field of
the form, the body of the email sent should read,
"The following product items for the TTI National Account have been
Approved. However, the email reads,
"The following product items for the Account have been Approved. I'm
guessing that the issue has something to do with the return statement (which
I do not understand). I have provided my code below.
Can someone Please help!
Thanks
# Approval/Disapproval Email Sent Page.
sub email_confirmation
{
my $active = shift;
return unless $active;
my $SMTPHost = "send.mcit.com";
my $ClientDevContact = "mailto:majid.sharif\@wcom.com;
my $UserEmailAddress = $Cgi->param('EmailAddress');
my $EmailSubject = $Cgi->param('AcctName'). " Account Product Approval";
my $EmailTitle = "The following product items for the " .
$Cgi->param('AcctName'). " Account have been Approved:\n\n";
my $smtp = Net::SMTP->new($SMTPHost) or return "Host not available";
$smtp->mail($ENV{USER});
$smtp->to($ClientDevContact, $UserEmailAddress);
$smtp->data();
$smtp->datasend("From:edms_webmaster\@lists.mci.com\n");
$smtp->datasend("To: $UserEmailAddress\n");
$smtp->datasend("Subject: $EmailSubject\n");
$smtp->datasend("\n");
$smtp->datasend("$EmailTitle\n");
$smtp->dataend();
$smtp->quit;
}
------------------------------
Date: 28 Sep 1999 16:53:30 GMT
From: gbacon@ruby.itsc.uah.edu (Greg Bacon)
Subject: Re: Slice in scalar context
Message-Id: <7sqrqa$lfb$1@info2.uah.edu>
In article <x7g0zzzris.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> writes:
: >>>>> "GB" == Greg Bacon <gbacon@ruby.itsc.uah.edu> writes:
:
: GB> Can you prove that? Keep in mind that so called constant lists do
: GB> change over the lifetime of a program.
:
: what does that mean? it is a constant list (1, 2, 3). so how can it
: change in the lifetime of the program?
Ummm... it's actually rather easy to do.
: GB> What about side effects?
:
: who mentioned side effects. we are talking about constant lists. keep
: the discussion on topic.
Even if we ignore side effects, there are times when the literal list
and, hence, the number of items in the literal list might change.
This makes what you call "a waste of code" useful.
: a constant list is just that. no side effects,
: no changing during the lifetime of the program.
Wanna bet? Put your money where your mouth is. Let's make a
gentleman's wager.
: GB> How will you stop a programmer from changing the code?
:
: what does that have to do with a constant list? my point is they can
: change it all they want but just counting it (with no side effects) is a
: waste as the list is not being used for anything else.
That doesn't necessarily make it a waste.
: keept this
: focused to just that one point. why count a constant list?
There may exist some circumstance in which we're only interested in
the number of items.
: GB> Say we're programming in C and have
:
: this is perl. who cares how c does it.
Quit being obtuse.
: GB> int array[] = { 1, 2, 4, 8, 16, 32, 64, };
:
: GB> int powers = sizeof(array) / sizeof(array[0]);
: GB> int powers = 7;
:
: but you are assigning that array/list. in the perl example no assignment or
: side effects are being done. so you comparison is null and void.
You're being obtuse again. C's arrays are of fixed size. Perl's
lists are of fixed size. It's possible to write code in both languages
such that one has to change one or two lines of code. Which is more
desirable?
: GB> Side effects?
:
: not allowed in constant lists. how often do i have to say this? if there
: is a side effect, it is not a constant list.
Am I to understand then that you're calling an entire syntax family
useless on the basis that you consider a subset of its applications to
be useless? That sort of attitude is what people sometimes call small
minded.
: GB> What if I want to count? What if the list of indices is itself
: GB>variable?
:
: then you have to either assign it to keep the indices for use later, or
: copy the code (bug prone) to recalculate the indices.
This is Perl. Who are you to dictate style to me?
: so again, counting
: a list of indices is useless.
You misspelled `nonorthogonal'. Orthogonality is considered mostly
irrelevant when it comes to arguing about Perl.
Greg
--
A wise man speaks because he has something to say, a fool because he has to
say something.
-- Plato
------------------------------
Date: Tue, 28 Sep 1999 12:56:03 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Sorting weird numeric data
Message-Id: <x3yd7v3ug9o.fsf@tigre.matrox.com>
Mike Sosteric <mikes@athabascau.ca> writes:
> How can I sort strings like this
>
> 1.1
> 1.1.1
> 1.1.2
> 1.2
> 1.3
>
> so that I get
>
> 1.1
> 1.1.1
> 1.1.2
> 1.2
> 1.3
>
> and not
>
> 1.1
> 1.1.1
> 1.1.2
> 1.2
> 1.3
Hmmm... don't sort!
--Ala
------------------------------
Date: Tue, 28 Sep 1999 10:47:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting weird numeric data
Message-Id: <MPG.125a9eefc1d6592c989feb@nntp.hpl.hp.com>
In article <btanx082.fsf@edlo1.ab.wave.home.com> on Tue, 28 Sep 1999
01:55:49 GMT, Mike Sosteric <mikes@athabascau.ca> says...
> How can I sort strings like this
>
> 1.1
> 1.1.1
> 1.1.2
> 1.2
> 1.3
There are many ways, some of which requiring making reasonable
assumptions about the ranges of the data. For example, here is a packed
sort that assumes the integers fit in one byte. I'll keep posting these
packed-sort examples until other people start to. :-)
#!/usr/local/bin/perl -w
use strict;
print map substr($_, 1 + rindex $_, "\0") =>
sort
map pack('C*' => split /\./) . "\0$_" =>
<DATA>;
__END__
10.0
1.1
1.1.1
1.1.2
1.2
1.3
WAGER: No one can write a more efficient solution.
EXERCISES:
Modify the above to work with arbitrary 32-bit unsigned integers.
Modify the above to work with unbounded unsigned integers.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 28 Sep 1999 10:48:43 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Stored encrypted messages in database
Message-Id: <Pine.GSO.4.10.9909281048100.17231-100000@user2.teleport.com>
On Sun, 26 Sep 1999, KaYue Mak wrote:
> I just wonder if there a best way to encrypted the messages that will
> be stored in db?
Define "best". What's best for me may not be best for you, and there's no
point in any of us wasting our time until you can say just what you want.
You may need to choose among fastest, most memory efficient, easiest to
program, fewest lines of code, most robust, most portable, easiest to
debug, easiest to maintain, most like your other favorite programming
languages, or perhaps you mean some other criterion. (Of course, one
solution may fall into more than one of these categories.)
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 28 Sep 1999 12:23:53 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Suggestion - comp.lang.perl.flame (was Re: You should be admired)
Message-Id: <slrn7v1uro.9kl.abigail@alexandra.delanet.com>
Matthew O. Persico (mpersico@erols.com) wrote on MMCCXIX September
MCMXCIII in <URL:news:37F0112F.3957ACB1@erols.com>:
;;
;; comp.lang.perl.cgi
;;
;; Wouldn't that draw off a good portion of the noise?
No. There's already a CGI group, and people don't post there. What makes
you think that another CGI group would solve the problem?
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 28 Sep 1999 15:19:59 GMT
From: "Par Svensson" <par@removethis.bahnhof.se>
Subject: Re: Trouble with matching. Help appreciated.
Message-Id: <z05I3.2035$tQ4.6377@dummy.bahnhof.se>
I just thought I'd clarify my rantings a bit.
The infile looks like
<a>
data
</a>
<b>
data
</b>
<a>
data
</a>
<b>
data
</b>
<c>
data
</c>
I want to process all the data between <a> and </a> in all instances first,
then the
data between <b> and </b>.
Thanks,
/Par
par@removethis.bahnhof.se
------------------------------
Date: Tue, 28 Sep 1999 12:21:57 -0400
From: "George Plumfield" <GPlumfield@worldnet.att.net>
Subject: UNIX (Solaris 2.6) to NT ACCESS DB?
Message-Id: <7sqpvo$puh$1@bgtnsc02.worldnet.att.net>
I'll be Perl-processing some files on a UNIX-Solaris 2.6 machine and would
like to directly update an Access DB (.mdb) residing on a NT machine
(intranet and NFS Maestro access to the NT filesystem).
Is this possible? If so, hi-level how?
The alternative is to copy the files over to NT and then run through DBI,
DBD::ADO, but I would love to do it directly from UNIX.
Thanks for any help!
George Plumfield
------------------------------
Date: Tue, 28 Sep 1999 17:21:15 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: UNIX (Solaris 2.6) to NT ACCESS DB?
Message-Id: <fO6I3.249$hs.15796@monger.newsread.com>
George Plumfield (GPlumfield@worldnet.att.net) wrote:
> I'll be Perl-processing some files on a UNIX-Solaris 2.6 machine and would
> like to directly update an Access DB (.mdb) residing on a NT machine
> (intranet and NFS Maestro access to the NT filesystem).
> Is this possible? If so, hi-level how?
The only way you could do this is to have a TCP/IP server running
on the NT box, which did it for you, and pass parameters to it.
Access itself is not a networkable database.
Scott
------------------------------
Date: Tue, 28 Sep 1999 17:19:34 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Using LWP and looking exactly like a web browser
Message-Id: <GM6I3.415$Gn.77861@news.itd.umich.edu>
In article <37f0ef52.43670304@news.supernews.com>,
David Stack <musicstack@hotmail.com> wrote:
>I am having a problem with a simple LWP script and pulling down a
>page. When I pull down the page with a regular web browser, the
>page comes down fine, with email address. But when I pull down the
>page with LWP, certain key parts of the pages are missing (mainly
>address and email information). It is almost as if there is some
>anti-LWP technology at play here.
Almost as if they don't want anyone viewing their site without also seeing
the pretty advertisements...Screw 'em, I say.
>I am wondering how can I make a LWP call look exactly like a browser
>call. I have tried the below, but I think it is leaving out certain
>header information that a browser puts out there. Does anyone know
>what other header information is needed to make it looks exactly like
>a real browser call? My next question is how do you implement it.
Well, you can find out what your own HTTP request looks like this way:
$req = new HTTP::Request(GET => 'http://www.foo.org');
print $req->as_string;
...and then, you can find out what your browser's request looks like by
setting up a listener like so:
----------------------------------------------------------------------
use IO::Socket;
$server = new IO::Socket::INET(LocalPort => 9999, Listen => 1);
$socket = $server->accept;
print while <$socket>;
----------------------------------------------------------------------
Now point your browser at port 9999 on the local machine, and see what your
browser's request looks like. Compare it to the LWP request.
I've never found that I ever needed to adjust anything other than the
User-Agent field to get a recalcitrant site to accept my automated
requests. Could the other site be expecting a cookie that the browser
sends but LWP doesn't? If you're using Netscape, you can get LWP to parse
Netscape's cookie file and send the same cookies Netscape would:
use HTTP::Cookies;
$jar = new HTTP::Cookies::Netscape(File => "$ENV{HOME}/.netscape/cookies");
$agent->cookie_jar($jar);
--
Sean McAfee | GS d->-- s+++: a27 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Tue, 28 Sep 1999 10:32:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: using System function to run other programs
Message-Id: <MPG.125a9b7874d041af989fea@nntp.hpl.hp.com>
In article <FIqy5q.4nG@news.boeing.com> on Tue, 28 Sep 1999 01:44:14
GMT, Charles DeRykus <ced@bcstec.ca.boeing.com> says...
> In article <MPG.12558da51e86923989fd7@nntp.hpl.hp.com>,
> Larry Rosler <lr@hpl.hp.com> wrote:
...
> > print "$n marble", $n != 1 && 's', "\n";
> >
> >instead of this Golf loser:
> >
> > print "$n marble", $n != 1 ? 's' : "", "\n";
...
> So, the null string reminds you of a "Golf" whiff :)
> Gratuitous negation should be a much, much greater peeve.
>
> Positives such as
>
> $n > 1 && 's' ,or, even
> $n == 1 ? "" : 's"
>
> read far, far better IMO.
But aren't the same.
"Yes, we have no bananas."
I meant exactly what I wrote:
$n != 1 && 's'
As for the difference between
$n != 1 ? 's' : ""
and
$n == 1 ? "": 's'
I chose to write the former to contrast it directly with the '&&' idiom,
which can't be written any other way. I don't think your criticism of
it is worth the bandwidth on this (or any) newsgroup.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 28 Sep 1999 17:16:47 GMT
From: jdkronicz@my-deja.com
Subject: why use references - in laymans terms?
Message-Id: <7sqt5h$ff6$1@nnrp1.deja.com>
Could someone explain to me the purpose for references? I've read that they
allow complex datastructures, nesting etc. I realize that this is a
fundamental question and very basic for most reading this newsgroup but I
would really like to hear the laymans explanation of why they are necessary?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 28 Sep 1999 17:49:16 GMT
From: "Colin R. DeVilbiss" <crdevilb@mtu.edu>
Subject: Re: why use references - in laymans terms?
Message-Id: <7sqv2s$s38$1@campus3.mtu.edu>
jdkronicz@my-deja.com wrote:
> Could someone explain to me the purpose for references? I've read that they
> allow complex datastructures, nesting etc. I realize that this is a
> fundamental question and very basic for most reading this newsgroup but I
> would really like to hear the laymans explanation of why they are necessary?
there are several important uses of references, probably the most important
of which is what you already mentioned; perl data structures (arrays and
hashes) can only hold scalars, which limits the ``depth'' of a data structure
to one level without references.
also, references are the preferred way to pass more than one data
structure into or out of a subroutine. for example, trying to pass
2 hashes as such into a subroutine:
foo(%bar, %baz);
is flattened to something like:
foo((all of the keys and values in both hashes))
without references.
references are also key to the working of object-oriented programming--
see the documentation for examples (perltoot is a good starting place).
HTH.
Colin DeVilbiss
crdevilb@mtu.edu
------------------------------
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 931
*************************************