[23223] in Perl-Users-Digest
Perl-Users Digest, Issue: 5445 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 5 00:18:31 2003
Date: Thu, 4 Sep 2003 21:10:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 4 Sep 2003 Volume: 10 Number: 5445
Today's topics:
Re: Rounding up anything past the decimal point sprint (ko)
Re: Silly push tricks <shawn@magma.ca>
Re: Silly push tricks (Anno Siegel)
Re: Telnet proxy <shuttermutt@nospam.com>
Re: Telnet proxy <shuttermutt@nospam.com>
Re: View NG with Net::NNTP (James Willmore)
Re: View NG with Net::NNTP (Mike)
Re: View NG with Net::NNTP (Mike)
Re: What ever happened to comp.lang.perl ? <tcurrey@no.no.no.i.said.no>
Re: What ever happened to comp.lang.perl ? <tcurrey@no.no.no.i.said.no>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 Sep 2003 15:39:51 -0700
From: kuujinbo@hotmail.com (ko)
Subject: Re: Rounding up anything past the decimal point sprintf
Message-Id: <92d64088.0309041439.23cbedd8@posting.google.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<bj7d92$ga108$1@ID-184292.news.uni-berlin.de>...
> Well, let's say that the context in which you posted the quote left
> some room for misunderstandings... I'm glad we are agreed. :)
I still don't see why there would be a misunderstanding, especially
since the OP asked "How can I round a number up if there is any value
other than 00 after the decimal point". In fact, the snippet that you
posted won't round up negative numbers:
====CODE
#!/usr/bin/perl -w
use POSIX qw[ceil];
my $count = 5;
my $item = -11;
my $result = ($item / $count);
my $answer = sprintf ("%.2f", $result);
my $answer1 = sprintf ("%.2f", ceil($result) );
my $answer2 = $result - int $result ? int $result + 1 : $result;
print join("\n", $answer, $answer1, $answer2);
====RESULTS
-2.20
-2.00
-1
That's the reason I posted 'perldoc -f int', only the OP knows whether
or not negative numbers will come in to play.
------------------------------
Date: Thu, 04 Sep 2003 18:51:33 -0400
From: Shawn Corey <shawn@magma.ca>
Subject: Re: Silly push tricks
Message-Id: <85-cnXJyaZlPXMqiU-KYvg@magma.ca>
Ben Kennedy wrote:
8< snip
> Using map() or grep() like this obfuscates the intent of the code. It
> certianly works, but it is not the most straightforward way of expressing
> the notion of "do one thing for each element in this list" - foreach()
> clearly is. Whether or not this is "poor style" depends on your point of
> view, of course. I prefer code to be as unambiguous as possible, as this
> makes it is easier to read, understand, and maintain. Using functions and
> modifers as described in the documentation and FAQ tend to do this for me.
> "Bad style" is clearly in the eye of the beholder, as someone could be
> perfectly comfortable with using map to iterate over loops and would not
> experience any loss in comprehension... but I'd guess that most seasoned
> Perl programmers would blink once or twice.
>
> --Ben Kennedy
>
Of course you have overlooked the original question: How to do this on
one line? Therefore style is relevant.
------------------------------
Date: 4 Sep 2003 22:53:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Silly push tricks
Message-Id: <bj8fpj$ed8$1@mamenchi.zrz.TU-Berlin.DE>
Ben Kennedy <bkennedy@hmsonline.com> wrote in comp.lang.perl.misc:
>
> "Abigail" <abigail@abigail.nl> wrote in message
> news:slrnblcs06.n3b.abigail@alexandra.abigail.nl...
> > Charlton Wilbur (cwilbur@mithril.chromatico.net) wrote on MMMDCLV
> > September MCMXCIII in <URL:news:878yp57f6r.fsf@mithril.chromatico.net>:
> > :) >>>>> "A" == Abigail <abigail@abigail.nl> writes:
> > :)
> > :) [using map in void context]
> > :)
> > :) A> Poor style? Why?
> > :)
> > :) Because
> > :)
> > :) map { fn($_) } @list;
> > :)
> > :) and
> > :) fn ($_) foreach @list;
> > :)
> > :) (where fn is a function with side-effects) do the same thing, but the
> > :) latter is better style.
> >
> > Beside that they are different (the context in which fn is called
> > differs) you don't give *any* argument why one is better style
> > than the other.
>
> Using map() or grep() like this obfuscates the intent of the code. It
> certianly works, but it is not the most straightforward way of expressing
> the notion of "do one thing for each element in this list" - foreach()
> clearly is.
The inventors of LISP (the language that introduced the map operator to
computing) thought otherwise. There, the map operation is clearly iterative.
It means: Apply this functions to successive elements (tails, actually)
of the original list. No collection of results is being done, you
need maplist for that. (The real LISP counterpart of Perl's map is
mapcar. It applies a function to successive elements (not tails), *and*
collects the results. Go figure.)
[snip style]
Anno
------------------------------
Date: Thu, 04 Sep 2003 22:14:46 GMT
From: Shuttermutt <shuttermutt@nospam.com>
Subject: Re: Telnet proxy
Message-Id: <5b5b2416b97eeb6243bd811cff698fe1@news.teranews.com>
news@roaima.freeserve.co.uk wrote:
> Shuttermutt <shuttermutt@nospam.com> wrote:
>
>>Good day all! I'm looking to write a prog that sits in between a
>>telnet client and server. In other words, the telnet client of the
>>user's choice would connect to my prog which would, in turn, connect
>>to the telnet server. My prog would move data back and forth between
>>the client and the server without manipulating it.
>
>
> A simple network proxy, in other words?
>
>
>>I'd like to know if anyone's run across this and/or if
>>somebody might have suggestions as to how I might proceed.
>
>
> In the general case, google for telnet proxy. In the perl specific case,
> check out the first hit on google for "perl telnet application proxy".
Hmmm... I hadn't seen ip_relay.pl before. It'll be worth taking a look
at it to see how he's doing things. I've also been playing with
fwdport.pl from The Cookbook and, while I can get it to work, I'm having
some trouble with it failing OOTB.
The real reason for doing this is so that my prog can analyze the data
moving between the telnet client and server and, when it finds something
interesting, do something else. Nothing sinister, mind you. I'm trying
to put together a scripting framework for a telnet-based game.
Anyway, thanks for the pointer to ip_relay. I googled before I asked, I
promise!
'Mutt
------------------------------
Date: Thu, 04 Sep 2003 22:22:58 GMT
From: Shuttermutt <shuttermutt@nospam.com>
Subject: Re: Telnet proxy
Message-Id: <46c578a4340561c936cbbd95794258a0@news.teranews.com>
James Willmore wrote:
> On Thu, 04 Sep 2003 12:03:58 GMT
> "Shuttermutt" <shuttermutt@nospam.com> wrote:
>
>>Good day all! I'm looking to write a prog that sits in between a
>>telnet client and server. In other words, the telnet client of the
>>user's choice would connect to my prog which would, in turn, connect
>>to the telnet server. My prog would move data back and forth between
>>the client and the server without manipulating it.
>>
>>I've started playing with Net::Telnet and IO::Socket, but before I
>>go too far, I'd like to know if anyone's run across this and/or if
>>somebody might have suggestions as to how I might proceed.
>
>
> Don't use telnet :) Use SSH. Unless you're using telnet on the
> client end and then using SSH to communicate with the server. Telnet
> sends everything clear text - SSH does not.
>
> There is Net::SSH and a few other SSH modules for Perl to aid in
> development.
Actually, I'm restricted to telnet since I don't have control over the
server side of things. I don't need a firewall type proxy as much as a
spy layer between the client of the user's choice and the server. You
see, I want to analyze the data being sent back and forth, catch what's
interesting, and use that as a part of a scripting framework for a
telnet-based game.
For example, if the server sent "Player Mutt moved from [A] to [B]" to
the client, I'd like to catch that and then let scripts act on that
information as they see fit. That way, if someone wanted to write a prog
that fired when a player moved and acted accordingly, my framework would
provide the necessary event and data to let them do that.
I've been playing with fwdport.pl from The Cookbook and I can proxy
ports, but I'm having trouble with the forking OOTB. If I can get it
fixed, the next step would be figuring out how to watch the data stream
between client and server.
Thanks for the heads up!
'Mutt
------------------------------
Date: 4 Sep 2003 18:25:57 -0700
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: View NG with Net::NNTP
Message-Id: <e0160815.0309041725.3b221435@posting.google.com>
tom@ztml.com (Tom) wrote in message news:<59b4279a.0309041309.76795c0@posting.google.com>...
> James Willmore <jwillmore@cyberia.com> wrote in message news:<20030904112427.589720fe.jwillmore@cyberia.com>...
> >
> > Yes, you're right. :(
> >
> > Does it work for you (the code I posted)? Anything else in error?
> > Comments welcomed.
<sniped for brevity>
>
> The changes made will output the last (most recent) message first. To
> output the oldest message first then nntpstat would be
> $nntp->nntpstat($first). The method in the while loop now should be
> $nttp->next.
I'm hoping the OP is still around, because I feel like I "stole" his
thread. But hey, I'm always open to new experiences :)
Thanks again.
Jim
------------------------------
Date: 4 Sep 2003 19:34:27 -0700
From: csdude@hotmail.com (Mike)
Subject: Re: View NG with Net::NNTP
Message-Id: <46cdc619.0309041834.7a6db561@posting.google.com>
> #!/usr/bin/perl -w
>
> use strict;
> use Net::NNTP;
<snip>
> while(my $msgid=$nntp->last) {
> # not all Net::NNTP packages include this function
> # my $fh = $nntp->articlefh;
> $nntp->article($msgid,*STDOUT);
>
> print;
> last if $x == 1;
> $x++;
> }
You guys are being an incredible help, I really appreciate that.
Apparently, my package simply doesn't recognize "$fh =
$nntp->articlefh;", like you said Tom, because changing it worked
perfectly.
Last question (I think). I noticed that, in my own script, I didn't
need to include the last "print;" statement; the statement
"$nntp->article($msgid,*STDOUT);" was printing for me. Based on this,
how would I modify the output? I can't seem to set a variable equal to
the output, but I need to do things like changing /n to <br>, and I
was hoping to create a blacklist to take out profanity.
Can I do something like this (this didn't work, but it describes what
I'm needing)?
$nntp->article($msgid,*STDOUT) =~ tr/\n/<br>/;
Thanks again,
Mike
------------------------------
Date: 4 Sep 2003 20:36:59 -0700
From: csdude@hotmail.com (Mike)
Subject: Re: View NG with Net::NNTP
Message-Id: <46cdc619.0309041936.2aa9a6f1@posting.google.com>
I posted about an hour ago, and just discovered that I have to ask
another question about this. Sorry about that!
I'm using a remote host for the final site, but I've been writing and
testing on my PC using localhost. The news server I'm using is through
my dial-up ISP, but the remote host doesn't offer a news server.
Based on this, once I upload to a final server, will I still be able
to retrieve and post through my ISP? If not, is there an alternative?
Thanks again,
Mike
------------------------------
Date: Thu, 4 Sep 2003 18:26:21 -0700
From: "Trent Curry" <tcurrey@no.no.no.i.said.no>
Subject: Re: What ever happened to comp.lang.perl ?
Message-Id: <bj8p00$pji$1@news.astound.net>
"Helgi Briem" <f_baggins80@hotmail.com> wrote in message
news:3f57599a.270998745@News.CIS.DFN.DE...
> On Thu, 4 Sep 2003 08:01:56 -0700, "Trent Curry"
> <tcurrey@no.no.no.i.said.no> wrote:
>
> >You truely are a silly bunch if you can't see that that
> >should of read "You are trying again", it is of matter
> >of fact, another semi common typo, which I am not the
> >first. But sure you are all pristine, perfect typists?
>
> You really are a funny little man, Manny. Every six
> months or so you come here with a few new names
> and fake e-mail addresses,
I haven't a clue where this came from, but it does not apply.
> throw a tantrum over
> something silly, then get tired and go away.
Excuse me? I'm not the one who as throwing a tantrum over a damn typo, you
and tad, onth are. Get the hell over it.
> What is your beef? Why do you keep coming back
> for more? You are so bad at hiding your identity
> that it is usually obvious in your first post.
** shakes head ** I have no desire in yours or anyone else's delusions.
Please leave me out of it. You got the wrong person. Simple as that.
------------------------------
Date: Thu, 4 Sep 2003 18:31:19 -0700
From: "Trent Curry" <tcurrey@no.no.no.i.said.no>
Subject: Re: What ever happened to comp.lang.perl ?
Message-Id: <bj8p9b$poa$1@news.astound.net>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnbleorq.6ko.tadmc@magna.augustmail.com...
> Trent Curry <tcurrey@no.no.no.i.said.no> wrote:
> > "Trent Curry" <tcurrey@no.no.no.i.said.no> wrote in message
> > news:bj7jai$f41$1@news.astound.net...
> >> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> >> news:bj6qjb$984$2@mamenchi.zrz.TU-Berlin.DE...
> >> > Trent Curry <tcurrey@no.no.no.i.said.no> wrote in
comp.lang.perl.misc:
>
> >> > > Rubbish. Complete rubbish. You are try again to miss label me with
non
> >> > ^^^^^
> >> >
> >> > Again, right? Oh boy, this is hard to pull off, isn't it?
> >>
> >> You make no sense.
>
>
> You missed the point.
>
>
> > You truely are a silly bunch if you can't see that that should of read
"You
> > are trying again"
>
>
> "again" implies that I did this to you before.
>
> I have never done this to Trent Curry before, I have done it
> to one of your other names. You can't keep straight what happened
> to which of your persona...
No, you moron, you tried to implicate me yesterday, and in another post you
were doing more of the same. Of course, if you weren't so busy wrongly going
after me maybe you would of seen that. I'm really getting tired of your
childish BS. You have no right to trying to frame any like you are doing. On
top of that you are mincing the facts like a piece of garlic like a
professional politician.
Please Kindly F'Off & leave me the hell alone.
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 5445
***************************************