[17128] in Perl-Users-Digest
Perl-Users Digest, Issue: 4540 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 6 14:10:39 2000
Date: Fri, 6 Oct 2000 11:10:18 -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: <970855818-v9-i4540@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 6 Oct 2000 Volume: 9 Number: 4540
Today's topics:
Re: lexical for loops <anmcguire@ce.mediaone.net>
mod_perl and ActiveState perl (v5.6.0 618) (oliver@ig.co.uk)
Re: Netscape supports Perl ? <camerond@mail.uca.edu>
Re: Newbie with HTTP LWP problem <f33r@the-reaper.co.uk>
Re: Not Entirely On Topic: Programming and math <gellyfish@gellyfish.com>
Re: Not Entirely On Topic: Programming and math <tim@ipac.caltech.edu>
Re: Not Entirely On Topic: Programming and math (Logan Shaw)
passing parameter to subroutine <kris.gonzalez@usa.alcatel.com>
Re: passing parameter to subroutine <kris.gonzalez@usa.alcatel.com>
Re: passing parameter to subroutine (Chris Fedde)
Perl & SQL programmers for immediate work <jeffgarnett@hotmail.com>
Perl and Outlook vivi16@my-deja.com
Re: Reading textfiles from client? <kpn_bw@hetnet.nl>
Re: Reading textfiles from client? (Keith Calvert Ivey)
Re: Reading textfiles from client? nobull@mail.com
Re: Reverse by paragraphs - NOT! ollie_spencer@my-deja.com
Re: Reverse by paragraphs - NOT! (Randal L. Schwartz)
Re: Reverse by paragraphs - NOT! <godzilla@stomp.stomp.tokyo>
Re: Reverse by paragraphs - NOT! (Randal L. Schwartz)
Re: Rookie Perl Programmer has a question! <camerond@mail.uca.edu>
Re: Rookie Perl Programmer has a question! nobull@mail.com
Rounding Integers vivi16@my-deja.com
Re: Serial-Timeout on Solaris <schuette@compoint.de>
Re: Splitting data (Bernard El-Hagin)
Re: Splitting data <anmcguire@ce.mediaone.net>
Unexpected behavior in 5.005_03 mrcribbins@my-deja.com
Re: using awk with perl rbishop@hursley.ibm.com
Re: Variable names enclosed within curly braces evanharrington@my-deja.com
Re: Very simple question. <anmcguire@ce.mediaone.net>
Re: Were to get a sendmail for a Win98 SE ? thodgson@my-deja.com
Re: Writing to Excel 2000 <Ribordy_Shawn_C@cat.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 6 Oct 2000 10:56:59 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: lexical for loops
Message-Id: <Pine.LNX.4.21.0010061055120.12117-100000@hawk.ce.mediaone.net>
On 6 Oct 2000, Bernard El-Hagin quoth:
BE> On Fri, 06 Oct 2000 08:07:14 +0200, P.Eftevik <haf@autra.noXX> wrote:
BE> >Is this allowed/recommended ? :
BE> >
BE> >for ( $char = 'A' ; $char lt 'G' ; $char++ ) {}
BE> >
BE> >Since my system uses characters instead of digits, something like
BE> >that would have been very convenient.
BE> >All comments appreciated.
BE>
BE> I have a comment - "For Christ's sake, why don't you just try it!?"
That only answers the first half of his question. The answer to the second
half is no.
foreach my $char ( 'A' .. 'F' ) { }
anm
--
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'
------------------------------
Date: Fri, 06 Oct 2000 18:02:46 GMT
From: oliver@ig.co.uk (oliver@ig.co.uk)
Subject: mod_perl and ActiveState perl (v5.6.0 618)
Message-Id: <8FC5C8ECFkjdsuisde8348@158.152.254.67>
I'm trying to get mod_perl to run with Apache (v1.3.12) and ActiveState
Perl (v5.6.0 618) under NT
I can compile mod_perl successfully by changing the library files to refer
to the ActiveState Perl libraries, but when I attempt to use the resulting
DLL, I simply get application errors...
I read an article by Sarathy (gsar@ActiveState.com) on this mailing list
(25th Aug) that suggested a few changes that could be made to the mod_perl
source to get it to work with ActiveState Perl. These changes allowed me to
get a working build of mod_perl, but unfortunatly it still raises an
application error when Apache is shutdown
The "official" Win32 ppm build of mod_perl for Win32 (made by Randy Kobes)
also suffer from the same problem when Apache is shutdown...
Can anyone help me with this?
------------------------------
Date: Fri, 06 Oct 2000 09:13:24 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Netscape supports Perl ?
Message-Id: <39DDDE04.844D60B8@mail.uca.edu>
Pratibha Sundarmurthy wrote:
>
> Hello,
> I am using ActiveState's Activeperl to develop ASP pages.
> The pages don't work on netscape...does anyone know if anything has to be
> installed/copied to work with netscape ?
> any info is appreciated.
Netscape servers support ActivePerl (actually, Perl) just fine, I'm
using NetscapeFastTrack 3.0 on NT 4 without any problems (well, *I'm*
having problems, but they're not the server's fault ;) ). This server
software doesn't run ASP, though, so I don't do them. If you want to do
ASP pages, I would suggest you start using Apache, which has ASP modules
available, although _some_ say they use M$ IIS without too many
problems.
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Fri, 6 Oct 2000 18:23:16 +0100
From: "Paul Coles" <f33r@the-reaper.co.uk>
Subject: Re: Newbie with HTTP LWP problem
Message-Id: <8rl12s$g9g$1@neptunium.btinternet.com>
Thanks Bob but
The HTTP code that appears when this code is run ignores the parameters
being sent.
The HTML im trying to copy maked the asp page produce a large table of data.
I think it is something to do with the variable that is passed as the submit
button.
Bob Walton <bwalton@rochester.rr.com> wrote in message
news:39DD1AD0.4E3127E0@rochester.rr.com...
> Paul Coles wrote:
> ...
> > here's what i have tried, but it doesnt work :-(
> >
> > use LWP::Simple;
> > use HTTP::Request::Common qw(POST);
> > use LWP::UserAgent;
> > $ua = LWP::UserAgent->new();
> > my $req = POST 'http://www.telecom.paper.nl/os/inp.asp', [ country =>
840,
> > posted=>1, submit =>'Search'];
> > $content = $ua->request($req)->as_string;
> > print($content)
> >
> > Thanks for any help.
> Well, I'm not sure what you mean by "doesn't work". When I try your
> code verbatim, it prints out a whole bunch of HTML. Does that
> constitute "working"? If so, then it works for me.
> --
> Bob Walton
------------------------------
Date: 5 Oct 2000 22:38:04 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Not Entirely On Topic: Programming and math
Message-Id: <8risbs$k66$1@orpheus.gellyfish.com>
On Thu, 05 Oct 2000 13:21:41 -0400 Lou Moran wrote:
> --Is a strong background in mathematics (not arithmetics) mandatory
> for a successful career as a programmer?
>
> --Could a creative (musician/writer/painter/whatever) person become a
> "real" (read useful/good/paid) programmer without having mathematical
> prowess?
Yes, I have a degree in English Literature.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Fri, 06 Oct 2000 10:37:48 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Not Entirely On Topic: Programming and math
Message-Id: <39DE0DEC.43EE274A@ipac.caltech.edu>
Lou Moran wrote:
>
> --Is a strong background in mathematics (not arithmetics) mandatory
> for a successful career as a programmer?
>
> --Could a creative (musician/writer/painter/whatever) person become a
> "real" (read useful/good/paid) programmer without having mathematical
> prowess?
One of the ways to think about programming is it's the art of realizing a
thought through computer code. There are two parts: a) Having a clear enough
thought, and b) translating the thought to code. Step a) is the hardest part,
but only requires math on some problems. If you can define an idea clearly
enough in your head, code will follow with or without a math background for many
problems, especially in as expressive a language as Perl.
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: 6 Oct 2000 12:49:35 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Not Entirely On Topic: Programming and math
Message-Id: <8rl3bf$aj7$1@provolone.cs.utexas.edu>
In article <35eptscl81drjr8gn9teh5ol2a2p00gcql@4ax.com>,
Lou Moran <lmoran@wtsg.com> wrote:
>--Is a strong background in mathematics (not arithmetics) mandatory
>for a successful career as a programmer?
Well, you can probably have a successful career without it,
but having a good math background can help you understand
other things which can be helpful in programming.
For instance, how long does this code take?
for ($x = 100; $x < 200; $x++)
{ sleep $x; }
If you know some simple calculus, you can glance at that and realize
that a decent approximation to the answer is the definite integral of
x dx from x = 100 to x = 199, so about 1/2 * (199^2 - 100^2) or
about 14800 seconds. That might be off by a hundred or two, but
it's probably within 1%.
This is kind of a silly example, but there are more realistic examples
that could be given. The point is that it's nice to be able to do this
kind of analysis.
In computer science programs, they go further and even make students
prove mathematically that a certain piece of code will take no more
than a certain amount of time. In the real world, you essentially
never actually do that, and you probably don't ever even write down a
formula either, but it does shape your thinking.
Also, if one of the problems you had with math was that you weren't
comfortable moving symbols around according to rules, this can cause
you some confusion in the programming world too. For instance, in
algebra, you can change this:
y = x / 3
into this:
3 = x / y
In the C programming language, if you declare two variables like this:
char *c;
char d;
then you'll find "*c" has the same type as "d", which means that "c"
has the same type as "&d".
For me at least, these two processes use the same brain cells.
>--Could a creative (musician/writer/painter/whatever) person become a
>"real" (read useful/good/paid) programmer without having mathematical
>prowess?
Yes, I think that can definitely happen. The key is whether you're
capable of analytical thinking too. I really think you need both kinds
of thinking to be a good programmer.
>PS -- My brain stopped accepting math around quadratic equations
There are a number of reasons that could have happened. One of them
which is a very common reason is that the educational system dropped
the ball. There are just very few people out there who know how to
teach math. There are plenty of people who can *do* math, but
apparently having that skill doesn't mean you can express yourself.
Lots of math teachers (especially at higher levels, it seems) have this
fictional idea in their heads that because what they've written on the
board is mathematically valid, they've explained it as clearly as can
be explained.
Anyway, the point of all this is to raise the possibility that maybe
your brain could wrap itself around math and math-like things just fine
under the right conditions. If you are interested in programming, it
may be an indication that your brain might actually be into analytical
stuff, which would be good if you want to be good at most kinds of
programming.
- Logan, whose brain only accepted calculus on the fifth try
------------------------------
Date: Fri, 06 Oct 2000 11:41:59 -0500
From: Kris Gonzalez <kris.gonzalez@usa.alcatel.com>
Subject: passing parameter to subroutine
Message-Id: <39DE00D7.90540048@usa.alcatel.com>
Can anyone tell me why the following code will not print the value of
the parameter passed to the subroutine "make_page"?
-----------BEGIN-INSERTED-CODE-------------
&make_page(3);
exit(0);
sub make_page {
print <<EOF;
<html><head></head>
<body>
<input type=text value=$_>
</body
</html>
-------------END-INSERTED-CODE--------------
I've tried this as well as the following:
-----------BEGIN-INSERTED-CODE-------------
&make_page(3);
exit(0);
sub make_page {
$param = shift;
print <<EOF;
<html><head></head>
<body>
<input type=text value=$param>
</body>
</html>
-------------END-INSERTED-CODE--------------
Nothing seems to work (and the lack of quotations in the input tag are
not the issue, I've tried them too. Can anyone assist me?
Thanks in advance!
-kg
------------------------------
Date: Fri, 06 Oct 2000 11:43:23 -0500
From: Kris Gonzalez <kris.gonzalez@usa.alcatel.com>
Subject: Re: passing parameter to subroutine
Message-Id: <39DE012B.7A87AB7E@usa.alcatel.com>
Oh yeah, i forgot to include the remainder of the function, but it is
ended with EOF and a close bracket ( } ).
Thanks for your help.
------------------------------
Date: Fri, 06 Oct 2000 17:22:13 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: passing parameter to subroutine
Message-Id: <9TnD5.6$x8.171005952@news.frii.net>
In article <39DE00D7.90540048@usa.alcatel.com>,
Kris Gonzalez <kris.gonzalez@usa.alcatel.com> wrote:
>
>&make_page(3);
>exit(0);
>
>sub make_page {
>
>print <<EOF;
>
><html><head></head>
><body>
><input type=text value=$_>
^^
></body
></html>
>
EOF
}
You probably want to look at some more examples in the tutorial
that you are reading. Parameters to subroutines are passed in an
array called @_ so the first argument is $_[0]. One common idiom
for this is the following:
sub {
my $param = shift;
...
}
good luck
chris
--
This space intentionally left blank
------------------------------
Date: Fri, 6 Oct 2000 10:40:45 -0400
From: "Jeff Garnett" <jeffgarnett@hotmail.com>
Subject: Perl & SQL programmers for immediate work
Message-Id: <39dde4ac@news2.starnetinc.com>
Financed Internet/Software Venture needs Perl & SQL programmers for
immediate work. Contact Jeff Garnett at 914-273-0040 or fax resume to
914-273-0045 or e-mail jeffgarnett@hotmail.com. Compensation includes a
highly competitive salary, stock, benefits and bonuses.
------------------------------
Date: Fri, 06 Oct 2000 17:28:01 GMT
From: vivi16@my-deja.com
Subject: Perl and Outlook
Message-Id: <8rl22r$isr$1@nnrp1.deja.com>
In a Perl file I want to send the results of a form to the user via E-
mail. Is it possible to use MS Outlook as the mail program? And does
the program have to reside on the server where the Perl program is?
I recall reading in this discussion group (though can't find it now)
someone saying that this might be possible (using Outlook and not
having it reside on the local server).
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 6 Oct 2000 16:30:01 +0200
From: "Bas Welvering" <kpn_bw@hetnet.nl>
Subject: Re: Reading textfiles from client?
Message-Id: <OxBz8G6LAHA.333@net025s>
> If you dont want to upload anything, you are planning on doing
computations
> on the client side. Thus you probably dont want to use Perl for the
processing
No, I want Perl to read a textfile from the client, then process it, and
return the processed data.
> since Perl is not widely available on the client side. So, you might want
to
> consider to use some client side programming language like JavaScript or
Java.
I don't want to use JavaScript, since some visitors have turned it off, and
I won't be able to do what I want in JavaScript.
> Conclusion:
> Upload the file via http put and then process it with Perl.
So, actually, you are saying that Perl can't open a file stored on the
clients computer, store all lines of the file in an array, and then process
it?
Greetz,
Bas
------------------------------
Date: Fri, 06 Oct 2000 15:15:59 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Reading textfiles from client?
Message-Id: <39ddeb0b.58982193@news.newsguy.com>
"Bas Welvering" <kpn_bw@hetnet.nl> wrote:
>> If you dont want to upload anything, you are planning on doing
>computations
>> on the client side. Thus you probably dont want to use Perl for the
>processing
>
>No, I want Perl to read a textfile from the client, then process it, and
>return the processed data.
If you're not doing the computation on the client side and
you're not uploading the file to the server, how is Perl on the
server supposed to know what's in the file? I think you need to
think your problem through a little more.
>> Conclusion:
>> Upload the file via http put and then process it with Perl.
>
>So, actually, you are saying that Perl can't open a file stored on the
>clients computer, store all lines of the file in an array, and then process
>it?
By what mechanism do you expect Perl to open the file if it's
not on the same system? You would have to have special software
on the client side (something much less common than the Java
that you've already dismissed) to allow something like that.
Perl is magical, but it's not so magical that it can read files
on remote computers without making some sort of connection to
them.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: 06 Oct 2000 17:33:12 +0100
From: nobull@mail.com
Subject: Re: Reading textfiles from client?
Message-Id: <u9itr6c4l3.fsf@wcl-l.bham.ac.uk>
"Bas Welvering" <kpn_bw@hetnet.nl> writes:
> > Conclusion:
> > Upload the file via http put and then process it with Perl.
>
> So, actually, you are saying that Perl can't open a file stored on the
> clients computer,
No, actually, he's saying a program running on a HTTP server can't
open a file stored on the client[1]. It doesn't matter what language the
program is written in. He then offers you two ways arround this:
1) Client-side programs
2) Upload forms.
[1] Just think for a minute - would you really *want* programs on
websites to be able to read your disks?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 06 Oct 2000 16:17:14 GMT
From: ollie_spencer@my-deja.com
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <8rktu2$fhq$1@nnrp1.deja.com>
Hi-
I don't know what a jeopardy post is. I am stopping all posts, but
perhaps you could let me in on that piece of jargon-
Thanks.
ollie spencer
In article <MPG.1447fba6ffde30d5989805@localhost>,
jason <elephant@squirrelgroup.com> wrote:
> ollie_spencer@my-deja.com wrote ..
> >In article <8ri75d$dcv$1@lublin.zrz.tu-berlin.de>,
==Snipped==
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 06 Oct 2000 09:42:25 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <m1hf6pdiq6.fsf@halfdome.holdit.com>
>>>>> "ollie" == ollie spencer <ollie_spencer@my-deja.com> writes:
ollie> Hi-
ollie> I don't know what a jeopardy post is. I am stopping all posts, but
ollie> perhaps you could let me in on that piece of jargon-
ollie> Thanks.
ollie> ollie spencer
ollie> In article <MPG.1447fba6ffde30d5989805@localhost>,
ollie> jason <elephant@squirrelgroup.com> wrote:
>> ollie_spencer@my-deja.com wrote ..
>> >In article <8ri75d$dcv$1@lublin.zrz.tu-berlin.de>,
ollie> ==Snipped==
Stop posting your answers before the original question. In
time-honored Usenet tradition, quoted material comes *ahead of* or
*interspersed* with the response. Take a look at 90% of the other
postings. The other 10%, we call "jeopardy posts" because they mimic
the old game show. These are frowned upon, because they cause an
unnatural reading flow. Yours are in this category, and make you seem
ignorant or disagreeable (we can't tell which).
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 06 Oct 2000 10:07:04 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <39DE06B8.869FE400@stomp.stomp.tokyo>
Randall L. Schwartz wrote:
> Ollie continues to make fools of the foolish and himself:
> > I don't know what a jeopardy post is.
> > I am stopping all posts,
> > but perhaps you could let me in on that piece of jargon-
> ...The other 10%, we call "jeopardy posts" because they mimic
> the old game show. These are frowned upon, because they cause an
> unnatural reading flow. Yours are in this category, and make you seem
> ignorant or disagreeable (we can't tell which).
Would you like me to whip out my Duncan yo-yo and
give Ollie another good smack on his forehead?
As a scrawny barefoot but not totally ignorant farm child,
I learned there are times you need to smack an ignorant
disagreeable mule between his eyes with an axe handle,
to attain his undivided attention. Then you can go to work.
Godzilla!
--
Gypsy Wildrose Pawnee, Fortune Teller
http://la.znet.com/~callgirl/android/fortune.cgi
------------------------------
Date: 06 Oct 2000 10:18:35 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <m1vgv5c2hg.fsf@halfdome.holdit.com>
>>>>> "Godzilla!" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
Godzilla!> Randall L. Schwartz wrote:
That's not me (check your spelling).
>> Ollie continues to make fools of the foolish and himself:
That's not something I said. Be careful how you quote the quoting. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 06 Oct 2000 09:26:01 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Rookie Perl Programmer has a question!
Message-Id: <39DDE0F9.3F23048C@mail.uca.edu>
Bob Deemer wrote:
>
> I am trying to write a Perl Script that will query a webpage and email
> the result to me. I can to the email part KO, but I am not sure how to
> get the program to go out and query a given URL and put the result in a
> variable.
>
> I need to store the result in a variable first to run it through a
> "filter" to manipulate the information received from the URL.
>
> For example, if I execute this script, it would go out and grab a stock
> quote from a given URL, manipulate what it receives, and then email the
> result to a given email address.
>
> AS stated, I can do the email and manipulation KO, I just need to know
> how to get the script to query a given URL.
Use LWP::Simple (part of the libwww package), it's pretty
straightforward.
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: 06 Oct 2000 17:36:14 +0100
From: nobull@mail.com
Subject: Re: Rookie Perl Programmer has a question!
Message-Id: <u9hf6qc4g1.fsf@wcl-l.bham.ac.uk>
Bob Deemer <moondoggle1@yahoo.com> writes:
> Subject: Rookie Perl Programmer has a question!
Please use your subject line to describe your question.
You see, not everyone is too selfish/arrogant/lazy to look to see if
the question they are about to ask has already been asked... and
answered... several times... per week... for the last few years.
People who are not this selfish/arrogant/lazy will find that they are
impedead by selfish/arrogant/lazy misuse of subject lines.
BTW: If you think I'm being rude then please remeber - you started it.
> ... I am not sure how to
> get the program to go out and query a given URL and put the result in a
> variable.
LWP
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 06 Oct 2000 17:24:15 GMT
From: vivi16@my-deja.com
Subject: Rounding Integers
Message-Id: <8rl1rq$ipt$1@nnrp1.deja.com>
Can you use sprintf(); to round integers? I want to round something
like 4568 to 4600. I suppose if I knew a number was always going to be
in the thousands, I could divide by 100, use the CEIL function and then
multiply by 100. But is there an easier way or built in command?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 06 Oct 2000 19:00:12 +0200
From: Lothar Schuette <schuette@compoint.de>
To: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Serial-Timeout on Solaris
Message-Id: <39DE051C.673CC8F5@compoint.de>
Hello,
Elaine Ashton wrote:
> =
> in article 39DAFB4B.DE89AD3E@compoint.de, Lothar Schuette at
> schuette@compoint.de quoth:
> > on a Sun E250 with 512 MB and one CPU running Solaris 8 and Perl 5.00=
5_3
> > I run into the following problem:
> >
> > The application communicats with an external box over a serial line.
> > This box uses 19200 8N1. And there is no flow control at all.
> >
> > This problem doesn't occure if 29, 30 oder more than 35 Bytes are sen=
d.
> >
> > Running on Linux the application works ok.
> > Changing the serial devices (term/a, term/b, cua/a, cua/b) or using P=
erl
> > 5.005_02 doesn't solve the problem.
> =
> I've never seen this problem on a sparc but one thing you might do is
> double-check all of the stty parameters. Solaris isn't even in the ball=
park
> of Linux so that it runs fine on it but not Solaris makes me think ther=
e is
> something in the stty settings that is causing your problem.
do you think the port setting might have changed while using it?
After opening the device there is send a start message to the box and
the box respones with an ok message. These have a length of 20 bytes.
After that the sun sends a request of < 127 bytes. The response to that
blocks the device.
So the serial setting is ok (I think).
Is it possible that a special sequence of bytes sent to the sun makes
the port hang? Does the OS or maybe HW interpret the data?
-- =
Best regards
Lothar Sch=FCtte schuette@COMPOINT.de
----------------------------------------------------------------------
Intra- u. Internet Services von http://www.COMPOINT.de
COMPOINT network consulting gmbh phone +49 561 98223-0
Triftstra=DFe 103, D-34246 Vellmar fax +49 561 98223-302
----------------------------------------------------------------------
------------------------------
Date: 6 Oct 2000 13:24:09 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Splitting data
Message-Id: <slrn8trkjs.f8v.bernard.el-hagin@gdndev25.lido-tech>
On Fri, 06 Oct 2000 14:49:35 +0200, Marco Natoni <foo@bar.va> wrote:
>Bernard,
>
>Bernard El-Hagin wrote:
>>> I have a list of delimited data like this:
>>> BILL|$10000|555-5555|4|HOUSE|NEW YORK
>>> CHRIS|$4000|666-6666|7|APT|BOSTON
>>> LIU|$120000|777-7777|12|MANSION|SHANGHAI|CHINA
>>> etx.
>>> I want to search through the list for people in New York. If
>>> they are found - print the value the phone number and rent. How do
>>> I just extract the phone number and rent. Right now - I do a
>>> split like this ($a,$b,$c,$d,$e,$f,$g)=split(/|/,$line). But what
>>> if I had 200 fields?
>> As I understand it the first four fields in each line are
>> always name|value|number|rent and the last is the city. Since
>> you're not interested in everything that's in between you can
>> try:
>> (split '|', $line)[-1] to get the city name,
>> (split '|', $line)[0] to get the first name,
>> (split '|', $line)[1] to get the value,
>> (split '|', $line)[2] to get the phone number, and, last but
>> not least,
>> (split '|', $line)[3] to get the rent.
>> This way you don't have to worry about how many fields are in
>> each line.
>
> Although the list-context usage of a Perl function could often result
>in a smart code style, I think that *five* calls to /split/ with the
>same parameter seems excessive, expecially regarding CPU's time
>consumption. Having decided to use numerical indexing for the fields,
>why do not use a named array?
>
><code>
> @data=split /\|/,$line;
> $city_name=$data[-1]; # and so on...
></code>
I totally agree. I was just trying to show the principle involved.
Admittedly it was silly of me to assume that my intentions would be
clear to someone who was asking for help thus I urge the OP to also take
Marco's advice.
Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'
------------------------------
Date: Fri, 6 Oct 2000 11:47:04 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Splitting data
Message-Id: <Pine.LNX.4.21.0010061134050.12131-100000@hawk.ce.mediaone.net>
On Fri, 6 Oct 2000, Marco Natoni quoth:
MN> Bernard,
MN>
MN> Bernard El-Hagin wrote:
MN> >> I have a list of delimited data like this:
MN> >> BILL|$10000|555-5555|4|HOUSE|NEW YORK
MN> >> CHRIS|$4000|666-6666|7|APT|BOSTON
MN> >> LIU|$120000|777-7777|12|MANSION|SHANGHAI|CHINA
MN> >> etx.
MN> >> I want to search through the list for people in New York. If
MN> >> they are found - print the value the phone number and rent. How do
MN> >> I just extract the phone number and rent. Right now - I do a
MN> >> split like this ($a,$b,$c,$d,$e,$f,$g)=split(/|/,$line). But what
MN> >> if I had 200 fields?
MN> > As I understand it the first four fields in each line are
MN> > always name|value|number|rent and the last is the city. Since
MN> > you're not interested in everything that's in between you can
MN> > try:
MN> > (split '|', $line)[-1] to get the city name,
This will not work, as China is not a city.
[ snip ]
MN> > This way you don't have to worry about how many fields are in
MN> > each line.
Nope, that way you do.
MN> Although the list-context usage of a Perl function could often result
MN> in a smart code style, I think that *five* calls to /split/ with the
MN> same parameter seems excessive, expecially regarding CPU's time
MN> consumption. Having decided to use numerical indexing for the fields,
MN> why do not use a named array?
MN>
MN> <code>
MN> @data=split /\|/,$line;
MN> $city_name=$data[-1]; # and so on...
MN> </code>
But then, why even use an array at all, if all you are going to be
doing is taking elements of that array, and assigning them to scalars?
I believe this meets the spec, but goes back to the OP's way (sort of):
#!/usr/bin/perl -w
use strict;
while ( <DATA> ) {
chomp;
my ( $rent, $phone, $city ) = ( split /\|/ )[1,2,5];
if ( $city eq 'NEW YORK' ) {
print "$phone -> $rent\n";
}
}
__DATA__
BILL|$10000|555-5555|4|HOUSE|NEW YORK
CHRIS|$4000|666-6666|7|APT|BOSTON
LIU|$120000|777-7777|12|MANSION|SHANGHAI|CHINA
anm
--
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'
------------------------------
Date: Fri, 06 Oct 2000 17:54:58 GMT
From: mrcribbins@my-deja.com
Subject: Unexpected behavior in 5.005_03
Message-Id: <8rl3li$jvd$1@nnrp1.deja.com>
Sorry if this is a re-post, I think our news server here at
work is broken...
---
Hello All,
I'm sure it comes back to something stupid I did, but I thought
I'd go ahead and post here and see what you think. I needed
to do a replacement of a string in about 100 files. I had a
list of filenames and line numbers where the string was found
in the file. I fed that to the following script:
#!/pkgs/local/bin/perl -w
use strict;
$^I = ".bak";
while (<>) { # filelist.txt passed as argument
/^(\[\.)([\/\.|A-Z|a-z|_|-|\s\d]+)(\s\-\sline\s)(\d+)(\].*)$/;
# Necessary due to the format of the file.
# $2 now contains the filename and $4 contains the line
# number where the string was found. (Yes, I checked.)
open(TBR, "/mweb/docs/IT/$2") or warn $!;
# Opened read-only unless $^I is defined, right?
while (<TBR>) {
select TBR;
if ($. == $4) {
s/it_corp_web\@/help_desk\@/;
print;
}
else {
print;
}
}
close (TBR) or warn $!;
}
#EOF
I ended up with a bunch of 0 length files, and no backup copies.
(Fortunately, I do have backup tapes...) Is this a bug, or am I
an idiot? Or both?
I'm running 5.005_03 on Solaris 2.6.
Thanks,
Michael
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 6 Oct 2000 13:15:29 GMT
From: rbishop@hursley.ibm.com
Subject: Re: using awk with perl
Message-Id: <8rkj9h$s5e$1@sp4en10.hursley.ibm.com>
> /usr/local/apache/cgi-bin/printenv | grep REMOTE_ADDR|awk -F= '{print $2}'
or even:
/usr/local/apache/cgi-bin/printenv | awk -F= '/REMOTE_ADDR/ {print $2}'
------------------------------
Date: Fri, 06 Oct 2000 16:06:24 GMT
From: evanharrington@my-deja.com
Subject: Re: Variable names enclosed within curly braces
Message-Id: <8rkt9p$f0p$1@nnrp1.deja.com>
In article <MPG.1446a4f16fc0c3b98ae12@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
> In article <8riubs$td3$1@nnrp1.deja.com> on Thu, 05 Oct 2000 22:12:17
> GMT, evanharrington@my-deja.com <evanharrington@my-deja.com> says...
>
> "A foolish consistency is the hobgoblin of little minds, adored by
> little statesman and philosophers and divines." -- Ralph Waldo Emerson
>
> This is truly a foolish consistency, though harmelss in this case.
As
> you note, it will cause Perl programmers to look at you askance.
Yes, so I have seen. All I thought I was doing was making it clear in
every case which variable was meant. After all, human coders are not
so good at seeing the few exceptions that cause all the problems. The
braces *seemed* to make it crystal-clear. I was bitten a few times by
variable name mistakes and thought that curlies were the way to avoid
the problem in the future. However, I do understand the point you and
others have made and I, myself, prefer not to resort to such clutter.
Your input is helpful.
Thank you.
Evan K. Harrington
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 6 Oct 2000 10:44:50 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Very simple question.
Message-Id: <Pine.LNX.4.21.0010061044220.12117-100000@hawk.ce.mediaone.net>
On Fri, 6 Oct 2000, H C quoth:
HC> > Can I call a perl script from another perl script?
HC>
HC> Yes.
HC>
HC> > Is so... how?
HC>
HC> The system() call...using backticks (`)...on Win32 systems, you
HC> can use the Win32::Process module...
or 'perldoc -f do'.
anm
--
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'
------------------------------
Date: Fri, 06 Oct 2000 14:41:59 GMT
From: thodgson@my-deja.com
Subject: Re: Were to get a sendmail for a Win98 SE ?
Message-Id: <8rkobk$afq$1@nnrp1.deja.com>
Try http://www.MailListBot.com - it's a sendmail alternative that comes
packaged as a command line exe or as a COM object. There is also a
free lite version available.
In article <8ps20v$di7sa$1@ID-48235.news.cis.dfn.de>,
"Agustin Chernitsky" <agustinchernitsky@altavista.com> wrote:
> Hi!
>
> I'am running a server on my Win98SE for development. I need a
sendmail
> program since my Internet Server uses sendmail to send it's mail. Can
> someone tell me were to get a sendmail for Win32?
>
> Thanks!
>
> --
> Agustín Chernitsky
> InterEmpresa
>
> E-mail: agustinchernitsky@altavista.com
> ICQ: 20020826
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 06 Oct 2000 08:05:44 -0500
From: Shawn Ribordy <Ribordy_Shawn_C@cat.com>
Subject: Re: Writing to Excel 2000
Message-Id: <39DDCE28.2FA48E4C@cat.com>
--------------528EB84304B0C005225282CF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
hajir@my-deja.com wrote:
> I am trying to write into an Excel 2000 cell using this, but I get an
> error: Can't Call Method Workbooks . I also get a can't call method
> Range for another one. Please help
>
> use OLE;
> $excel = CreateObject OLE 'Excel.Application.5'
> or warn "Couldn't create new instance of Excel App!!";
> $excel->Workbooks->Open( 'test.xls' );
> $excel->Workbooks(1)->Worksheets('Sheet1')->Cells(1,2)->{Value}
> = 'foo';
> $excel->Workbooks(1)->Worksheets('Sheet1')->Cells(1,2)->{Value}
> = 'bar';
> $excel->Save();
> $excel->Quit();
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Try this code instead!
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit'); # get already active
Excel
# application or open
new
$Excel->Workbooks->Open( "P:\\My Documents\\pscripts\\amet.xls" );
$Excel->ActiveWorkbook->Worksheets('Sheet1')->Cells(1,2)->{Value} = 'foo';
$Excel->ActiveWorkbook->Worksheets('Sheet1')->Cells(2,2)->{Value} = 'bar';
$Excel->ActiveWorkbook->Save();
$Excel->ActiveWorkbook->Close();
$Excel->Quit();
--------------528EB84304B0C005225282CF
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<p>hajir@my-deja.com wrote:
<blockquote TYPE=CITE>I am trying to write into an Excel 2000 cell using
this, but I get an
<br>error: Can't Call Method Workbooks . I also get a can't
call method
<br>Range for another one. Please help
<p> use OLE;
<br> $excel = CreateObject OLE
'Excel.Application.5'
<br>
or warn "Couldn't create new instance of Excel App!!";
<br> $excel->Workbooks->Open(
'test.xls' );
<br> $excel->Workbooks(1)->Worksheets('Sheet1')->Cells(1,2)->{Value}
<br>= 'foo';
<br> $excel->Workbooks(1)->Worksheets('Sheet1')->Cells(1,2)->{Value}
<br>= 'bar';
<br> $excel->Save();
<br> $excel->Quit();
<p>Sent via Deja.com <a href="http://www.deja.com/">http://www.deja.com/</a>
<br>Before you buy.</blockquote>
<p><br><tt>Try this code instead!</tt><tt></tt>
<p><tt>use strict;</tt>
<br><tt>use Win32::OLE qw(in with);</tt>
<br><tt>use Win32::OLE::Const 'Microsoft Excel';</tt>
<br><tt>$Win32::OLE::Warn = 3;
# die on errors...</tt>
<br><tt>my $Excel = Win32::OLE->GetActiveObject('Excel.Application')</tt>
<br><tt> || Win32::OLE->new('Excel.Application', 'Quit'); #
get already active Excel</tt>
<br><tt>
# application or open new</tt>
<br><tt>$Excel->Workbooks->Open( "P:\\My Documents\\pscripts\\amet.xls"
);</tt>
<br><tt>$Excel->ActiveWorkbook->Worksheets('Sheet1')->Cells(1,2)->{Value}
= 'foo';</tt>
<br><tt>$Excel->ActiveWorkbook->Worksheets('Sheet1')->Cells(2,2)->{Value}
= 'bar';</tt>
<br><tt>$Excel->ActiveWorkbook->Save();</tt>
<br><tt>$Excel->ActiveWorkbook->Close();</tt>
<br><tt>$Excel->Quit();</tt>
<br> </html>
--------------528EB84304B0C005225282CF--
------------------------------
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 4540
**************************************