[17382] in Perl-Users-Digest
Perl-Users Digest, Issue: 4804 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 3 11:10:25 2000
Date: Fri, 3 Nov 2000 08:10:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973267814-v9-i4804@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 3 Nov 2000 Volume: 9 Number: 4804
Today's topics:
perl and IRC <Sebastien.THOMAS@none.net>
Re: perl and IRC (Mark-Jason Dominus)
Re: Perl Question <bart.lateur@skynet.be>
Re: Perl style and module searches <elaine@chaos.wustl.edu>
Re: Perl style and module searches (Tom Christiansen)
Perl syntax and beyond (was: Re: Perl style and module <bart.lateur@skynet.be>
Problems Downloading a Web Page REMOVEdino@texas.net
Quick newbie question: Perl fork() and signals on NT? <davesisk@ipass.net>
Re: Reading a backslash in a variable? (Tad McClellan)
Re: Removing carriage returns from cgi (Ameen Dausha)
run compiled bytecode <mirvine555@yahoo.com>
running compiled bytecode <mirvine555@yahoo.com>
Re: script error <ksiddall@attcanada.net>
Re: SMS - text messaging <bart.lateur@skynet.be>
Re: String manipulation?? <james@NOSPAM.demon.co.uk>
Re: String manipulation?? (Tad McClellan)
Re: String manipulation?? (Anno Siegel)
Re: system command question <eric@urbanrage.com>
values of strings <daniel.hendrickx@alcatel.be>
Re: values of strings <josef.moellers@fujitsu-siemens.com>
Re: Want to process all files less than 24 hours old <bart.lateur@skynet.be>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 03 Nov 2000 12:08:32 +0100
From: Sebastien THOMAS <Sebastien.THOMAS@none.net>
Subject: perl and IRC
Message-Id: <3A029CB0.7625F37A@none.net>
Hi,
I would like to write a perl script that could sort :
-what are the channels used
-how many users in each
-what is the topic of each
like the result of a /list :)
I'me currently using the NET::IRC module, but it's not really defined
for this kind of stuff.
In fact all I've been able to do is to write the result in a file. I
can't use the result as an array. I don't know why nor what to do...
Maybe the best solution would be to open a socket directly and pass IRC
protocol through this ??
Meybe someone already have some piece of script I could use (for free :)
?
Here is my script :
----------------------------
#!/bin/perl
use strict;
use Net::IRC;
#
# Create the IRC and Connection objects
#
my $irc = new Net::IRC;
open(OUTF,">>channel.out") or dienice("Couldn't open file for writing:
$!");
flock(OUTF,2);
open(OUTFT,">>topic.out") or dienice("Couldn't open file for writing:
$!");
flock(OUTFT,2);
#print "Creating connection to IRC server...\n";
my $conn = $irc->newconn(Server => ($ARGV[0] || 'chat.freesbee.fr'),
Port => 6667,
Nick => 'listbot',
Ircname => 'listbot used to generate list.',
Username => 'listbot')
or die "listbot: Can't connect to IRC server.\n";
# What to do when the bot successfully connects.
sub on_connect {
my $self = shift;
$self->list();
$self->quit();
}
# Handles some messages you get when you connect
sub on_init {
my ($self, $event) = @_;
my (@args) = ($event->args);
shift (@args);
# print "*** @args\n";
}
sub on_list {
my ($self, $event) = @_;
my (@list, $channel) = ($event->args);
#print "channels on server: @list\n";
#print "$self->list()\n";
print OUTF "$list[1] $list[2]\n";
print OUTFT "$list[1] $list[3]\n";
}
# Change our nick if someone stole it.
sub on_nick_taken {
my ($self) = shift;
$self->nick(substr($self->nick, -1) . substr($self->nick, 0, 8));
}
$conn->add_global_handler([ 250,252,253,254,302,255 ], \&on_init);
$conn->add_global_handler(376, \&on_connect);
$conn->add_global_handler(433, \&on_nick_taken);
$conn->add_global_handler(322, \&on_list);
#print "starting...\n";
$irc->start;
---------------
--
_______________________________________________
Sebastien THOMAS none networks
System Engineer freesbee
geo:153, rue Saint-Denis, 75002 Paris, France
vox:+33 1 45 08 23 10 - fax:+33 1 45 08 25 29
mailto:sebastien.thomas@none.net
------------------------------
Date: Fri, 03 Nov 2000 15:46:05 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: perl and IRC
Message-Id: <3a02ddbc.1f43$399@news.op.net>
In article <3A029CB0.7625F37A@none.net>,
Sebastien THOMAS <Sebastien.THOMAS@none.net> wrote:
>I'me currently using the NET::IRC module, but it's not really defined
>for this kind of stuff.
Net::IRC has been abandoned. The developer is now working on
POE::Component::IRC. POE::Component::IRC is a lot more complete and
probably does what you want.
>Maybe the best solution would be to open a socket directly and pass IRC
>protocol through this ??
Maybe, but POE::Component::IRC already does that.
>Meybe someone already have some piece of script I could use (for free :)
POE::Component::IRC.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f|ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Fri, 03 Nov 2000 12:06:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl Question
Message-Id: <1ja50t0jrk4n07ojlv2kp7k9cgkr97fqi4@4ax.com>
James Taylor wrote:
>Errr, I think you have me confused with the original poster.
>You don't think I would choose such a silly subject line do you?
I was talking into an anonymous crowd. The OP must be somewhere in
there.
--
Bart.
------------------------------
Date: Fri, 03 Nov 2000 15:54:12 GMT
From: "Elaine Ashton" <elaine@chaos.wustl.edu>
Subject: Re: Perl style and module searches
Message-Id: <EcBM5.13452$AM5.253150@news1.nokia.com>
"Dave E" <dave_at_hm@hotmail.com> wrote in message
news:3A021193.6761027B@hotmail.com...
> http://perldoc.cpan.org, recommended by Elaine Ashton, seems to give me
more
> useful search results than http://search.cpan.org. At least on first
> test. Perldoc.com also looks quite interesting.
Each of the different search engines have their own strengths.
perldoc.cpan.org is a pointer to Randy Kobe's site which also has a
similar module searching engine at http://kobesearch.cpan.org/ So, like
anything, YMMV but wading through CPAN certainly is a lot easier than it
used to be.
e.
------------------------------
Date: 3 Nov 2000 09:02:02 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Perl style and module searches
Message-Id: <3a02e17a@cs.colorado.edu>
In article <EcBM5.13452$AM5.253150@news1.nokia.com>,
Elaine Ashton <elaine@chaos.wustl.edu> wrote:
>news:3A021193.6761027B@hotmail.com...
>> http://perldoc.cpan.org, recommended by Elaine Ashton, seems to give me
>more
>> useful search results than http://search.cpan.org. At least on first
>> test. Perldoc.com also looks quite interesting.
>
>Each of the different search engines have their own strengths.
But they all have the same weakness: they're flipping web crud.
This is onerous at best.
My new stuff does not suffer from this silliness, and is much more
featureful besides. However, it does not look for other people's
stuff on other systems, only documentation that comes from the
standard distribution or optional (perhaps CPAN) modules you've
installed.
--tom
------------------------------
Date: Fri, 03 Nov 2000 13:08:38 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Perl syntax and beyond (was: Re: Perl style and module searches)
Message-Id: <7qd50t48o4t7615f0cn20e3msokpg1807h@4ax.com>
Gwyn Judd wrote:
>If you read much of Larry
>Walls speeches you will note he emphasises that he designed Perl from
>the point of vies of a linguistics background. The whole point is that
>most human languages are not terribly logical or orthogonal or a whole
>heap of other words ending in 'al'. There really is more than one way to
>do it. It may make Perl harder to learn, but in the end the degree of
>expressiveness that you gain is immense. At the risk of sounding pompous
>I like to think of Perl as a language for programmers. A simple language
>such as java may be easier to learn but it is the equivalent of a
>language with seven verbs and 5 nouns ie. you have to do a lot of work
>to do anything with it. On the other hand Perl is like English, you get
>five words to express exactly the same thing :) Actually I think it's
>still not really "there" yet and I'd like to see it go even further,
>Perl 6 sounds promising in that respect.
That was not what was originally asked, but a very interesting sidetrack
anyway.
I must say, that in therory I'm all for orthogonality. But I've grown so
used to Perl, that I don't even *see* any more in what way it is
"awkward" when compared to other computer languages. Perl fits pretty
much like a glove (and that's no a "sperical" one ;-).
So, I'm curious, for examples in *what* way that Perl deviates from
normal programming languages, and what makes it more powerful. Regexes
are one example.
Gwyn, in what way would you like to see Perl go "even further"?
--
Bart.
------------------------------
Date: Fri, 03 Nov 2000 15:12:12 GMT
From: REMOVEdino@texas.net
Subject: Problems Downloading a Web Page
Message-Id: <3a02cf21.83051742@corp.supernews.com>
I am trying to learn Perl and the first thing I wanted to do was
download a Web page. The following:
use LWP::Simple;
getprint 'http://www.perl.com';
returns 500 Can't connect to http://www.perl.com:80 (Bad protocol
'tcp')
I'm using Active States's Win32 build on a Win NT networked machine.
The web browser program Lynx works so I should be able to get LWP to
work. If I cannot get the LWP to work I'll just use a Lynx dump, but
I was really hoping to use Perl w/o Lynx.
Thanks,
Dean
------------------------------
Date: Fri, 03 Nov 2000 14:18:43 GMT
From: "David Sisk" <davesisk@ipass.net>
Subject: Quick newbie question: Perl fork() and signals on NT?
Message-Id: <7PzM5.16263$%j.4901835@typhoon.southeast.rr.com>
Do the perl constructs like fork(), wait(), exec(), system(), and the signal
handling constructs work on NT as well as unix? I realize those don't exist
natively in NT, but does the Perl executable fabricate them? I need to
develop a process on NT, but I want to do it so that it will work on unix
because that's where it will be run eventually. Please post or email?
Regards,
Dave
------------------------------
Date: Fri, 3 Nov 2000 07:20:59 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reading a backslash in a variable?
Message-Id: <slrn905bdb.1qp.tadmc@magna.metronet.com>
On 3 Nov 2000 08:12:53 GMT, Christer <chho65@hotmail.com> wrote:
>s/\\/\\\\/go
The "o" is useless, and so it should not be there.
"o" is only useful for patterns that contain variables. It
is a red herring to confuse maintenance programmers to include
it when there are no variables in the pattern.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 03 Nov 2000 11:20:52 GMT
From: ameen @ dausha . net (Ameen Dausha)
Subject: Re: Removing carriage returns from cgi
Message-Id: <3a029ec0.29286143@news>
After reading your earlier post, I was again returned to the "Why
tr/// verses s///? I admit I'm still learning although Perl is my
bread and butter right now. The previous development efforts in my
shop are poor examples to follow and yet they are the examples I have.
Although, we have a lot of string issues as opposed to character
issues. Would that this were the case everywhere (that there were no
character issues). :-)
On Thu, 2 Nov 2000 23:18:17 -0500, tadmc@metronet.com (Tad McClellan)
spat:
>On Fri, 03 Nov 2000 03:37:55 GMT, Ameen Dausha <ameen@dausha.net> wrote:
>>The answer is:
>>
>>$mailingaddress =~ s/\r//sg;
>
>
>That is "an answer", but hardly a "good answer".
>
>The s///s option is a red herring to distract maintenance programmers.
>
>The s/// option only affects the dot character, and is therefore
>useless if there is no dot character in the pattern.
>
>
>s/// is for strings or patterns.
>
>tr/// is for characters.
>
>This is a "character problem".
>
>And tr///d is lots faster than s///g is.
>
>
>>The \r is the carriage return, part of the MS-DOS newline group
>>(\n\r).
>
>
>Errr, I believe that is incorrect as well. DOS line endings are
>marked by \r\n.
>
>
>>"perldoc perlr" I believe is what gives you the manpage on Regex.
>
>
>... and I think there is something wrong there too.
>
>
>[snip Jeopardy quoted text, which should have been enough of
> a clue to disregard the "answers" given.
>]
>
>--
> Tad McClellan SGML consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
Ben Wilson (a.k.a. Ameen, Last of the Dausha)
____________________________
-"Ever heard of Aristotle . . . Plato . . . Socrates?!"
-"Yes."
-"Morons!"
------------------------------
Date: Thu, 02 Nov 2000 05:29:03 +0500
From: "Mark Irvine" <mirvine555@yahoo.com>
Subject: run compiled bytecode
Message-Id: <8tuci5$o3t$1@dorito.esatclear.ie>
Hi,
I've compiled some perl bytecode with malcom Beatties complier. How do I
get it to run?
From the FAQ I found:
The resulting bytecode can be run with a special byteperl executable or (for non-main programs) be loaded via the byteload_fh
function in the B module.
Where do I get a special byteperl executable? I've searched CPAN, but
nothing showed.
Tahnks,
Mark Irvine
------------------------------
Date: Thu, 02 Nov 2000 05:19:02 +0500
From: "Mark Irvine" <mirvine555@yahoo.com>
Subject: running compiled bytecode
Message-Id: <8tubvc$nrn$4@dorito.esatclear.ie>
Hi,
I'm trying to compile some perl code to bytecode using Malcom Beatties
compiler. The compiler returns with an ok message, so how do I run
the bytecode?
At http://www.perl.com/pub/doc/manual/html/lib/B/Bytecode.html
i found:
The resulting bytecode can be run with a special byteperl executable or
(for non-main programs) be loaded via the byteload_fh
function in the B module.
Where can I find a special bytecode executable?
------------------------------
Date: Fri, 3 Nov 2000 05:49:52 -0800
From: "munch" <ksiddall@attcanada.net>
Subject: Re: script error
Message-Id: <gqzM5.84877$YG5.65212@tor-nn1.netcom.ca>
My sincere apologies.|
| Posting to a comp.lang group (i.e. a programming group) to talk about
| problems in a programs that you are simply wanting download and use
| rather than programs you are actually writing/debugging.
|
| --
| \\ ( )
| . _\\__[oo
| .__/ \\ /\@
| . l___\\
| # ll l\\
| ###LL LL\\
------------------------------
Date: Fri, 03 Nov 2000 13:57:56 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: SMS - text messaging
Message-Id: <13h50tk4sf3l08q6n6b1is96ma795g6d7h@4ax.com>
Steve wrote:
>Can anybody recommend a script that allows a user to
>send text messages from a website to a mobile phone.
This looks promising.
<http://search.cpan.org/search?dist=Net-SMS>
--
Bart.
------------------------------
Date: Fri, 3 Nov 2000 14:35:08 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: String manipulation??
Message-Id: <ant0314080b0fNdQ@oakseed.demon.co.uk>
In article <Pine.GSO.4.21.0011022136250.25313-100000@crusoe.crusoe.net>,
Jeff Pinyan <URL:mailto:jeffp@crusoe.net> wrote:
> [posted & mailed]
Actually, I wish you wouldn't.
I'd rather just read it once in this group.
> [Or else Tom Christiansen will eat me alive.]
Why would he do that then?
> On Nov 3, James Taylor wrote:
>
> > If the subroutine definition included a prototype of ($\@) then he would
> > not have to remember to put a \ in front @array each time. He could also
> > use Tom's clever typeglob assignment to avoid the messy dereference syntax
> > in the subroutine.
>
> Only if he used the non-& method of calling functions.
Is there any reason to use the &sub method these days?
> Once you use &, all prototype bets are off.
Do you mean to say that even one use of the &sub style call anywhere
in a Perl program renders *all* prototype definitions non-functional?
I thought the presence of an ampersand only affected the particular
call where it was used. If that's wrong, please let me know. Thanks.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Fri, 3 Nov 2000 08:50:49 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: String manipulation??
Message-Id: <slrn905glp.2gp.tadmc@magna.metronet.com>
On Fri, 3 Nov 2000 14:35:08 +0000, James Taylor
<james@NOSPAM.demon.co.uk> wrote:
>In article <Pine.GSO.4.21.0011022136250.25313-100000@crusoe.crusoe.net>,
>Jeff Pinyan <URL:mailto:jeffp@crusoe.net> wrote:
>> Once you use &, all prototype bets are off.
>
>Do you mean to say that even one use of the &sub style call anywhere
>in a Perl program renders *all* prototype definitions non-functional?
No.
>I thought the presence of an ampersand only affected the particular
>call where it was used.
Yes.
>If that's wrong, please let me know. Thanks.
<silence> :-)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 3 Nov 2000 15:31:41 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: String manipulation??
Message-Id: <8tulot$nor$1@lublin.zrz.tu-berlin.de>
James Taylor <james@NOSPAM.demon.co.uk> wrote in comp.lang.perl.misc:
[...]
> He could also
>use Tom's clever typeglob assignment to avoid the messy dereference syntax
>in the subroutine.
Tom's numerous merits are undebated, but I don't think this type of
aliasing is rightly attributed to him. It's been Perl folklore since
Perl 5 came out. I believe the primary purpose of providing the
ref-to-typeglob assignment was to enable selective aliasing, which
was sorely missing from Perl 4. A close second must have been the
ability to shortcut dereferencing when it piles up.
Anno
------------------------------
Date: Fri, 03 Nov 2000 08:26:08 -0600
From: eric <eric@urbanrage.com>
Subject: Re: system command question
Message-Id: <3A02CB00.82E86D26@urbanrage.com>
"Y. Wang" wrote:
>
> Hi,
>
> I have a part of code as follows
>
> ....
> $cmd="para parafile < $tmpinput > /dev/null";
> system("$cmd")==0 or die "Failed to do: $cmd\n";
> ....
>
> para program asks for parameter from tmpinput and write out in
> parafile. Since there are some interative information, e.g. Input N:
> I let those information go to /dev/null.
>
> When I use the same code, it runs well in "version 5.005_02 built for
> i86pc-solaris". But I got errors any time when I ran it on Red Hat
> 6.2. I tried two different RPMs in it, neither perl-5.00503-10.i386 nor
> perl-5.00503-12.i386 works. The error was due to nonzero was returned
> from system command.
>
> Can someone tell me how to solve this problem?
check para to see what the return value your getting means, it could be
somehting as simple as getting permission denied on the file it's trying
to create.
you need to shift the return value before you do anything with it.
$err = system($cmd);
$err =>> 8;
$! = $err; # normally this is not something you do
print "error was $err [$!]\n";
if para is passing on the system error that it got the $! line should
work, a lot of times programs don't though so it might not make sense.
Hope this helped,
Eric
eric@urbanrage.com
Brainbench MVP for Unix Programming
http://www.brainbench.com
------------------------------
Date: Fri, 03 Nov 2000 16:00:21 +0100
From: Danny Hendrickx <daniel.hendrickx@alcatel.be>
Subject: values of strings
Message-Id: <3A02D305.B82802CC@alcatel.be>
Hello,
I just split up a string in its individual characters. Now I would like
to print the hex-value of each character of that string, (sort of like
printf("%X",$a) in C, where $a would contain a character), but I can't
find the perl way to do this. Can anyone help me please.
--
Regards,
________________
________________________________________________\ /_____
CTXT XPT Team Leader BP8 Team 4 (Call Handling) \ /
SW-Engineering - Routing - VJ24 Hendrickx Danny
phone : +32-3-240 3916 ALCATEL TELECOM
fax : +32-3-240 9899 Fr.Wellesplein 1
mailto:daniel.hendrickx@alcatel.be 2018 Antwerp Belgium
______________________________________________________\ /___________
URL: http://www.se.bel.alcatel.be/CH_sector1/SS31/ \/
*********************************************************************
Every 0.2 seconds somewhere on Earth, a woman gives birth to a child.
We have to find that woman and stop her before it's too late.
*********************************************************************
------------------------------
Date: Fri, 03 Nov 2000 16:12:39 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: values of strings
Message-Id: <3A02D5E7.6C3C267@fujitsu-siemens.com>
Danny Hendrickx wrote:
> =
> Hello,
> =
> I just split up a string in its individual characters. Now I would like=
> to print the hex-value of each character of that string, (sort of like
> printf("%X",$a) in C, where $a would contain a character), but I can't
> find the perl way to do this. Can anyone help me please.
ord() is your friend.
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
------------------------------
Date: Fri, 03 Nov 2000 12:08:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Want to process all files less than 24 hours old
Message-Id: <fla50t4lopttl3k80so329gt9v0q3atee9@4ax.com>
Jerome O'Neil wrote:
>Now, Grasshopper, you're journey truley begins...
I wonder: is this a language error that a spell checker can catch?
--
Bart.
------------------------------
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 4804
**************************************