[9352] in Perl-Users-Digest
Perl-Users Digest, Issue: 2947 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 23 12:07:12 1998
Date: Tue, 23 Jun 98 09:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 23 Jun 1998 Volume: 8 Number: 2947
Today's topics:
Re: after 5 hrs, the beginner beats the s/// (Matt Knecht)
CGI Help Please <worker@capequip.com>
Re: Flames.... (I R A Aggie)
Re: Flames.... (I R A Aggie)
Re: Flames.... <tchrist@mox.perl.com>
Re: Flames.... birgitt@my-dejanews.com
Re: Flames.... (I R A Aggie)
Re: Flames.... <quednauf@nortel.co.uk>
Re: Flames.... (Eric D. Friedman)
Re: Hash iteration (trying to avoid looping through the <danboo@negia.net>
Help with site command in NET::FTP <jcisaac@pacbell.com>
Re: How can I get the IP-Number & the Remote_Host Name <jdporter@min.net>
Re: How to find last modified date of a file? <quednauf@nortel.co.uk>
Re: How to make Web work with "rsh" in Perl (Brian Wheeler)
Re: How to test perl on my windows95 home computer...? <rootbeer@teleport.com>
Re: How to test perl on my windows95 home computer...? <quednauf@nortel.co.uk>
Learning Perl; (i.e. newbie question) <airvent@ktis.net>
LWP::Simple on NT with a proxy / fire wall <davidc@selectst.com>
QUESTION: Why does only one of these work? (Mario D'Alessio)
Re: Remove blank too much lines from a text file <perlguy@inlink.com>
Re: sort e-mail list <psdspss@execpc.com>
Re: Windows NT, how to copy binary files ! (David Cantrell)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Jun 1998 15:19:00 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: after 5 hrs, the beginner beats the s///
Message-Id: <EHPj1.12$ct3.109951@news3.voicenet.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
>None of whom (modulo me) actually provided the proper answer.
I know I'm starting to build a nice little tchrist library. From my
archives I have this nice, simple little gem:
sub trim {
my @strings = @_;
for (@strings) {
s/^\s+//;
s/\s+$//;
}
return wantarray ? @strings : $strings[0];
}
After lots of searching on perl.com, and dejanews, I don't think I'll
have to buy the Cookbook if it ever comes out. ;)
--
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"
------------------------------
Date: Tue, 23 Jun 1998 09:48:14 -0500
From: "Dr.V" <worker@capequip.com>
Subject: CGI Help Please
Message-Id: <6mofh0$826$1@supernews.com>
I'v been working on this for weeks now and i can't find the problem.
Can anyone tell me what is wrong with this program?
when i test it using my computer, using perl5 for windows 95/nt it does'nt
give me an error code. so i then put it on the server and try it.
I log in useing telnet and check it there. and i get this error.
Can't find string terminator "ending_print_tag" anywhere befor EOF at
first.cgi line 4.
#!/usr/bin/perl5
print "content-type: text/html\n\n";
print = <<'ending_print_tag';
<html>
<head>
<title> My first CGI </title>
<background="#000000" text="#FF0000" >
</head>
<body>
<h1> My First CGI </h1>
<em> HELLO, INTERNET! </em>
<hr noshade>
Watch out cyber space, i'm on the loose
</body>
</html>
ending_print_tag
So you know this is out a CGI Programing book .
I have had no luck running any cgi scripts at all.
I tryed FormMail and other Form scripts and all i get is the 500 internal
server error.
The script above was tried cus it's a very simple script, just to see if it
would work.
I also have this script being ran from the test web page.
the address is www.capequip.com/first.htm
I would be very appreciate any help or clues in cureing my frustration.
DrV.
------------------------------
Date: Tue, 23 Jun 1998 11:01:58 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Flames....
Message-Id: <fl_aggie-2306981101580001@aggie.coaps.fsu.edu>
In article <358EA25D.4E63@hotkey.net.au>, steph@hotkey.net.au wrote:
+ Here here. What the hell ever happened to COMPASSION.
Compassion should be a two-way street...
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Tue, 23 Jun 1998 11:00:44 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Flames....
Message-Id: <fl_aggie-2306981100440001@aggie.coaps.fsu.edu>
In article <358F120A.8D355002@aquila.com>, "Michael D. Schleif"
<mike.schleif@aquila.com> wrote:
+ Bottomline, if you do not want to help the beleaguered, do NOT respond
+ to their questions. If nobody answers, they will go away -- so much
+ more bandwidth for enlightening topics, such as this!
And their parting shot will be "Waaaaa! Those people are a bunch of
arrogant pricks who wouldn't answer my questions. Waaaaaaa!" Perl'ers
are a reasonably friendly lot. But the "gimme gimme gimme" crowd wears
on one's nerves.
I for one am waiting for the clp.moderated newsgroup. That will put an
end to this foolishness.
+ From my meager vantage point, I do not think that I, nor my clients, are
+ ready for 5.004_67 -- I'm waiting for God to get it right first . . .
Doesn't mean you can't get the docset for it...
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: 23 Jun 1998 15:13:39 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Flames....
Message-Id: <6mogn3$en4$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
fl_aggie@thepentagon.com (I R A Aggie) writes:
:I for one am waiting for the clp.moderated newsgroup.
You may have to wait a long time. Unless you're planning
to campaign in favor of it, I can't help but think that the
evil news.groupies FUD-spreaders shall have sunk it.
--tom
--
"Software Engineers are like economists." --Rob Pike
------------------------------
Date: Tue, 23 Jun 1998 15:16:57 GMT
From: birgitt@my-dejanews.com
Subject: Re: Flames....
Message-Id: <6mogt9$jv9$1@nnrp1.dejanews.com>
In article <Pine.GSO.3.96.980622183041.3398P-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
>
> On Tue, 23 Jun 1998 birgitt@my-dejanews.com wrote:
> > 1. Don't play the enabler, don't provide the shortcut.
> > 2. Remind them daily (yes, that's needed, believe it or not)
> > that their behaviour is unacceptable.
> > Make it impossible to them to deny what is going on.
> > 3. Be there, if they stay 'sober'.
>
> Now, I believe that your suggestion was to have a daily autopost of some
> information on why some posts are inappropriate. It seems that you're now
> contending that this will somehow help people _after_ they've posted an
> inappropriate message. Hmmm.
Yes, in an open .misc group I don't think you can do anything about
the *real first-time post* of a *first-time c.l.p.m user*, only something
about what follows that post.
>
> I'd like to make an improvement to your suggestion. Here is my thesis:
>
> If it would help someone to read it,
> mailing it would be better than posting it.
Yes and no.
Yes, because anything you mail privately will most probably be read.
And I think any "straighten-out" flames belong in the private
mail box for that reason as well. It's a personal response to a
personal misbehaviour, so to speak. If you have 'sinned' and need
a strong dose of a lesson, you might be helped by getting one.
It's more appropriate to supply that lesson via email because:
1.You might consider what has been told to you with much more
openess and honesty, if you are not distracted by a public
humiliation.
2.You also can defend yourself privately if you feel you have been
completely misunderstood.
3.Nobody can use this privately sent mails and post it publicly.
(is illegal, isn't it ?). Both sides have saved the c.l.p.m. a
noisy flame exchange.
No, because it depends what you autopost publicly and what you
don't post publicly non-autopost mode.
1.If you post a MiniFAQ,
a HOW TO FIND A FAQ, READ FIRST,
a USERS' GUIDE TO C.L.P.M
more often than once a week or so, it really doesn't help much.
We know already that the ones, who should read it, don't. Doesn't
matter how helpful and how polite and cheerful the wording.
2.If you post something like
a WHY YOU DON'T GET AN ANSWER TO YOUR POST
a FIVE STEPS TO STOP COMPULSIVE C.L.P.M POSTING
a NO SHORTCUTS AND FREE LUNCHES AVAILABLE HERE
or something similar to that, it might catch your eye and
mind if
in combinations with 2.
3.you don't post publicly personal, very basic pointers
(however goodhearted, well-meant and objectively helpful
they might be to the individual newbie poster) which
could be found in daily autoposts of 2 and weekly autoposts
of 1.
4.Impersonal public autoposts can be much more defty/hefty/
juicy than personal public posts. I don't get upset
about a 'flamy' autopost, but it might make me think.
It is kind of very sad, because I am suggesting to consider
*not* to post the kindest responses I have seen so far in
c.l.p.m.
What I am trying to say I may be able to convey with a small
sentence I was confronted with in a completely different context
but somewhat similar underlying problems:
When Helping Harms The Ones You Love
>
> Points in support:
>
> 1. If they didn't read a posting beforehand, they won't read
> it afterwards.
If they have the choice to ignore the posting, because they got
already a real answer to their (inappropriate) FAQ question, yes.
If they didn't get this answer and would be left hanging in the dry,
they might read the posting and give it some serious thought.
See above.
>
> 2. Posting it weekly, daily, or hourly doesn't make it more
> likely to be read. Mailing it does.
Agreed. But it depends on what you post publicly and what you post
privately, I think. See above.
>
> 3. We are trying to improve the s/n ratio here, after all. Too
> frequently posting an identical document will make that worse.
Can't argue against it.
The only thing I can think of:
It would be a very easy recognizable noise you would generate with
a daily autopost and if it would cut down second follow-up inappropriate
upset/clueless/stubbern FAQ posts, and would cut down public personal
'straighten-out' answers, and would cut down very goodhearted, well-meant
and kind 'pointers' (yours :-), it might be justifyable and worth a try.
>
> Of course, this won't reach address-mungers. For their benefit, we could
> post it once per week or so. I could perhaps endorse a plan to mail some
> sort of "Users' Guide to c.l.p.misc" to inappropriate posters to this
> newsgroup.
Oh, no, not another "Users' Guide ...". See above.
Cheers !
Birgitt Funk
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 23 Jun 1998 11:17:30 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Flames....
Message-Id: <fl_aggie-2306981117300001@aggie.coaps.fsu.edu>
In article <Pine.GSO.3.96.980622192239.3398T-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
+ Let's all help to keep this newsgroup a valuable resource. Don't let
+ people get away with littering.
I dunno...how can one be accused of littering on the garbage scow that
has become comp.lang.perl.misc?
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Tue, 23 Jun 1998 16:39:29 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Flames....
Message-Id: <358FCC30.E71857D1@nortel.co.uk>
I R A Aggie wrote:
>
> In article <Pine.GSO.3.96.980622192239.3398T-100000@user2.teleport.com>,
> Tom Phoenix <rootbeer@teleport.com> wrote:
>
> + Let's all help to keep this newsgroup a valuable resource. Don't let
> + people get away with littering.
>
> I dunno...how can one be accused of littering on the garbage scow that
> has become comp.lang.perl.misc?
Quite painful to hear for a person who has been helped by this newsgroups quite
often.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 23 Jun 1998 15:29:56 GMT
From: efriedma@us.oracle.com (Eric D. Friedman)
Subject: Re: Flames....
Message-Id: <6mohlk$qf6$1@inet16.us.oracle.com>
In article <Pine.GSO.3.96.980622155331.3398D-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
<
<Maybe we should invest a little effort to develop a savvy address
<_de_munger. That would make everyone happy. :-)
<
Reminds one of Dr. Seuss' "sneeches on beaches," eh? (The story is
about a two groups of creatures - "sneeches" - one group has stars on
their bellies and spurns those in the other group, who do not. One
day a fellow comes into town with a machine that can put stars on
sneech bellies - for a price - and the sneeches spend all of their
money having stars applied and removed. Pretty soon they're out of
money and can't remember who was in which group to begin with!)
Eric
--
Eric D. Friedman
Software Developer Oracle Corporation
Porting Automation User Interfaces (650) 633-6040
------------------------------
Date: Tue, 23 Jun 1998 11:50:57 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Hash iteration (trying to avoid looping through the entire hash)
Message-Id: <358FCEE1.BE32E6C0@negia.net>
? the platypus {aka David Formosa} wrote:
>
> In <358F18D4.7EF0@pdq.net> Tom Kent <tkent@pdq.net> writes:
>
> >This script snippet allows me to parse a web server log and tell me how
> >many times each site was hit. However, I am unable to capture just the
> >top ten. Instead, I am only able to go through the entire hash. I've
> >tried counters and for loops in various places with no luck...Any ideas?
> >Thanks very much in advance.
>
> #!perl
>
> for $word (map {split ' '} <SOMEFILE>) {
> $count{$word}++;
> }
this will not work if SOMEFILE has more than one column. you need to
limit it to only the first item that comes out of the split. otherwise
you'll be including every "word" in the file. also, ' ' is the default
pattern for split and is not needed, leaving us with something like:
for $word (map {(split)[0]} <SOMEFILE>) {
$count{$word}++;
}
though i must now say that i've changed my mind since my post earlier in
this thread and would prefer *this* as my method for doing the frequency
count:
while (<SOMEFILE>) {
$count{(split)[0]}++;
}
why suck the whole file in at once if not necessary? :-)
and i might even do the following if this log file doesn't have leading
spaces:
while (<DATA>) {
/^(\S+)/ && $count{$1}++;
}
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Tue, 23 Jun 1998 08:34:51 -0700
From: "James Isaacson" <jcisaac@pacbell.com>
Subject: Help with site command in NET::FTP
Message-Id: <6mohs5$56d@gw.PacBell.COM>
I need advice on using the site command. The node I'm
connecting to has a 'site cm' command that automatically connects
to another server. In the debug I can see it connects but no
matter what I try the @files array is empty. I can maunally
ftp to this site and type site cm and then a dir and it works.
I tried putting a sleep in to wait for the connection to the site cm but
it did not help. Is there a wait or waitfor I can use to ensure I am
connected to the site?
Thanks in advance.
Jim
#!/usr/bin/perl
use Net::FTP;
$ftp = Net::FTP->new("119.245.24.201", Timeout => 60, Passive => true) or
die "Cannot contact 119.245.24.201: $!";
$ftp->debug(1);
$ftp->login('root', 'root') or
die "Cannot login:" . $ftp->message;
$ftp->command('site cm') or die "Unable to send command";
@files = $ftp->dir() or die "Unable to list directory";
foreach $file (@files) {
print "$file\n";
}
$ftp->quit or
die "Could not close the connection cleanly: $!";
exit;
------------------------------
Date: Tue, 23 Jun 1998 15:38:48 GMT
From: John Porter <jdporter@min.net>
Subject: Re: How can I get the IP-Number & the Remote_Host Name
Message-Id: <358FCDAA.699@min.net>
Larry Rosler wrote:
>
> This is a sounder (and shorter) approach:
> foreach (sort keys %ENV) { print "$_ = '$ENV{$_}'\n" }
> Of course, it no longer is "just one big print statement, but" you can't
> win 'em all :-).
local $, = "\n";
print map { "$_ = '$ENV{$_}'" } sort keys %ENV;
--
John Porter
------------------------------
Date: Tue, 23 Jun 1998 15:08:28 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: How to find last modified date of a file?
Message-Id: <358FB6DC.2B1ED57@nortel.co.uk>
Tom Phoenix wrote:
>
> On Mon, 22 Jun 1998, F.Quednau wrote:
>
> > open(BLA, $explan_file);
>
> Even when your script is "just an example" (and perhaps especially in that
> case!) you should _always_ check the return value after opening a file.
> Thanks!
ARGH! You finally got me ! NOOOO! Damn! Another hope down the drain...
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 23 Jun 1998 15:34:42 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: How to make Web work with "rsh" in Perl
Message-Id: <6mohui$hns$1@jetsam.uits.indiana.edu>
In article <358ED83D.4036A3EB@cae.cig.mot.com>,
Ying Peng <peng@cae.cig.mot.com> writes:
> Tom Phoenix wrote:
>>
>> On Fri, 19 Jun 1998, Ying Peng wrote:
>>
>> > The problems I am having are that the file cannot be generated via
>> > Web(call request.cgi) and "rsh" doesn't work (do nothing) when you click
>> > the submit button in the Web form.
>>
>> When you're having trouble with a CGI program in Perl, you should first
>> look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
>> such problems. It's available on CPAN.
>>
>> http://www.perl.com/CPAN/
>> http://www.perl.org/CPAN/
>> http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
>> http://www.perl.org/CPAN/doc/manual/html/pod/
>>
>> > The problems might relate to how to make "web" run the CGI or Perl
>> > scripts as root.
>>
>> Concerning security issues, that is generally considered a Bad Thing.
>>
>> Hope this helps!
>>
>> --
>> Tom Phoenix Perl Training and Hacking Esperanto
>> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
> Thanks for your info. But I might not write my problme more clearly
> resulting in you thinking my question is Idios. I read though the URLs
> you provided to me, unfortunately none of them help me find a solution
> to solve my problem. The key issue is described below:
>
> the CGI script has to be called by HTML(web
> form) under the httpd control. As you know the http daemon can not be
> run as root, but in my CGI script I have to use such command "rsh
> workstation ls
> /home/login". The /home/login might be 0700. "http" as an user has no
> right to access any directories or files with 0700. Do you have any
> suggestion to work arund it?
Become the user the webserver is running as and try it by hand. Its
probably asking for a password or something. Use the -l option on rsh to
set the username of the login.
Brian Wheeler
bdwheele@indiana.edu
>
> Thanks
>
> --Ying
------------------------------
Date: Tue, 23 Jun 1998 14:39:44 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: How to test perl on my windows95 home computer...?
Message-Id: <Pine.GSO.3.96.980623073111.24075P-100000@user2.teleport.com>
On Tue, 23 Jun 1998, F.Quednau wrote:
> Marcel Ouwendijk wrote:
> > I want to test my perl programs on my homecomputer with windows95 befor i
> > upload theme to my provider.
> Phew, this is asked a lot, and there is no straight answer in the win32
> FAQ
I'm sure that that FAQ's author would be glad to have help in improving
it.
> From the sound of it you want to run the programs in a CGI context, so
> you'll need the TCP/IP thing installed. Don't worry if you don't have
> a network card, just install a Network Card anyway :)
You're assuming (probably rightly) that the original poster was discussing
CGI programs written in Perl. Do you really need some special setup to
test CGI programs on Win32 systems? I thought that, if you use a savvy
module like CGI.pm, you could test your program from the command line
without needing anything special. That's supposed to be one of that
module's features.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 23 Jun 1998 16:31:34 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: How to test perl on my windows95 home computer...?
Message-Id: <358FCA56.DD35D3AE@nortel.co.uk>
Tom Phoenix wrote:
>
> On Tue, 23 Jun 1998, F.Quednau wrote:
>
> > Marcel Ouwendijk wrote:
> > > I want to test my perl programs on my homecomputer with windows95 befor i
> > > upload theme to my provider.
>
> > Phew, this is asked a lot, and there is no straight answer in the win32
> > FAQ
>
> I'm sure that that FAQ's author would be glad to have help in improving
> it.
I'll write something on it this evening and send it off to the relevant person.
>
> > From the sound of it you want to run the programs in a CGI context, so
> > you'll need the TCP/IP thing installed. Don't worry if you don't have
> > a network card, just install a Network Card anyway :)
>
> You're assuming (probably rightly) that the original poster was discussing
> CGI programs written in Perl. Do you really need some special setup to
> test CGI programs on Win32 systems? I thought that, if you use a savvy
> module like CGI.pm, you could test your program from the command line
> without needing anything special. That's supposed to be one of that
> module's features.
That is true. However, I tend to let my script create the form itself to fill
out, etc., and it is quite useful to see if the output is correct, the submit is
correct, file upload works nicely, etc. Not very much of a Perl issue, but then
you can be pretty sure that the program really works once it's uploaded.
>
> Cheers!
And to you!
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Tue, 23 Jun 1998 10:50:46 -0500
From: Jay Buffington <airvent@ktis.net>
Subject: Learning Perl; (i.e. newbie question)
Message-Id: <358FCED5.211242FE@ktis.net>
Hi
I don't expect help from anyone, but i would appreciate any that i might
receive. I'm reading the llama book, doing my best to learn perl. I
figured i would test my knowledge and see how far i could get writing a
simple game.. the idea of the game is the computer picks a number
between 1 and 1000 stores it in a varible and then trys to guess it,
using clues like, "to high, guess lower!". eventually it will be a
human vs. computer game but this code is just the computers brain... its
not working out to well... it compiles and everything.. the computer
wont take its own advice (i.e. if the answer is 600 it guesses 500 and
returns "to low" then it guesses 300!)
i would appreciate it if someone could point out to me what i'm doing
wrong.
i think my error is around line 33... but i'm not sure
--------------------------------begin
code--------------------------------
# initialize the random number generator
srand;
# set the array of possible numbers (i.e. guess a number between 1 and
1000)
@a = (1...1000);
# number of time i guessed for the right answer... is this step
necessary? better safe than sorry..
$attempts = 0;
#init the highest and lowest guesses...
$high = 999;
$low = 0;
# set the array that lets me choose a value from @a
@b = ($low...$high);
# choose a number between 1 and 1000 that is the number i'm trying to
guess.
$answer = $a[rand(@b)];
#for debugging purposes only, eventually this will be a game, human
against the computer, first one to get it right wins...
print "The answer is $answer, i will now try to guess that number\n";
while ($guess ne $answer) {
$guess = @a[rand(@b)];
&checkguess;
}
sub checkguess {
if ($guess > $answer) {
# since this guess was to high, i never want to guess any higher
than this...
# i think this is the line that is screwing this program up.. but i
have no idea how to fix it..
$high = $guess;
print "my guess is $guess, but that was to high, so i'll guess
between $low and $high\n";
# because arrays start at 0 instead of one, i need to subtract one
digit..
$high--;
# keep track of the attempts for later use...
$attempts++;
} else {
$low = $guess;
print "my guess is $guess, but that was to low, so i'll guess
between $low and $high\n";
$low--;
$attempts++;
}
}
print "It took me $attempts guesses, but I got it!";
--------------------------------end code--------------------------------
I probably did a horrible job explaining that, so i hope you understand.
Thanks a lot!
Bernard Assumalin
------------------------------
Date: Wed, 24 Jun 1998 01:17:27 +1000
From: David Coldrick <davidc@selectst.com>
Subject: LWP::Simple on NT with a proxy / fire wall
Message-Id: <358FC707.372FAC6F@selectst.com>
This is a multi-part message in MIME format.
--------------91B6F6345EF6E03B6176F167
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Using GS port of Perl 5.004_02 on NT 4.
I have a program that uses LWP::Simple to get() an http page that works
fine when directly connected to the net, but the get() fails when I try
it via a proxy.
As I understand the doc, I should be able to specify the proxy via an
environment variable http_proxy. I set a system variable http_proxy to
n.n.n.n:80 (via the control panel), where the IP address is the one that
successfully works as the proxy address with Netscape and IE, then ran
the program, but the get() failed.
Am I on the right track here? If so, is it possible that the firewall
could be set up to preclude use of Simple to perform such a task? (It's
an all-Microsoft network, so I guess they're using msoftware for the
firewall stuff).
Thanks for any help,
David
--------------91B6F6345EF6E03B6176F167
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for David Coldrick
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: David Coldrick
n: Coldrick;David
org: SELECT Software Tools
email;internet: davidc@selectst.com
x-mozilla-cpt: ;0
x-mozilla-html: TRUE
version: 2.1
end: vcard
--------------91B6F6345EF6E03B6176F167--
------------------------------
Date: 23 Jun 98 14:37:07 GMT
From: dalessio@manatee.cig.mot.com (Mario D'Alessio)
Subject: QUESTION: Why does only one of these work?
Message-Id: <dalessio.898612627@manatee>
Keywords: QUESTION: Why does only one of these work?
A coworker wrote a perl 4 script, and needed help
debugging it. I managed to get it working, but I
don't know why it didn't work in the first place.
Here's a sample of what she did:
foreach (<STDIN>)
{
next if 1 .. /pattern/;
...
}
I just could not get this to work. It never skipped
any lines. When I replaced "foreach" with "while",
it worked fine.
Why didn't this work with the "foreach" statement?
Thanks.
Mario
**********************************************************
* ____ ____ ___ *
* __/\__ Mario D'Alessio ((oo)) //oo\\ /o o\ *
* \RUSH/ dalessio@cig.mot.com \__/ \__/ \_O_/ *
* |/\| Work: (847) 632-2323 Moe Larry Curly *
* 9am to 6pm Central Time *
* *
**********************************************************
------------------------------
Date: Tue, 23 Jun 1998 15:18:21 GMT
From: Brent Michalski <perlguy@inlink.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Remove blank too much lines from a text file
Message-Id: <358FC73D.12160D9A@inlink.com>
C'mon Tom, give me a little break, it isn't as bad as you said.
#!/usr/bin/perl
$filename="test.txt";
open (IN_FILE,"$filename");
open (OUT_FILE,">$filename.out");
while(<IN_FILE>){
print OUT_FILE $_ if($_ ne "\n");
}
close OUT_FILE;
close IN_FILE;
DOES work. I tested it! Finally...
My "close" statement was in error though. I was under the impression
that a close without any arguments closed ALL open files, but a re-visit
to the docs on close did not mention that; so I don't know why I thought
that. Maybe a flashback to another language.
All I was TRYING to do, was provide a simple example of how I had
successfully done it in the past. The "\n" omission was just a
brain-fart, and I apologize.
My intent wasn't to provide a complete working program with all
error-checking, documentation, etc... I believe in learning-by-doing,
not in doing everything for everyone who asks.
I do promise to check my code more thoroughly before I post though.
Crawling away with tail between legs.....
Brent
------------------------------
Date: Tue, 23 Jun 1998 10:01:56 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Re: sort e-mail list
Message-Id: <358FC364.7851224E@execpc.com>
ken@co.greenwood.sc.us wrote:
> I need help adding a sort method. I am reading a file which contains the
> following text file:
>
> id firstname lastname
>
> This file contains a listing of the email box - "id" and the name of the user
> (first and last). I have created the following to read and split:
>
> #!/usr/bin/perl
> $filename="c:/public/email.txt";
> open(EMAIL,"$filename");
> while (<EMAIL>) {
> ($id,$first,$last) = split(/\s+/);
> print "$last, $first\n e-mail:$id\@domain.com\n";
> }
> close(EMAIL);
>
> Eventually I am going to use this to read my current e-mail listing
> (email.txt) and convert to html from a cgi on-the-fly. I want it to be able
> to first sort by last name before composing the html page.
>
> Thanks for the help.
> Ken
>
One approach, I could think of is, build a hash of arrays.
Hash key being the last_name.
Look at the following snippet, if that approach interests you :
#!/usr/bin/perl
$filename="./email.txt";
open(EMAIL,"$filename") or die "Could not open the email file : $!";
while (<EMAIL>) {
($id,$first,$last) = split(/\s+/);
print "$last, $first\n e-mail:$id\@domain.com\n";
# ** Build the hash of arrays. Key is the last name.
$email_list{$last} = [ ($id, $first) ];
}
# Sort the hash on last name.
foreach $key (sort keys %email_list)
{
# Access the array associated with the key.
($id, $first) = @{ $email_list{$key} };
print "The last name is : $key\t";
print "The first name is : $first\t";
print "The email id is : $id\n";
}
close(EMAIL) or die "Could not close the email file : $!";
Hope that helps.
Deva
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 23 Jun 1998 13:27:20 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: Windows NT, how to copy binary files !
Message-Id: <358694b9.92344364@news.ind.mh.se>
On Mon, 15 Jun 98 20:50:34 GMT,
JahanJ@yahoo.com (Jahan K. Jamshidi) enlightened us thusly:
>I know how to read a ascii file using perl and write it out somewhere else. I
>have problem reading a binary file and write out to a new location (kind of
>like copying the an executable program to a new locaiton). Does perl support
>this function? Any help is greatly appriciated.
You have to use binmode() after opening files:
# open the input file ...
open(INFILE, $inputfilename); binmode(INFILE);
# open the output file ...
open(OUTFILE, ">$outputfilename"); binmode(OUTFILE);
--
David Cantrell, part-time NT/java/SQL techie
full-time chef/musician/homebrewer
http://www.ThePentagon.com/NukeEmUp
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 2947
**************************************