[15765] in Perl-Users-Digest
Perl-Users Digest, Issue: 3178 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 26 18:10:36 2000
Date: Fri, 26 May 2000 15:10:23 -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: <959379023-v9-i3178@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 26 May 2000 Volume: 9 Number: 3178
Today's topics:
Re: join " ", do {$x++}, do {$x++}, do {$x++}; <lr@hpl.hp.com>
Re: libudbc and DBD-ODBC on solaris <dwilgaREMOVE@mtholyoke.edu>
Re: Looking for a good editor... scottlong@my-deja.com
LWP::SecureSocket and https irenaro@my-deja.com
Re: LWP::SecureSocket and https (SBoyV)
Re: my $x vs. my ($x) <lr@hpl.hp.com>
Re: my $x vs. my ($x) <sergei_kucherovNOseSPAM@3com.com.invalid>
Re: my $x vs. my ($x) <sergei_kucherovNOseSPAM@3com.com.invalid>
Re: my $x vs. my ($x) <sergei_kucherov@3com.com>
Re: Netscape w/ Perl (Abigail)
Re: Netscape w/ Perl <brburton@cintek.com>
Re: Newbie - need to rip images from URL (Bart Lateur)
Re: Newbie: DIV <lr@hpl.hp.com>
Re: Perl Editor for Linux scottlong@my-deja.com
Re: Perl unusable as a programming language <lr@hpl.hp.com>
perl5.6 bug -- no stringification of object reference <sergei_kucherovNOseSPAM@3com.com.invalid>
Re: perl5.6 bug -- no stringification of object referen <sergei_kucherov@3com.com>
Re: PerLotto 0.1a1. My first "real" Perl script!!! <y-o-y@home.com>
problems in PPM and installation modules yudelin@my-deja.com
Re: Problems installing DBI-1.13 <phil@BuxTech.Com>
Re: randomizing (anagramming words) (Craig Berry)
reading from binmode() as "unsigned chars" <bwhitman@cs.columbia.edu>
Re: reading from binmode() as "unsigned chars" <bwhitman@cs.columbia.edu>
Re: reading from binmode() as "unsigned chars" (Sean McAfee)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 26 May 2000 11:00:15 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <MPG.13985b89ac2a56dd98aae5@nntp.hpl.hp.com>
In article <8gm82o$fi3$1@pegasus.csx.cam.ac.uk> on 26 May 2000 16:17:28
GMT, M.J.T. Guy <mjtg@cus.cam.ac.uk> says...
> Bart Lateur <bart.lateur@skynet.be> wrote:
> >Hmmm... that isn't very explicit, isn't it? In scalar context, it is
> >garanteed to be executed from left to right, but in list context, it's
> >not said in so many words.
> >
> >Just a gap in the docs?
>
> No gap in the docs. In general, the order of evaluation of expressions
> is undefined, as in C. ',' in a scalar context is one of the few
> exceptions.
<pedantry mode="pure">
s/undefined/unspecified/;
</pedantry>
But it that really so? Is there really not a defined semantics for,
say:
my $p;
my @a = ( $p = 1, $p );
That is ',' in a list context. Can we not say for certain that the
value of $a[1] after the execution of that statement is 1, not undef?
And if we *can* say that for certain, shouldn't it be documented
explicitly? And if we *can't* say that for certain, shouldn't it be
documented explicitly?
Note the distinction here between a list whose values are copied into an
array and a subroutine argument list, whose lvalue arguments are passed
by reference.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 26 May 2000 21:11:20 GMT
From: Dan Wilga <dwilgaREMOVE@mtholyoke.edu>
Subject: Re: libudbc and DBD-ODBC on solaris
Message-Id: <dwilgaREMOVE-EE867F.17112226052000@news.mtholyoke.edu>
In article <8gghmf$1oe$1@info.service.rug.nl>, Koos Schut
<schut@rugth1.phys.rug.nl> wrote:
> Hi all,
>
> I am trying to get Perl-Informix functionality
> on a Solaris-5.5.1 machine. I have:
> perl-5.005_03
> DBD-ODBC-0.28
> gcc-2.95.2
> Informix SE-7.?
>
> I can configure the ODBC-package. With make I get:
> ....
> cannot find libudbc.h
That sounds like something is depending on the specific udbc driver written by
OpenLink: http://openlinksw.com
If this is the driver you've installed, then you probably just need to put
that file in the same directory as the driver's library files (in /usr/lib, or
wherever they belong in your OS.) The header should come with the driver.
This is just a guess, though.
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: Fri, 26 May 2000 21:47:13 GMT
From: scottlong@my-deja.com
Subject: Re: Looking for a good editor...
Message-Id: <8gmrct$qs0$1@nnrp1.deja.com>
Hi,
Try CRISP editor. You can get it from http://www.vital.com.
In article <392A9ACF.D2F681CB@outofthisworld.org>,
Phill Allen <webmaster@outofthisworld.org> wrote:
>
> A good text editor that includes PERL dictionary highlighting and
> has a nice integrated FTP interface is UltraEdit
> www.UltraEdit.com for Windows!
>
> This is an inexpensive editor that has lost of potential.
>
> Phill
> jcentrix@hotmail.com
>
> John Springer wrote:
> >
> > in article 8g8o5s$oma$2@news2.kornet.net, Padawan at
perl@sigmainstitute.com
> > wrote on 5/21/00 6:25 AM:
> >
> > > Good day,
> > > I'm a Perl Padawan (beginner) and have tried a few of Perl editing
and
> > > testing programs (Perl Builder, Perl Studio, DZ Perl Editor), but
I want to
> > > put the money down on a highly recommended editor. What do the
Jedi Masters
> > > of Perl and Perl/CGI use?
> > >
> > > Thanks in advance...
> > >
> > This one uses BBEdit on a Macintosh.
> > I've never seen anything on windoze yet that would convince me to
switch.
> >
> > --
> > John Springer
> > Sitting in the rain in Portland.
> > Pondering my perl.
> > Moss everywhere.
> > Perfect.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 26 May 2000 20:28:33 GMT
From: irenaro@my-deja.com
Subject: LWP::SecureSocket and https
Message-Id: <8gmmp0$ndq$1@nnrp1.deja.com>
Hello,
i'm trying to get secure HTTPs page by following code:
use LWP::SecureSocket;
$remote = new LWP::SecureSocket;
$remote->connect($server,443) or die "can't connect to server on 443\n";
$document="/dir/file.cgi?parm1=value1&parm2=value2";
$remote->write("POST $document HTTPS/1.0\n\n");
$remote->write("Content-type: text/html\n\n");
$remote->read(\$buffer);
print $buffer, "\n";
I'm really very new for all these(socket, https) issues.
The code fails on connect line with "Failed to create SSL_CTX" message.
I installed all required modules (LWP/SSLeay etc.).
I tryied to do the same with:
$req = new HTTP::Request 'POST' =>
'https://www.server.com/file.cgi....";
and as I understood i'm able to get only files from HTTP and not HTTPS.
Can somebody tell me what is a right way to get pages from HTTPS?
Thank you in advice.
Irena
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 26 May 2000 22:03:29 GMT
From: you_know_who_am_i@hotmail.com (SBoyV)
Subject: Re: LWP::SecureSocket and https
Message-Id: <392ef04e.1981224@news.club-internet.fr>
irenaro@my-deja.com wrote:
>I tryied to do the same with:
>$req = new HTTP::Request 'POST' =>
>'https://www.server.com/file.cgi....";
>and as I understood i'm able to get only files from HTTP and not HTTPS.
>
>Can somebody tell me what is a right way to get pages from HTTPS?
For me it works perfectly under Win32.
Just take:
http://www.activestate.com/packages/zips/Crypt-SSLeay.zip
Nothing else is needed,
Good luck,
--
SBoyV
------------------------------
Date: Fri, 26 May 2000 12:11:09 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: my $x vs. my ($x)
Message-Id: <MPG.13986c2879a1879098aae9@nntp.hpl.hp.com>
In article <PNxX4.1704$Rx.296215@den-news1.rmi.net> on Fri, 26 May 2000
10:57:13 -0500, Tim <tcuffel@exactis.com> says...
...
> What I want to know is which is better when it doesn't matter. I see
> a lot of stuff like:
>
> my ($x) = 42;
>
> which I think is kinda silly. But I see it a lot, so I was wondering if
> someone has ever made a call on this.
To me, the above is a matter of poor breeding, because it implicitly
converts a scalar to a one-element list (so the scalar is evaluated in
list context, should that matter) and then assigns that to a list. As
you and I prefer to, one might write:
my $x = 42;
which assigns a scalar (evaluated in scalar context) to a scalar, or
my ($x) = (42);
which assigns an explicit list to a list. The latter has the advantage
of facilitating appending to the list conveniently:
my ($x, $y) = (42, 63);
But other than that, it is obfuscatory, IMO.
In an earlier post, you said that 'my' isn't a function. Amen to that!
It is a declaration, which also supports initialization. Too bad that
it shares the syntax of a function and is documented in perlfunc, along
with several other operators that are not functions (such as flow-
control operators).
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 26 May 2000 12:28:52 -0700
From: sergei kucherov <sergei_kucherovNOseSPAM@3com.com.invalid>
Subject: Re: my $x vs. my ($x)
Message-Id: <04ef478a.1dec3c87@usw-ex0107-055.remarq.com>
In article <PNxX4.1704$Rx.296215@den-news1.rmi.net>, "Tim"
<tcuffel@exactis.com> wrote:
>
>Randal L. Schwartz wrote in message ...
>>>>>>> "Tim" == Tim <tcuffel@exactis.com> writes:
>>
>>Tim> However, I have seen my ($x) in posted code, some of the
books, and other
>>Tim> semi-respectable sources. Is there any kind of concensus
on which is more
>>Tim> appropriate?
>>
>>Depends on what you want:
>>
>> my $x = @_; # number of elements passed to this
subroutine
>> my ($x) = @_; # first element
>>
>>So, it's not a matter of which is "right", but which is "right
for the
>>use". You gotta know about both.
>
>
>Right. When one works and the other doesn't, it is real easy to
decide.
>
>What I want to know is which is better when it doesn't matter.
I see
>a lot of stuff like:
>
>my ($x) = 42;
>
>which I think is kinda silly. But I see it a lot, so I was
wondering if
>someone has ever made a call on this.
>
>
>
>
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Fri, 26 May 2000 12:43:36 -0700
From: sergei kucherov <sergei_kucherovNOseSPAM@3com.com.invalid>
Subject: Re: my $x vs. my ($x)
Message-Id: <04ddba12.21c3e88c@usw-ex0107-055.remarq.com>
In article <PNxX4.1704$Rx.296215@den-news1.rmi.net>, "Tim"
<tcuffel@exactis.com> wrote:
>
>Randal L. Schwartz wrote in message ...
>>>>>>> "Tim" == Tim <tcuffel@exactis.com> writes:
>>
>>Tim> However, I have seen my ($x) in posted code, some of the
books, and other
>>Tim> semi-respectable sources. Is there any kind of concensus
on which is more
>>Tim> appropriate?
>>
>>Depends on what you want:
>>
>> my $x = @_; # number of elements passed to this
subroutine
>> my ($x) = @_; # first element
>>
>>So, it's not a matter of which is "right", but which is "right
for the
>>use". You gotta know about both.
>
>
>Right. When one works and the other doesn't, it is real easy to
decide.
>
>What I want to know is which is better when it doesn't matter.
I see
>a lot of stuff like:
>
>my ($x) = 42;
>
>which I think is kinda silly. But I see it a lot, so I was
wondering if
>someone has ever made a call on this.
>
>
I have been using my($x) and my($x, $y) so that my code looks
stylistically consistent. The parens work for one variable
or several. In particular, I have been known to do:
my($x) = @_;
which would generally be wrong without the parens (as Randal
pointed out). A similar danger is for newbie perl coders
who are used to C. Once you get used to leaving out the parens,
you might be tempted to do:
my $x, $y = @_;
Since I've arrived at an intermediate perl coding level,
I'm reconsidering whether it would be better to leave out
the usually superfluous parens (I'm now 2 years from my last C
coding and no longer think of "my" as similar to a "char *"
or "int" declaration). To date I have not used "unless" and
similar perl-isms which avoid extra braces. I'm changing now
to code in a more perlish style. But perl newbies will have a
harder time reading my code, which is a real concern in
our environment.
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Fri, 26 May 2000 21:20:08 GMT
From: sergei_kucherov <sergei_kucherov@3com.com>
Subject: Re: my $x vs. my ($x)
Message-Id: <8gmppq$pk1$1@nnrp1.deja.com>
In article <MPG.13986c2879a1879098aae9@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
wondering if
> To me, the above is a matter of poor breeding, because it implicitly
> converts a scalar to a one-element list (so the scalar is evaluated in
> list context, should that matter) and then assigns that to a list. As
> you and I prefer to, one might write:
>
> my $x = 42;
>
> which assigns a scalar (evaluated in scalar context) to a scalar, or
>
> my ($x) = (42);
>
> which assigns an explicit list to a list. The latter has the
advantage
> of facilitating appending to the list conveniently:
>
> my ($x, $y) = (42, 63);
>
> But other than that, it is obfuscatory, IMO.
Larry has converted me to use the "good breeding" style :-).
============================================================
The unexpectedly related discussion of || vs "or" has also changed
my perl coding style to (as a general rule of thumb) use || when
outside of an "if (...)" expression clause, and "or" within
such a clause (especially if there is an assignment).
Similarly for "and" and "not".
So I am not following the style found in the book
"Effective Perl Programming", which is where I first saw:
... or die ...
-- Because of the danger that someone (eg. me) will generalize the
style idiom and start using "or" when it is an assignment statement:
... = ... or die ...
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 26 May 2000 18:10:59 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: Netscape w/ Perl
Message-Id: <8gmenj$q7k$4@news.panix.com>
On Thu, 25 May 2000 21:31:05 -0600, Brian Burton <bburton@cintek.com> wrote:
++ Hey there, this question I know has probably been out there lots but I
++ haven't easily found the answer.
++
++ My scripts work good with Internet Explorer but with Netscape it just
++ views the source. Does anyone know a solution?
Yes there are lots of people who know the answer. However, you'll
find them in different groups.
Your article was Perl free.
Abigail
------------------------------
Date: Fri, 26 May 2000 14:38:00 -0600
From: "Brian" <brburton@cintek.com>
Subject: Re: Netscape w/ Perl
Message-Id: <8gmn86$iln$1@news.junction.net>
I am fairly new to Perl and the script I was talking about is a Perl script
that get's called from my webpage that in it "prints" the HTML code.
I just hoped that someone would know the answer but since I already found
it, no worries.
B
------------------------------
Date: Fri, 26 May 2000 07:35:41 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Newbie - need to rip images from URL
Message-Id: <392f27ca.1402125@news.skynet.be>
patrickshroads@my-deja.com wrote:
>How would I capture the response to a file?
Use LWP::Simple's getstore().
As a variation on Randal's theme (warning: untested):
use LWP::Simple;
my $url ="http://developer.irt.org/images/irt-sm.gif";
my $file = 'oopsthereitis.gif';
getstore($url, $$file)==200 or die "Cannot retrieve file!";
--
Bart.
------------------------------
Date: Fri, 26 May 2000 12:32:31 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Newbie: DIV
Message-Id: <MPG.1398712b910563f898aaeb@nntp.hpl.hp.com>
In article <k0nn1ldpvly.fsf@dhcp-49138.phys.ntnu.no> on 26 May 2000
10:24:25 +0200, Joakim Hove <hove@phys.ntnu.no> says...
> Stephan Canisius <SCanisius@dusnet.de> writes:
>
> > 10/3 is 3.333333333 and I only want the 3 given to me.
>
> Well, i guess int () should help you with this. However you should be
> aware that int truncates decimals, and does not do mathematically
> proper rounding:
>
> #!/usr/bin/perl -w
> $three = int 10/3;
> $four = int 19/4;
Just for completeness, there's another way to specify this behavior,
over whatever scope you wish:
#!/usr/bin/perl -w
{
use integer;
$three = 10/3; # 3
}
$four = 19/4; # 4.75
Integer arithmetic will be used throughout the specified scope.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 26 May 2000 21:30:39 GMT
From: scottlong@my-deja.com
Subject: Re: Perl Editor for Linux
Message-Id: <8gmqdv$q9n$1@nnrp1.deja.com>
Hello,
You may want take a look at the CRISP editor. The web site is
http://www.vital.comm.
In article <slrn8isq66.4tu.tjla@thislove.dyndns.org>,
tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:
> I was shocked! How could Elaine Ashton <elaine@chaos.wustl.edu>
> say such a terrible thing:
> >in article 8ghahj$qbt$1@nnrp1.deja.com, houseofpain@my-deja.com at
> >houseofpain@my-deja.com quoth:
> >
> >> Can anyone recomend a good Perl Editor for Linux. Someting i can
use
> >> to trace through my code.
> >
> >Try ed.
>
> No No! cat is the one true text editor!!!
>
> --
> Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
> My return address is rot13'ed
> A writer is congenitally unable to tell the truth and that is why we
call
> what he writes fiction.
> -- William Faulkner
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 26 May 2000 11:27:36 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl unusable as a programming language
Message-Id: <MPG.139861efb8a2f9a98aae6@nntp.hpl.hp.com>
In article <393145cb.9083276@news.skynet.be> on Fri, 26 May 2000
10:05:55 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Larry Rosler wrote:
>
> >A company selling commercial software products (Micro$..t excepted, of
> >course :-) can -- and usually does -- impose quality criteria and
> >metrics on its employees. But not on volunteers.
>
> The committee (?) can reject contributions that they consider of too low
> quality.
>
> Is the difference so fundamental?
I don't want to be misunderstood. I'm not casting aspersions on the
quality of submissions of new functionality by Perl volunteers, or on
the value of whatever peer review there is.
I meant that volunteers are unlikely -- on their own -- to focus on
quality or documentation improvements as their primary contributions.
New features are so much more glamorous.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 26 May 2000 11:57:19 -0700
From: sergei kucherov <sergei_kucherovNOseSPAM@3com.com.invalid>
Subject: perl5.6 bug -- no stringification of object reference
Message-Id: <0d405d62.15b1ca33@usw-ex0107-055.remarq.com>
Below is a tiny script that demonstrates a perl5.6 (core)
regression from the correct behavior in perl5.00503.
This bug is why I am reinstalling perl5.00503 to replace perl5.6
on our machines (note: lifetime of our perl5.6 installation was
all of two days). Supposedly a patch exists somewhere, but it is
not easy to acquire this patch (devel.tar.gz does not exist yet
at www.cpan.org/src ). No need for a followup to this post,
since I've already reported the bug to bugs.activestate.com .
The bug affects all classes that override '""'.
======================================================
#!/usr/local/bin/perl -w
use strict;
use URI;
# bug: URI class has overload method for '""'
# which is not being called automagically in perl5.6 .
# perl5.00503 works correctly.
my $uri = URI->new("http://10.1.1.5");
if ($uri->as_string =~ /^http:/) {
print "PASSED easy uri test\n";
} else {
print "FAILED easy uri test\n";
}
# this next test fails on perl5.6
if ($uri =~ /^http:/) {
print "PASSED hard uri test\n";
} else {
print "FAILED hard uri test\n";
}
======================================================
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Fri, 26 May 2000 20:55:37 GMT
From: sergei_kucherov <sergei_kucherov@3com.com>
Subject: Re: perl5.6 bug -- no stringification of object reference
Message-Id: <8gmoc1$on5$1@nnrp1.deja.com>
In article <0d405d62.15b1ca33@usw-ex0107-055.remarq.com>,
sergei kucherov <sergei_kucherovNOseSPAM@3com.com.invalid> wrote:
> Below is a tiny script that demonstrates a perl5.6 (core)
> regression from the correct behavior in perl5.00503.
> This bug is why I am reinstalling perl5.00503 to replace perl5.6
> on our machines (note: lifetime of our perl5.6 installation was
> all of two days). Supposedly a patch exists somewhere, but it is
> not easy to acquire this patch
OK, I went through the pain of looking at over 500 subject lines in the
perl5-porters archives (search for "patch") to find this one critical
patch that will make perl5.6 usable for our group. FYI, the web site for
perl5-porters is: www.xray.mpe.mpg.de/mailing-lists/perl5-porters/
Here is the patch reference for anyone else who cares about ^ working in
regexps on references or objects being automagically stringified:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-03/msg02668.html
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 26 May 2000 19:10:03 GMT
From: A <y-o-y@home.com>
Subject: Re: PerLotto 0.1a1. My first "real" Perl script!!!
Message-Id: <f_zX4.210414$Tn4.1870654@news1.rdc2.pa.home.com>
In article <slrn8ivpa8.3cn.tjla@thislove.dyndns.org>,
tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:
> Note that the following is more or less untested but it conforms a bit
> more to the perl "way". You have a fair bit to learn, look in the
> documentation available to you and read as many books as you can,
> especially ones that focus on programming well, with good style. I
> learnt perl from "Programming Perl" (the one with a camel on the front)
> and can highly recommend it but maybe not as a first book if you are
> just starting out.
I've got so much to read! The included docs alone are a volumn. As far
as style and technique, agreed, I better develop better habits before I
get too far along in the learning process.
I didn't really outline the program design on paper. More or less
inserted things as I went along. Not very organized I realize.
> >print("Enter winning number separated by spaces: ");
> >$input = <STDIN>;
> >chomp($input);
> >@lotto = (split/ /, $input);
>
> you might want to do this:
>
> @lotto = split /\s+/, $input;
>
> This will allow any amount of whitespace between the numbers.
Thanks! That solves the extra spaces problem (split) problem!
> >open(IN, 'games');
> >while ($line = <IN>)
> >{
> > chomp($line);
> > @win = (split/ /, $line);
> >
> > $picks = 0;
> >
> >#Check for duplicate numbers in a game
> >for ($y=$#win ; $y>=0 ; $y--)
> > {
> > for ($x=$#win ; $x>=0 ; $x--)
> > {
> > if ($y == $x)
> > {
> > }
>
> Why do you have this empty test? Wouldn't it be better to do:
>
> if ($y != $x)
>
> and leave out the else?
>
> > else
> > {
> > if ($win[$y] == $win[$x])
> > {
> > print("INALID: Duplicate number in game below.\n");
> > $y = 0;
> > }
> > }
> > }
> > }
>
> I recommend you do the above loop as:
>
> while (<IN>)
> {
> chomp; # use the "default" $_ variable
>
> @win = split; # use the default split, this is safer than yours if the
> # lines in the "lotto" file are tab delimited (say)
Great!!! I wondered how I could handle that exact situation. I was
making the program much less flexible. Thanks!
> LOOP: for ($i = 0; $i < @win; $i++)
> {
> for ($j = $i + 1; $j < @win; $j++)
> {
> if ($win[$i] == $win[$j])
> {
> print "INVALID: Duplicate number in game below.\n";
> last LOOP;
> }
> }
Thanks!
> OR you could simply find and remove duplicate entries from the array in
> one step. This means that if the file accidentally has some duplicate
> entries they wont matter:
If someone types in duplicates by mistake from their lotto tickets to
the games file, I want to know about it, that's all.
> undef @saw;
> @win = grep(!$saw[$_]++, @win);
>
> If you don't understand this one then don't worry about it (yet).
>
> >
> >#Check for too few entries in a game
> >if ($#win != $#lotto)
> > {
> > if ($#win < $#lotto)
> > {
> > print("INALID: Too few numbers in game below.\n");
> > }
> > else
> > {
> > print("INVALID: Too many numbers in game below.\n");
> > }
> > }
>
> Note that you can get the size of an array simply by using it in a
> scalar context. Also note that the first if test is not necessary eg:
>
> if (@win < @lotto)
> {
> ...
> }
> elsif (@win > @lotto)
> {
> ...
> }
Thank you!
> >
> > for ($y=$#lotto ; $y>=0 ; $y--)
> > {
> > for ($x=$#win ; $x>=0 ; $x--)
> > {
> > if (($lotto[$y]) == ($win[$x]))
> > {
> > $picks++;
> > }
> > }
> > }
>
> foreach $num (@win)
> {
> foreach $guess (@lotto)
> {
> picks++ if ($num == $guess);
> }
> }
Very nice. I did switch over to foreach blocks. The picks+++ if... now
that's much nicer!!!
> > $last = $#lotto +2;
> > $win[$last] = "--$picks";
>
> uhhh. I wouldn't do this. Why not just print the number of correct
> guesses explicitly?
Thanks for pointing that out. DOH!
> $, = " "; # look in the "perlvar" documentation for an explanation of
> # this and other funky named variables. In this case $, sets
> # the character to put between elements in a list when
> # printing
> print @win;
> print $picks . "\n";
MUCH nicer method. Thanks!
> > foreach $item (@win)
> > {
> > print("$item ");
> > }
> >
> > print("\b\n");
>
> what does the "\b" do?
Since $picks became an $item in the array it printed a space before the
\n, so I \b'd to get rid of it. Switching to your method it's not
necessary at all. That also solves the problem of the actual control
character being inserted into a file on STDOUT re-direction!
> >close(IN);
>
> It shouldn't be necessary to close the file since you are quitting
> anyway.
Agreed. I noticed that it didn't seem to matter.
Gwyn, you put a lot of time and effort into your reply and it's all
great info. I'm very grateful!
I'm going to incorporate your techniques from above, add a "number is
too high for this lotto" error check/feature, clean up the print
alignment and maybe later add a "powerball" feature.
Today I added a non-numeric error check, fixed a couple typos, renamed
the variables to be more intuitive and added the ability to include
comments and blank lines in the 'games' file.
Many thanks, again!!!
Andy
Andy
------------------------------
Date: Fri, 26 May 2000 19:43:30 GMT
From: yudelin@my-deja.com
Subject: problems in PPM and installation modules
Message-Id: <8gmk4u$ljr$1@nnrp1.deja.com>
Hi,
Any body knows an easy way to install those Perl modules available? It
takes too much time to install them by yourself (following
their "README" instruction) because you often got problems in testing
and you don't know how to do with them (my experience). Using PPM may
be a good idea but then I got many problems with PPM also - it just
totally doesn't work for me now. Here's the whole story:
My OS: Win NT
1. I installed ActivePerl 613 (so I had PPM also), and followed
instruction to set up Environmental Variable "HTTP_proxy" for Internet
server in "Properties" in "My Computer". Then I run "search"
and "install" commands in PPM and was successfully to install Perl
modules DBI, DBD::ODBC (related Perl script worked also).
=> Note: Our IT support told me later actually we didn't have a proxy
server , bit I really don't know why it worked at the first time
if "proxy:8080" is a wrong name.
2. The next day I found I needed to install another module, I went
to PPM but couldn't do a search (find nothing or just can't link to Web
site, I don't remember exactly). Then I found Activestate.com site
mentioned that there were problems with PPM and they provide a fix
program. I installed this PPM Hotfix program to update my PPM to
version 1.1.4 (following all instructions and everything looked ok).
But when I run a "search" I got error message like following:
PPM>search
HTTP POST failed: 500 (can't connect to proxy:8080 (Bad
hostname 'proxy'), <> line 2.
), in SOAP method call. Content of response:
at D:/Perl/site/lib/PPM/SOAPClient.pm line 222
=> Note: other PPM commands like "set","query" are still working here.
3. I reinstalled Perl and PPM fix program many times (I removed
first all Perl except a few protected files in Perl\bin\, manually or
using installation program). But always got same error. I tried not to
use PPM fix program (so PPM version is 1.1.3), but got same error.
Even when I deleted HTTP_proxy set up (our IT said I may not need
that), I still got same error "... bad hostname proxy" -- from where
PPM still found a Proxy name?
Any helps and information are highly appreciated.
Yude Lin
Encl.
********** line 222 in SOAPClient.pm ******************
line #:
221: my $soap = new SOAP::Transport::HTTP::Client();
222: my $result = $soap->send_receive(
223: $self->{'_server'},
224: $self->{'_urn'},
225: $method,
226: $soap_request );
****************************************************
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 26 May 2000 14:07:03 -0400
From: Phil Eschallier <phil@BuxTech.Com>
Subject: Re: Problems installing DBI-1.13
Message-Id: <86bt1tgp88.fsf@BuxTech.Com>
>>>>> "Rodney" == Rodney Engdahl <red_orc@my-deja.com> writes:
> In article <392E9898.BBF7AE2E@lmc.ericsson.se>, "Martin C Dore
> (LMC)" <lmcmcad@lmc.ericsson.se> wrote:
>> Hi
>>
>> I have get the DBI-1.13 from this website:
>> http://www.perl.com/CPAN-local/modules/by-module/DBI/
>>
>> I have read the instruction to install it. It says to do: perl
>> Makefile.PL make make test make install
>>
>> I have done perl Makefile.PL with no problem
>>
>> The problem is with the make. When i have made the make, he
>> starts and stop suddenly saying:
>>
>> cc -c -I/usr/local/include -O -DVERSION=\"1.13\"
>> -DXS_VERSION=\"1.13\" -KPIC
> try this without the K in -KPIC
>> -I/usr/local/bin/nsPerl5.005_03/lib/sun4-solaris/CORE
>> -DDBI_NO_THREADS Perl.c
>>
>> /usr/ucb/cc: language optional software package not installed
>>
>> *** Error code 1
>>
>> make: Fatal error: Command failed for target 'Perl.o'
>>
>> HELP please!!!
>>
>>
> -- Some drink at the fountain of knowledge...others just gargle.
> Sent via Deja.com http://www.deja.com/ Before you buy.
Sun's cc compiler does not appear to be on your system -- perhaps
/usr/local is NFS mounted an you're on a different system than that
which was used to install perl5? Or perhaps it was just removed?
You'll be stuck without Sun's compiler ... or you could try to install
GCC on your local workstation and name it 'cc' but as perl5 was
apparnetly compiled with Sun's compiler, who knows how well this would
work.
--
Phil Eschallier | Bux Technical Services | Systems, software,
inet phil@BuxTech.Com | 131 Wells Road | security and Inter-
tel 215 348 9721 | Doylestown, PA 18901 | networking for your
fax 215 230 8265 | http://www.BuxTech.Com | business!
KeyID D6E9B193
------------------------------
Date: Fri, 26 May 2000 20:53:06 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: randomizing (anagramming words)
Message-Id: <sitp1iit5pj70@corp.supernews.com>
Kevin Miles (kdmiles@lucent.com) wrote:
: If I want to randomize a word
: i.e.
: England
: to be (as an example)
: glnEand
: How do I do this in PERL??? Can I randmize a string??
Sure; just split on the null pattern to break the word into an array of
characters, shuffle that array using the technique described in the FAQ,
then reassemble the string using e.g. join with a 0-length-string
separator argument.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "The road of Excess leads to the Palace
of Wisdom" - William Blake
------------------------------
Date: Fri, 26 May 2000 15:05:17 -0400
From: Brian Whitman <bwhitman@cs.columbia.edu>
Subject: reading from binmode() as "unsigned chars"
Message-Id: <Pine.GSO.4.21.0005261501510.23402-100000@ocean.cs.columbia.edu>
I have a binary file, my platform is Win98. I'd like to read an arbitrary
*byte* from it and treat it like an integer. Here's what I'm doing:
open FILE, "moles_03.mmd";
binmode FILE;
seek FILE, 4994, 0;
read FILE, $buffer, 1;
if($buffer > 100) { print "this never happens! :( \n"; }
close FILE;
The byte location of 4994 contains hex c0 - decimal 192. If I print
$buffer I get the ASCII version of 192, which is a notch character.
However, the test above never returns true, nor can I do math ops to this
number. How can I get an "unsigned char" read from a binary file as a
number?
-Brian
------------------------------
Date: Fri, 26 May 2000 15:33:57 -0400
From: Brian Whitman <bwhitman@cs.columbia.edu>
Subject: Re: reading from binmode() as "unsigned chars"
Message-Id: <Pine.GSO.4.21.0005261531530.23402-100000@ocean.cs.columbia.edu>
I answered my own question, I think:
>
> open FILE, "moles_03.mmd";
> binmode FILE;
> seek FILE, 4994, 0;
> read FILE, $buffer, 1;
$newbuf = join('', unpack('C*', $buffer));
> if($newbuf > 100) { print "this never happens! :( \n"; }
> close FILE;
>
It looks like that did it. I dono, I like newbuf = (unsigned char) *buffer
better ... :)
-Brian
------------------------------
Date: Fri, 26 May 2000 19:13:20 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: reading from binmode() as "unsigned chars"
Message-Id: <k1AX4.647$xJ2.10467@news.itd.umich.edu>
In article <Pine.GSO.4.21.0005261501510.23402-100000@ocean.cs.columbia.edu>,
Brian Whitman <bwhitman@cs.columbia.edu> wrote:
>open FILE, "moles_03.mmd";
>binmode FILE;
>seek FILE, 4994, 0;
>read FILE, $buffer, 1;
>if($buffer > 100) { print "this never happens! :( \n"; }
>close FILE;
>The byte location of 4994 contains hex c0 - decimal 192. If I print
>$buffer I get the ASCII version of 192, which is a notch character.
>However, the test above never returns true, nor can I do math ops to this
>number. How can I get an "unsigned char" read from a binary file as a
>number?
$buffer contains a string, but you're treating it like a number. Either
convert $buffer to its ordinal value, or use a string comparison operator
to compare it with another string:
if (ord($buffer) > 100) { ... }
if ($buffer gt chr(100)) { ... }
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
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 3178
**************************************