[26668] in Perl-Users-Digest
Perl-Users Digest, Issue: 8775 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 19 03:06:48 2005
Date: Mon, 19 Dec 2005 00:05:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 19 Dec 2005 Volume: 10 Number: 8775
Today's topics:
[ANNOUNCE] Emacs modules for Perl programming (Jari Aalto+mail.perl)
Re: Line number inconsistency <someone@example.com>
Socket operation crashes under HPUX&Solaris, but OK und <kalala@hotmail.com>
Re: What is the reason for Perl? robic0
Re: What is the reason for Perl? robic0
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Dec 2005 05:37:26 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: [ANNOUNCE] Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1134970488@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
Maintainer: Jari Aalto A T cante net
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs/XEmacs
o Unix:
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
o Unix Windows port (for Unix die-hards):
install http://www.cygwin.com/ which includes native Emacs 21.x.
and XEmacs port
o Pure Native Windows port
http://www.gnu.org/software/emacs/windows/ntemacs.html
ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe
o More Emacs resources at
http://tiny-tools.sourceforge.net/ => Emacs resource page
Emacs Perl Modules
Cperl -- Perl programming mode
http://math.berkeley.edu/~ilya/software/emacs/
by Ilya Zakharevich
CPerl is major mode for editing perl files. Also included in
latest Emacs, but newest version is at Ilya's site. Note that
the directrory at CPAN is out of date:
http://www.cpan.org/modules/by-authors/id/ILYAZ/cperl-mode/
Compared to default `perl-mode' that comes with Emacs, this
one has more features.
TinyPerl -- Perl related utilities
http://tiny-tools.sourceforge.net/
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Grep through all Perl manpages (.pod)
o Follow POD references e.g. [perlre] to next pod with RETURN
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o Update `$VERSION' variable with YYYY.MMDD on save.
o Load source code into Emacs, like Devel::DProf.pm
o Prepare script (version numbering) and Upload it to PAUSE
o Generate autoload STUBS (Devel::SelfStubber) for you
Perl Module (.pm)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in Tiny Tools Kit]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
how to set up dattabases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to to do the search, You can adjust
recursive grep options, set search case sensitivity, add user grep
options etc.
You can find latest `igrep.el' module at
<http://groups.google.com/groups?group=gnu.emacs.sources> The
maintainer is Jefin Rodgers <kevinr@ihs.com>.
TinyCompile -- To Browse grep results in Emacs *compile* buffer
TinyCompile is a minor mode for *compile* buffer from where
you can collapse unwanted lines or shorten file URLs:
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: Mon, 19 Dec 2005 06:02:40 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Line number inconsistency
Message-Id: <42spf.9106$ic1.8688@edtnps90>
Daniel Pfeiffer wrote:
> I recently stumbled over a design bug, and there doesn't even seem to be
> a clear warning about it in the docs: columns (e.g. in strings), like
> all indices, count from 0, but file lines count from 1.
Get one of your non-programmer friends to open a document in their favourite
text editor and then tell them to go to line 0.
> That leads to absurd equivalences like
(In your opinion.)
> 5..7 and print while <>;
>
> does the same as
>
> print +(<>)[4..6];
It prints the same lines but it doesn't do the same thing.
> Worse, if you do
>
> 0..9 and print while <>;
>
> that will not emulate head, instead the flip-flop will never become true.
Probably because $. can never be equal to 0.
> I guess it's too late to make line numbers behave, but there should be a
> big warning in the docs!
Then I guess you could also teach everyone in the world that their documents
now start at line zero instead of what they assumed is actually line one.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 19 Dec 2005 15:47:54 +0800
From: kalala <kalala@hotmail.com>
Subject: Socket operation crashes under HPUX&Solaris, but OK under Windows
Message-Id: <43A665AA.F0EE192B@hotmail.com>
Socket operation crashes under HPUX&Solaris, but OK under Windows
I am a perl newbie. Here's a problem annoying me!
I am writing a TCP server(under Solaris). Everything seems OK: I can
telnet to it, and can see
the text sent by the server;But if I quit the telnet window, the TCP
server will crash silently,
without any prompt. I tested it under HPUX & Windows2000 to find the
reason, and find it worked under
windows2000, but still failed under HPUX.
I put codes below:
#!/usr/bin/perl
my $tcpport = 5050;
use IO::Socket;
use Socket;
socket(TCPSERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
#build up socket address
if(0 == bind(TCPSERVER, sockaddr_in($tcpport,INADDR_ANY)))
{
die "Can not bind tcp server:$!, exiting...";
}
if(0 == listen(TCPSERVER,SOMAXCONN))
{
die "Can not listen on port $tcpport : $!";
}
#main loop
while(1)
{
sleep(0.1);
my $client_address = accept(CLIENT, TCPSERVER);
if(defined($client_address))
{
#a client connected.
CLIENT->autoflush(1);
my $counter = 0;
while(1)
{
$counter ++;
sleep(2);
$line = "Looping $counter... ";
print("$line"."\n");
my $retval = print CLIENT $line."\n";
print("print retval:$retval.\n");
if(!defined($retval))
{
#the peer socket may shutdown
close(CLIENT);
print "Exit loop because CLIENT error\n";
last;
}
}
}
}
Under windows 2000, the output looks like that(quit the telnet
client during test):
Looping 1...
print retval:1.
Looping 2...
print retval:1.
Looping 3...
print retval:1.
Looping 4...
print retval:1.
Exit loop because CLIENT error
Looping 1...
print retval:1.
Looping 2...
print retval:1.
Looping 3...
Exit loop because CLIENT error
Under HPUX or Solaris, the output turs to:
Looping 1...
print retval:1.
Looping 2...
print retval:1.
Looping 3...
print retval:1.
Looping 4...
print retval:.
Then it crashes.
The environment:
Windows 2000, perl5.6.0
HPUX, perl5.8,perl5.6.1,perl5.005_02
Solaris8, perl5.005_03
Any help? Thanks in advance!
------------------------------
Date: Sun, 18 Dec 2005 18:30:06 -0800
From: robic0
Subject: Re: What is the reason for Perl?
Message-Id: <to6cq1tm6l4r7e73d57p0j8jevufo584il@4ax.com>
On Sat, 17 Dec 2005 06:59:07 -0600, "Eric J. Roode"
<sdn.girths00869@zoemail.net> wrote:
>robic0 wrote in news:t5d7q15ishiomte1ee61t8nucnh9j5ibt5@4ax.com:
>
>> On Fri, 16 Dec 2005 13:36:37 +0100, Erwin Moller
>[...]
>>>Have a nice life.
>>>
>>>Erwin Moller
>>
>> Who in the fuck are you asshole?
>
>It's nice to see such an intellectual comeback.
Who's trolling now?
------------------------------
Date: Sun, 18 Dec 2005 18:32:42 -0800
From: robic0
Subject: Re: What is the reason for Perl?
Message-Id: <pr6cq1t0hvj496521gt97jb4sj9fhe11l0@4ax.com>
On Mon, 12 Dec 2005 17:03:35 -0600, "Eric J. Roode"
<sdn.girths00869@zoemail.net> wrote:
>John Bokma <john@castleamber.com> wrote in
>news:Xns972AA09354FA1castleamber@130.133.1.4:
>
>> "Eric J. Roode" <sdn.girths00869@zoemail.net> wrote:
>>
>>> John Bokma <john@castleamber.com> wrote in
>>> news:Xns972A92C699419castleamber@130.133.1.4:
>>>
>[...]
>>> Only in that it lacks some niceties that more modern languages (like
>>> Perl, or Java, or C#) provide, such as exceptions.
>>
>> Isn't there one (or even more) library that makes exceptions available
>> in C?
>
>Not that I've seen. I don't see how it could be implemented. Of course,
>I may be missing something.
>
>
>>> C's loops are unlabeled, meaning that you can only break or continue
>>> out of the innermost one.
>>
>> goto LABEL?
>> return;
>
>You can do anything with goto. Doesn't mean it's a lovely control
>structure.
>
>>>
>>> C has no exception mechanism.
>>
>> nor does Perl for that matter, eval and die is not that different from
>> longjmp. However, with both C and Perl you can use a library to make
>> things easier.
>
>eval and die are tons different from setjmp/longjump.
>
>>
>>> C gives no information about the number
>>
>> yes it does.
>
>No, it doesn't.
>
>>> Strings auto-extend in Perl. You cannot overrun a buffer in Perl.
>>
>> Aren't there libraries that do *exactly* the same for C / C++?
>
>Dunno. Can you point to one that does so for C?
>
>>
>>> Perl makes it a breeze to join strings,
>>
>> such a library might have a join, a split.
>>
>>> split them, interpolate
>>> variables into them,
>>
>> sprintf.
>
>Sure, sprintf exists. You can't tell me it's a simple or easy to use as,
>say $foo = "$bar $baz{a}{b} $quux[5]";
>
>
>>> perform pattern matching and replacement upon
>>> them,
>>
>> libraries
>>
>>> have multi-line strings, read them from files, I could go on and
>>> on.
>>
>> Yup, all this can be found in libraries for C, C++, Java, etc.
>
>No library can make C or C++ support multi-line strings. Try this in C:
>
> strcpy (var, "This string has
>a newline in it");
>
>or:
>
> strcpy (var, <<END_OF_STRING);
>...
>END_OF_STRING
>
>>> You can _do_ all of these things in C or C++, but the equivalent code
>>> is longer
>>
>> I doubt it.
>
>Then you don't know what you're talking about.
>
>>> you can add methods at run-time as needed, you can handle any unknown
>>> methods via AUTOLOAD, you can tell who called you, and with what
>>> arguments, you can examine your own hierarchy, etc. Perl provides
>>> closures; neither C nor C++ have anything like those.
>>
>> The question is: do you need those all the time? Moreover, the things
>> you do with, for example closures, are those not work arounds (now and
>> then) for limitations Perl has, but say C++ not?
>
>Do you need those all the time? Of course not. I don't need wire
>strippers all the time, but they're in my toolkit, and using a knife to
>strip insulation off a wire is tedious and dangerous.
>
>I don't see how closures are a workaround for limitations perl has,
>except possibly in the sense of information hiding. Closures are
>probably never necessary, but they make a bunch of problems easier to
>solve. There have been times when I've wished for a closure in C.
>
>>> In Perl, you can write a function:
>>>
>>> sub add_args
>>> {
>>> my ($arg1, $arg2) = @_;
>>> unless (UNIVERSAL::can($arg1, 'add')) {
>>> die "Can't add $arg1 and $arg2";
>>> }
>>> return $arg1->add($arg2);
>>> }
>>>
>>> and it will add any arguments, of any type, whether declared at
>>> compile- time or not. The only major deficiency there is that it
>>> won't add any built-in types. Writing such a universal function in
>>> C++ is pretty much impossible.
>>
>> No it isn't. Just create your own Universal class, and let everything
>> that adds inherit from it.
>
>That only works if all of the libraries (including those from other
>vendors) that you are using inherit from _your_ Universal class, which of
>course they don't. In Perl, polymorphism simply requires that methods
>have the same name. In C++, it requires that they have the same
>ancestor.
>
>C++'s solution is not *wrong* (nor is Perl's *right*); they're just
>*different*. I happen to prefer Perl's, and have used it to good effect.
>C++'s is more limited, however.
Nobody read your post, i just gave it a 10 second look.
If a tree falls in the woods, how do you know it fell if
you didn't hear it?
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 8775
***************************************