[21863] in Perl-Users-Digest
Perl-Users Digest, Issue: 4067 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 5 11:07:40 2002
Date: Tue, 5 Nov 2002 08:05:11 -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 Tue, 5 Nov 2002 Volume: 10 Number: 4067
Today's topics:
[ANNOUNCE] CGI::Widget::Tabs v1.3 <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Re: A vision for Parrot <graham.lee@wadham.ox.ac.uk>
Re: A vision for Parrot (Cameron Laird)
Re: A vision for Parrot <graham.lee@wadham.ox.ac.uk>
Re: A vision for Parrot (Cameron Laird)
Re: A vision for Parrot <graham.lee@wadham.ox.ac.uk>
Bioperl install proxy prob (Brian Smith)
Re: Block buffered web server? <h.b.furuseth@usit.uio.no>
Complex search/replace (H.Wiersema)
Re: Flash sendXML with CGI <rrobbins@kolbnetworks.com>
fork() and socket? edgue@web.de
h2ph and C enum (Stephen J. Smith)
Re: How to open browser window without browser menubar news@roaima.freeserve.co.uk
HTTPS Post <rajkothary@hotmail.com>
HTTPS Post <rajkothary@hotmail.com>
Re: HTTPS Post <bart.lateur@pandora.be>
Re: Limit output of examine (x) and return (r) in debug (tî'pô)
Re: Net::Telnet - is there a way to ignore a connection news@roaima.freeserve.co.uk
Re: Perl -e "print qq! Tips and Tricks !" <zzapper@ntlworld.com>
Re: Perl and large text files (Helgi Briem)
Re: Perl and large text files <s_grazzini@hotmail.com>
Re: perl nslookup <root@nuddelaug.jackal-net.at>
style pet peeve: qw() for single words? <noemail@nowhere.net>
Re: style pet peeve: qw() for single words? <joe+usenet@sunstarsys.com>
Re: style pet peeve: qw() for single words? <usenet@tinita.de>
Re: style pet peeve: qw() for single words? <smurch@no.spam>
Re: unwanted white space when I write to files <garry@ifr.zvolve.net>
Re: Why is DESTROY called in scalar context? (tî'pô)
Re: ||= |= <cyberjeff@sprintmail.com>
Re: ||= |= <bart.lateur@pandora.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 05 Nov 2002 14:35:48 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: [ANNOUNCE] CGI::Widget::Tabs v1.3
Message-Id: <newscache$o3v35h$57p$1@news.emea.compuware.com>
Announcement for CGI::Widget::Tabs, version 1.3.
Enclosed is the README for reference.
The changes are listed at the bottom of this message.
Best regards,
Koos Pol
CGI::Widget::Tabs
=================
DESCRIPTION
CGI::Widget::Tabs lets you simulate tab widgets in HTML. You
could benefit from a tab widget if you want to serve only one
page. Depending on the tab selected you fetch and display the
underlying data. There are two main reasons for taking this
approach:
1. For the end user not to be directed to YAL or YAP (yet another
link / yet another page), but keep it all together: The single
point of entry paradigm.
2. For the Perl hacker to generate and display multiple data
sources within the same script environment.
As an example the following tabs could be used on a web page for
someone's spotting hobby:
________ ________ _____________
/ Planes \ / Trains \ / Automobiles \
-----------------------------------------------------
The nice thing about CGI::Widget::Tabs is that the tabs know
their internal state. So you can ask a tab for instance which tab
heading has been clicked by the user. This way you get instant
feedback.
DOCUMENTATION
The documentation is included in the module. You can read it's
manpage after installation with `perldoc CGI::Widget::Tabs'. If
you prefer you can read the documentation before installation
with `perldoc ./Tabs.pm'
DEPENDENCIES
- CGI, CGI::Minimal or another CGI "object broker"
with the param() method and with similar behaviour
- HTML::Entities
- URI
- A CSS style sheet for the tabs markup
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
DOWNLOAD
The latest version of CGI::Widget::Tabs is always available from
the CGI::Widget::Tabs homepage at:
http://users.raketnet.nl/koos_pol/en/Tabs/index.html
COPYRIGHT AND LICENCE
Copyright (c) 2002 Koos Pol. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
CHANGES
These changes are against the previous version. For a complete
history log, see the file 'CHANGES' in the distribution.
1.3 (2002-11-12)
----------------
Continuous discussions with Sagar Shah <sagarshah@softhome.net>
had made me (finally) realize that CGI::Widget::Tabs can't be
extended without serious design change. (Is everybody so
stubborn, or is it just me?) Well, here it is Sagar :-)
- Added an OO interface as a basis for future extensions of tab
headings.
- OO headings can be configured with the new methods:
text() HTML escaped heading text
raw_text() HTML unescaped heading text
key() Value to be used as CGI query param value
url() Redirection URL
- Documentation additions, changes and fixes.
- Small change to the layout of the HTML table displaying the
widget
- The test script (`make test') now supports both CGI and
CGI::Minimal
------------------------------
Date: Tue, 05 Nov 2002 12:20:05 +0000
From: Frodo Morris <graham.lee@wadham.ox.ac.uk>
Subject: Re: A vision for Parrot
Message-Id: <aq8cut$4pr$1@news.ox.ac.uk>
Daniel Pfeiffer wrote:
> Hi,
> Apache would essentially have a mod_parrot. Maybe, if this can be tested very hard, we'd even have a Parrot kernel module for all Unices supporting that. Then exec() could perform compiled scripts right away, like machine code :-)
Gah! Scary line-wraps!
Anyway, I would have thought that a more platform-independent version of
this would be, say, a parrotd, which sits on top of the kernel,
intercepts calls to exec() bytecode and spawns the relevant processes.
I may be wrong. This parrotd system would also help in projects like
Beowulfs (although why you'd be using byte-compiled languages in
parallel computing is beyond me), because you could use inetd or similar
to spawn a parrot when data was received on a certain port.
Just my £0.02
--
FM
------------------------------
Date: Tue, 05 Nov 2002 12:45:52 -0000
From: claird@lairds.com (Cameron Laird)
Subject: Re: A vision for Parrot
Message-Id: <usffc087vtip40@corp.supernews.com>
In article <aq8cut$4pr$1@news.ox.ac.uk>, Frodo Morris <""> wrote:
.
.
.
>Beowulfs (although why you'd be using byte-compiled languages in
>parallel computing is beyond me), because you could use inetd or similar
.
.
.
To catch up with the Javans.
--
Cameron Laird <Cameron@Lairds.com>
Business: http://www.Phaseit.net
Personal: http://phaseit.net/claird/home.html
------------------------------
Date: Tue, 05 Nov 2002 13:17:09 +0000
From: Frodo Morris <graham.lee@wadham.ox.ac.uk>
Subject: Re: A vision for Parrot
Message-Id: <aq8g9u$6c7$1@news.ox.ac.uk>
Cameron Laird wrote:
> In article <aq8cut$4pr$1@news.ox.ac.uk>, Frodo Morris <""> wrote:
> .
> .
> .
>
>>Beowulfs (although why you'd be using byte-compiled languages in
>>parallel computing is beyond me), because you could use inetd or similar
>
> .
> .
> .
> To catch up with the Javans.
Actually, I just thought of a reason! No, me miss! Me!!!
<cough>
How cool would it be to just set up a computer with a listening parrotd
and DHCP client, plug it in to the Beowulf and have it automagically
recognised as a node and delegated tasks?
I have been thinking quite a bit about cross-platform Beowulfing
recently. My initial idea was to set up an rlogin or something on the
node machines, and have the Apple (that's what I call the conducting
machine: "Apple" because it sends Jobs away, does nothing for a while
then gets Jobs back :-) distribute the source code for the node service
and job processor, configure and build the code, then log out and use
the new node as normal. This would be faster (provided the building
didn't fall over) as Beowulfs go, but less secure and probably harder to
set up.
Comments [rational variety preferred]?
--
FM
------------------------------
Date: Tue, 05 Nov 2002 13:36:51 -0000
From: claird@lairds.com (Cameron Laird)
Subject: Re: A vision for Parrot
Message-Id: <usfibjb72aq0d7@corp.supernews.com>
In article <aq8g9u$6c7$1@news.ox.ac.uk>, Frodo Morris <""> wrote:
.
.
.
>How cool would it be to just set up a computer with a listening parrotd
>and DHCP client, plug it in to the Beowulf and have it automagically
>recognised as a node and delegated tasks?
>I have been thinking quite a bit about cross-platform Beowulfing
>recently. My initial idea was to set up an rlogin or something on the
>node machines, and have the Apple (that's what I call the conducting
>machine: "Apple" because it sends Jobs away, does nothing for a while
>then gets Jobs back :-) distribute the source code for the node service
>and job processor, configure and build the code, then log out and use
>the new node as normal. This would be faster (provided the building
>didn't fall over) as Beowulfs go, but less secure and probably harder to
>set up.
.
.
.
Work on such schemes is already underway.
Security is a *hard* problem.
--
Cameron Laird <Cameron@Lairds.com>
Business: http://www.Phaseit.net
Personal: http://phaseit.net/claird/home.html
------------------------------
Date: Tue, 05 Nov 2002 14:43:07 +0000
From: Frodo Morris <graham.lee@wadham.ox.ac.uk>
Subject: Re: A vision for Parrot
Message-Id: <aq8lb1$8mq$1@news.ox.ac.uk>
Cameron Laird wrote:
> In article <aq8g9u$6c7$1@news.ox.ac.uk>, Frodo Morris <""> wrote:
> .
> .
> .
>
>>How cool would it be to just set up a computer with a listening parrotd
>>and DHCP client, plug it in to the Beowulf and have it automagically
>>recognised as a node and delegated tasks?
>>I have been thinking quite a bit about cross-platform Beowulfing
>>recently. My initial idea was to set up an rlogin or something on the
>>node machines, and have the Apple (that's what I call the conducting
>>machine: "Apple" because it sends Jobs away, does nothing for a while
>>then gets Jobs back :-) distribute the source code for the node service
>>and job processor, configure and build the code, then log out and use
>>the new node as normal. This would be faster (provided the building
>>didn't fall over) as Beowulfs go, but less secure and probably harder to
>>set up.
>
> .
> .
> .
> Work on such schemes is already underway.
>
> Security is a *hard* problem.
Curses! You stole my idea :-) I see what you mean about security being
a problem...
--
FM
------------------------------
Date: 5 Nov 2002 01:41:34 -0800
From: B.Smith@organon.co.uk (Brian Smith)
Subject: Bioperl install proxy prob
Message-Id: <a2190251.0211050141.20f29de0@posting.google.com>
Hi,
Im having a bit of a problem when trying to install bioperl.
During the make test the following occurs:-
############################################################################
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/AAChange................ok
t/AAReverseMutate.........ok
t/AlignIO.................ok
t/Allele..................ok
t/Alphabet................ok
t/Annotation..............ok
t/Biblio..................ok
t/Biblio_biofetch.........ok 3/13
-------------------- WARNING ---------------------
MSG: 500 (Internal Server Error) Can't connect to www.ebi.ac.uk:80
(Bad hostname 'www.ebi.ac.uk')
Client-Date: Tue, 05 Nov 2002 22:50:49 GMT
---------------------------------------------------
Warning: Couldn't connect to BioFetch server with Bio::DB::Medline.pm!
t/Biblio_biofetch.........ok 14/13
############################################################################
And so on-
I have set my environment variable to point to my proxy and using the
tests in libwww and libnet all is well and I can get access to the
outside world.
It appears that env_proxy variable is not being picked up in
LWP::UserAgent.
When I generate scripts using:-
############################################################
my $ua = new LWP::UserAgent;
$ua->proxy('http', 'http://gatekeeper.xxx.xxxxx.xx:80/');
$ua->no_proxy('xxx.xxxxx.xx');
$ua->timeout(900);
############################################################
All is well and I can get to the outside world.
Can anyone advise on why or how to force the LWP::UserAgent to use the
proxy environment variables?
Many thanks,
Brian
Operating system:Linux 2.4.2-2 Redhat 7.3
Modules:bioperl-1.0.2 libnet-1.12 libwww-perl-5.65
------------------------------
Date: 05 Nov 2002 13:26:41 +0100
From: Hallvard B Furuseth <h.b.furuseth@usit.uio.no>
Subject: Re: Block buffered web server?
Message-Id: <HBF.20021105ujjl@bombur.uio.no>
mjd@plover.com (Mark Jason Dominus) writes:
> Unix read semantics *never* hang on an incomplete block.
> They always return the partial block immediately.
>
> read() only blocks when there is *no* data available.
Oh, I get it. read() returns the incomplete block, and then the
stdio call notices that it doesn't need to read any more so it
doesn't do any more buffering.
> That said, I imagine that if you were to make a request to the server
> whose HTTP header was exactly one block long, the server would get
> stuck trying to read the 'rest' of the header.
I don't think so. The header ends with a blank line. If that blank
line has not been received yet, the server _should_ wait for it.
If it has been seen, it won't need to read any more.
--
Hallvard
------------------------------
Date: 5 Nov 2002 06:32:50 -0800
From: h.wiersema@dbr.agro.nl (H.Wiersema)
Subject: Complex search/replace
Message-Id: <c990df5a.0211050632.2c5ce2cf@posting.google.com>
*,
I've a sql script to create lots of objects in a database. The format
of the script looks like this:
...
create table ABC
column1 varchar2(10),
column2 varchar2(10),
..
columnN varchar2(20)
tablespace UNKNOWN
/
create table DEF
column1 varchar2(20),
column2 varchar2(20),
..
columnN varchar2(30)
tablespace UNKNOWN
/
create table GHI
column1 varchar2(20),
column2 varchar2(10),
..
columnN varchar2(20)
tablespace UNKNOWN
/
...
etc etc!
I want to make a (sed|awk|perl) script that is able to grep (for
example) the 'DEF' object create clause, then catch the
'tablespace'occurence of that clause. Then replace the tablespacename
after 'tablespace' by another tablespacename. The name of the
tablespace is the script above is not known, so I cant search for the
name. Too make it, perhaps, more clear:
create table DEF <1> Grep on this object
column1 varchar2(20),
column2 varchar2(20),
..
columnN varchar2(30)
tablespace NEWNAME <2> Something like
/^tablespace/s/$2/$NEW_NAME/
/
Does anyone can give me a hint how to programm this in sed|awk|perl ?
kind regards,
H.Wiersema
------------------------------
Date: Tue, 5 Nov 2002 10:37:44 -0500
From: "Robert Robbins" <rrobbins@kolbnetworks.com>
Subject: Re: Flash sendXML with CGI
Message-Id: <usfpdgcq61tn50@corp.supernews.com>
$s = $query->header();
print $s . "\n";
Only returns "Content-Type: text/html; charset=ISO-8859-1"
print $ENV{"ALL_HTTP"},"<br>\n";
Also fails to return the raw post data I'm looking for.
"Andras Malatinszky" <nobody@dev.null> wrote in message
news:3DC6E35F.6080809@dev.null...
>
>
> Andras Malatinszky wrote:
>
> >
> >
> > Robert Robbins wrote:
> >
> >> Hello Perl Programmers,
> >>
> >> I am trying to write a Perl script that reads the XML sent by
> >> Flash using its XML.send method. The XML.send uses the
> >> content type text/xml and sends the data using POST. I've
> >> tried the CGI.pm and cgi-lib.pl. The cgi-lib.pl script won't
> >> work with this content type and the CGI.pm does not provide
> >> a method for getting the raw post data. I tried $q->param('raw')
> >> but this did not work. An ASP script can successfully
> >> get the XML using:
> >>
> >> Response.BinaryWrite Request.BinaryRead(Request.TotalBytes)
> >>
> >> And PHP has the $GLOBALS["HTTP_RAW_POST_DATA"]
> >> global variable. I need to do this in Perl.
> >>
> >> Robert Robbins
> >
> >
> >
> > I have no Flash, so I may be way off base, but a simple script like
> >
> > #!/usr/bin/perl -w
> > use strict;
> > use CGI;
> > my $message=<STDIN>;
> > my $q=new CGI;
> > print $q->header();
> > print $message;
> >
> > will parrot back everything you have sent to it via the POST method.
> >
> > I hope that helps.
> >
> >
> >
>
>
> OK, maybe we should have @message instead of $message in both instances...
>
> Like I said, this is untested.
>
>
------------------------------
Date: Tue, 05 Nov 2002 16:37:21 +0100
From: edgue@web.de
Subject: fork() and socket?
Message-Id: <3DC7E5B1.9080404@web.de>
Hi folks,
My application has to communicate with a server.
So it creates a IO::Socket::INET on startup that
establishes a TCP connection to the server. Later
on my application sends/reads data from that socket.
Unfortunately I need to do some things in parallel;
therefore I have to fork() at some point in time.
Now something strange happens:
- on W2K with ActiveState Perl 5.6.1 everything
works fine - parent and child process are able
to communicate using the TCP connection.
- on OS/2 with a Perl 5.7.3 built, the same code
fails. To me it looks like parent/child process
are really working on the _SAME_ socket object.
So the data that is read from the socket looks
"corrupted" immediately.
I wrote some debugging code - the child process
runs fine if it avoids to use the TCP connection ...
But my child process needs to send some data,
otherwise it is useless to me.
I guess one solution would be to open a completely
new connection for the child process to the server;
but this would require us to change the server, too.
Do you have better ideas?
Is there a way to make my perl socket code "reentrant"?
And why does it work on windows, anyway?
regards,
eg
------------------------------
Date: 5 Nov 2002 08:01:49 -0800
From: khadrin@hotmail.com (Stephen J. Smith)
Subject: h2ph and C enum
Message-Id: <264a5c2e.0211050801.58c7f0f@posting.google.com>
I am using a distribution of perl from ActiveState on
Windows NT.
D:\src\foo>perl -v
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 633 provided by ActiveState Corp. http://www.ActiveState.com
Built 21:33:05 Jun 17 2002
<snip>
It seems that h2ph only handles enum definitions if the
opening brace occurs on the same line as the keyword
enum and the enum tag:
D:\src\foo>type foo.h
enum Foo
{
fooEnum /* won't show up */
};
enum Bar {
barEnum /* will show up */
};
D:\src\foo>h2ph -d . foo.h
foo.h -> foo.ph
D:\src\foo>type foo.ph
require '_h2ph_pre.ph';
eval("sub barEnum () { 0; }") unless defined(&barEnum);
1;
D:\src\foo>
Also, the generated file _h2ph_pre.ph does not return true:
D:\src\foo>type _h2ph_pre.ph
# This file was created by h2ph version 2
D:\src\foo>
I would gladly use h2xs, but after reading the documentation
and experimenting a bit, I believe it does nothing with
the enum definitions in a header file.
The workaround that will allow me to use h2ph as I want is
easy, but usually when I encounter problems such as this
there is something I am not understanding.
-Stephen
------------------------------
Date: Tue, 5 Nov 2002 09:40:01 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: How to open browser window without browser menubar, toobar, etc.
Message-Id: <hl38qa.1o8.ln@moldev.cmagroup.co.uk>
Jerry <jgrant1001@hotmail.com> wrote:
> I want to send a response to a new pop-up browser window with no
> menubar, toolbar, location features.
> This is easy to do in the client browser with javascript using
> window.open but how is it done in perl?
In the same way that you do it with any other scripting language. Work
out what HTML and/or ECMA-Script you need to generate, first.
This line's wrong. The character sequence "\n\n" won't work under all
circumstances. If you use the CGI module instead it will get this right
all the time.
> print "Content-type: text/html\n\n";
use CGI qw/:standard/;
print header;
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Tue, 5 Nov 2002 14:20:17 -0000
From: "Raj" <rajkothary@hotmail.com>
Subject: HTTPS Post
Message-Id: <aq8k31$jpn$1$8302bc10@news.demon.co.uk>
Hi,
I need to be able to send data to a HTTPS site using the above "protocol"
(if it is a valid name for what I need to do).
Can anyone provide any test programs on how to acheive this or point me in
the right direction? It will be XML data I am interested in posting.
Thanks you in advance for any help you can provide.
Kind regards,
Raj
------------------------------
Date: Tue, 5 Nov 2002 15:38:59 -0000
From: "Raj" <rajkothary@hotmail.com>
Subject: HTTPS Post
Message-Id: <aq8omp$63g$1$8300dec7@news.demon.co.uk>
(Apologies in advance if this has been received, but I had an error at my
end and have not seen this post appear).
Hi,
I need to be able to send data to a HTTPS site using the above "protocol"
(if it is a valid name for what I need to do).
Can anyone provide any test programs on how to acheive this or point me in
the right direction? It will be XML data I am interested in posting.
Thank you for any help you can provide.
Kind regards,
Raj
------------------------------
Date: Tue, 05 Nov 2002 15:42:29 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: HTTPS Post
Message-Id: <dgpfsu4p9br0bc2g1pdru9mqqg6lc43hlu@4ax.com>
Raj wrote:
>I need to be able to send data to a HTTPS site using the above "protocol"
>(if it is a valid name for what I need to do).
>
>Can anyone provide any test programs on how to acheive this or point me in
>the right direction? It will be XML data I am interested in posting.
Check out anything in LWP (like lwpcook). I think it includes support
for HTTPS as well. At least, there's a module LWP::Protocol::https, so I
can't be completely off. :-)
--
Bart.
------------------------------
Date: Tue, 05 Nov 2002 10:09:41 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Limit output of examine (x) and return (r) in debugger.
Message-Id: <p5vesug3b964alh3jfklh04lfrgo088q1v@4ax.com>
Peter Scott bravely attempted to attach 11 electrodes of knowledge to
the nipples of comp.lang.perl.misc by saying:
>In article <u1m9suk8qau2cvode003mcjphukscgv97e@4ax.com>,
> "Teh (tî'pô)" <teh@mindless.com> writes:
>>I hope this isn't a FAQ, but I can't figure out how to download
>>specific files from perl 5.8 without downloading the whole thing.
>
>http://search.cpan.org/src/JHI/perl-5.8.0/lib/perl5db.pl
>http://search.cpan.org/src/JHI/perl-5.8.0/lib/dumpvar.pl
Thank you.
------------------------------
Date: Tue, 5 Nov 2002 09:35:47 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: Net::Telnet - is there a way to ignore a connection that timed out?
Message-Id: <jd38qa.1o8.ln@moldev.cmagroup.co.uk>
Christian Caron <nospam@nospam.org> wrote:
> But, if the other computer is turned off, then the Telnet connection times
> out and the script ends (my webserver returns a 500 Server Error).
This usually means your script has printed something unexpected
(i.e. before the script headers). You need to run the script from the
command line to determine what that is - and/or look at the error log.
> My
> question is: is it possible to tell the script to continue _anyway_ and
> print an empty variable instead of stopping?
It depends what the error message is. The following will execute the
bit inside the if() only if the Net::Telnet module sucessfully connected.
$t = Net::Telnet->new(...);
if (defined $t) {
# Do some stuff with the connection handle
}
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Tue, 05 Nov 2002 10:01:25 +0000
From: zzapper <zzapper@ntlworld.com>
Subject: Re: Perl -e "print qq! Tips and Tricks !"
Message-Id: <ti5fsu4fd28rgg6afpu9f11hn2kt1ll4nr@4ax.com>
On Tue, 5 Nov 2002 06:34:00 +0000 (UTC), "David H. Adler"
<dha@panix2.panix.com> wrote:
>
>
>I don't know... one of my favorite JAPH moments was during a talk on
>them where Abigail said "The question here is not what this does.
>That's obvious - it prints 'Just Another Perl Hacker'. the question is
>'Why does it COMPILE??'."
>
One of Abigail's specials
perl -Mstrict -we '$_ = "goto F.print chop;\n=rekcaH lreP rehtona
tsuJ";F1:eval'
Eat your heart out!
perl -e '$_="<sfldbijmsfQjsfiupobjutvK"; y/A-Za-ik-zj</ZA-Yza-ik-y ,/; $_=reverse $_ ;print '
------------------------------
Date: Tue, 05 Nov 2002 10:52:59 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl and large text files
Message-Id: <3dc7a121.1755275552@news.cis.dfn.de>
On Mon, 4 Nov 2002 20:46:58 +0200, "JorkkiS"
<jarkko.rantamaki@edu.stadia.no.spam.fi> wrote:
>Thanks for ideas and suggestions.
>Maybe I will do two versions of this script. One with the grep and array...
>and other with line by line approach.
>Then I can compare which is faster.
Who cares which is faster? Get it right first. That is
the priority.
But using a while loop is faster anyway.
#!/perl
use warnings;
use strict;
use Benchmark;
my $find_this = 'sad';
timethese(1000000,
{
'slurp' => sub { my @array = (<DATA>);
my @wanted = grep /$find_this/,@array; },
'while' => sub { while (<DATA>)
{ next unless /$find_this/; push @wanted, $_; }},
}
);
__END__
asdgfsiuadghi8osadfg´pg´æosjglisjafgijhsgfjfsg9faghdfghd
f9gj9fjgf9asgjdf9asgjaftu05toign hvbodvoghdfoghdfhg
sdfaigyhfastgyh8hguiuh iguf uyg uoyg iuo 8y 6g
798ho9uujoihoghipuh
sdoafhsifugpsfagh8ðy9dfsð8gyregt8hdfsgouhsaof8gh
Output:
Benchmark: timing 1000000 iterations of slurp, while...
slurp: 12 wallclock secs ( 8.31 usr + 2.32 sys = 10.64
CPU) @ 94029.15/s (n=1000000)
while: 8 wallclock secs ( 5.38 usr + 2.09 sys = 7.47
CPU) @ 133868.81/s (n=1000000)
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Tue, 05 Nov 2002 12:35:29 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: Perl and large text files
Message-Id: <lWOx9.70016$gB.18091017@twister.nyc.rr.com>
Helgi Briem <helgi@decode.is> wrote:
> On Mon, 4 Nov 2002 20:46:58 +0200, "JorkkiS"
> <jarkko.rantamaki@edu.stadia.no.spam.fi> wrote:
>
>> Thanks for ideas and suggestions.
>> Maybe I will do two versions of this script. One with the grep and
>> array...
>> and other with line by line approach.
>> Then I can compare which is faster.
>
> Who cares which is faster? Get it right first. That is
> the priority.
>
> But using a while loop is faster anyway.
And when the filehandle is at eof, it hardly takes any
time at all...
(But you're right, of course; given a big enough file.)
--
Steve
perldoc -qa.j | perl -lpe '($_)=m("(.*)")'
------------------------------
Date: Tue, 5 Nov 2002 09:29:10 +0000 (UTC)
From: root <root@nuddelaug.jackal-net.at>
Subject: Re: perl nslookup
Message-Id: <slrnasf3mk.4dv.root@nuddelaug.jackal-net.at>
In article <3DC6DC75.B88621D5@earthlink.net>, Benjamin Goldberg wrote:
> filip wrote:
>>
>> dear all,
>>
>> I have a problem with my Perl script.
>>
>> In my script, I use the unix nslookup commando's.
>> I do a host lookup to a known dns server but the problem is when the
>> known dns server does not answer. My script just waits and waits.
>> If I specify a timeout in the nslookup -timeout=10 nothing happens...
>>
>> I do not know how to solve this problem.
Why dont you use Net::DNS ??
>
> There are a number of solution.
>
> One is to open a pipe from the nslookup command, and use
> select/IO::Select to read data while doing a timeout -- if it does time
> out, remember to use kill() on the pid returned by open(), before
> closing the filehandle.
>
> Another is to use the bgsend method of Net::DNS::Resolver, do the
> timeout using select/IO::Select on the sockethandle it gives you.
>
> Another is to use backticks or qx or readpipe to get the data from
> nslookup, and to use alarm() to time it out.
>
------------------------------
Date: 5 Nov 2002 14:36:26 GMT
From: nobody <noemail@nowhere.net>
Subject: style pet peeve: qw() for single words?
Message-Id: <Xns92BD624C5990Aabccbaabc@216.148.53.99>
Here's a rhetorical style question (and personal pet peeve):
Why do examples so often use qw() to quote single words?
Ex.
@ISA = qw(Exporter);
instead of
@ISA = 'Exporter';
Just tradition, or ignorance about what qw() does, or assignment
to arrays?
I suppose it might make more sense in context, if the next line is
@EXPORT = qw(&func1 &func2 &func4);
------------------------------
Date: 05 Nov 2002 10:41:22 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: style pet peeve: qw() for single words?
Message-Id: <m3u1iwkorh.fsf@mumonkan.sunstarsys.com>
nobody <noemail@nowhere.net> writes:
> Here's a rhetorical style question (and personal pet peeve):
>
> Why do examples so often use qw() to quote single words?
> Ex.
> @ISA = qw(Exporter);
> instead of
> @ISA = 'Exporter';
>
> Just tradition, or ignorance about what qw() does, or assignment
> to arrays?
From the standpoint of perl context, the thing that matters
most is the type of assignment (list or scalar) taking place.
IMO qw// is more parsimonious than '' when performing a
(single-element) list assignment.
btw- In 5.00503, using qw// in scalar context is an error,
and is arguably bad form in more modern versions of perl.
HTH.
--
Joe Schaefer "Peace cannot be kept by force. It can only be achieved by
understanding."
--Albert Einstein
------------------------------
Date: 5 Nov 2002 15:46:35 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: style pet peeve: qw() for single words?
Message-Id: <aq8p4r$7krfk$1@fu-berlin.de>
nobody <noemail@nowhere.net> wrote:
> Here's a rhetorical style question (and personal pet peeve):
> Why do examples so often use qw() to quote single words?
> Ex.
> @ISA = qw(Exporter);
> instead of
> @ISA = 'Exporter';
in this case it's probably a habit; for other cases
it's useful. Suppose you have:
use CGI 'param';
and you want to add the method head().
then you would have to write
use CGI ('param','head');
with qw// you can just add " head".
use CGI qw(param head);
less keystrokes...
this reminds me of the habit to add a comma after the
last element of a hash:
%hash = (
KEY1 => "value1",
KEY2 => "value2",
);
if you want to add a KEY3, you can just add it and don't
have to care about the comma.
hth, tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/ \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Tue, 05 Nov 2002 15:51:06 GMT
From: Stan Murch <smurch@no.spam>
Subject: Re: style pet peeve: qw() for single words?
Message-Id: <KNRx9.22607$Lu1.39359@sccrnsc01>
nobody wrote:
> Here's a rhetorical style question (and personal pet peeve):
>
> Why do examples so often use qw() to quote single words?
> Ex.
> @ISA = qw(Exporter);
> instead of
> @ISA = 'Exporter';
>
> Just tradition, or ignorance about what qw() does, or assignment
> to arrays?
>
> I suppose it might make more sense in context, if the next line is
> @EXPORT = qw(&func1 &func2 &func4);
Because the list is likely to expand, and a common typo would then result in
@ISA = 'Exporter DynaLoader';
The qw() is a way of saying "a list can go here". It's not ignorance.
------------------------------
Date: Tue, 05 Nov 2002 13:37:19 GMT
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: unwanted white space when I write to files
Message-Id: <slrnasfi3g.cin.garry@zfw.zvolve.net>
On 4 Nov 2002 19:04:38 -0800, Matt Oefinger <oefinger@mit.edu> wrote:
> I'm getting unwanted white space when I try to write to a file as follows:
^^^^^
This is a FAQ.
perldoc -q space
"Why do I get weird spaces when I print an array of lines?"
--
Garry Williams
------------------------------
Date: Tue, 05 Nov 2002 10:12:22 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Why is DESTROY called in scalar context?
Message-Id: <37vesu08jihadd8orr1n53r491m032h8a3@4ax.com>
Rafael Garcia-Suarez bravely attempted to attach 10 electrodes of
knowledge to the nipples of comp.lang.perl.misc by saying:
>Teh (tî'pô) wrote in comp.lang.perl.misc :
>> I wrote a trivial test and DESTROY seems to be called in scalar
>> context, is this always so?
>>
>> I would have expected void context. I don't know if this has any
>> significance, just wondering.
>
>I just hacked perl to have DESTROY called in void context, and ran the
>test suite. Nothing appeared to break. I'll ask for further
>clarification on P5P.
I've looked a bit in perl5db.pl and found this:
# Note that if DESTROY returns a reference to the object (or object),
# the deletion of data may be postponed until the next function call,
# due to the need to examine the return value.
I don't know apropos what this is said but it looks like it might have
something to do with the context in which DESTROY is called.
------------------------------
Date: Tue, 05 Nov 2002 15:16:28 GMT
From: Jeff Thies <cyberjeff@sprintmail.com>
Subject: Re: ||= |=
Message-Id: <3DC7E151.F4B1E166@sprintmail.com>
Benjamin Goldberg wrote:
>
> Bart Lateur wrote:
> >
> > Jeff Thies wrote:
> [snip]
> > >What's the right why to assign defaults?
> >
> > ||=
>
> Or, if you're using bleedperl, then the answer is
A quick Google search has left me unilluminated about bleedperl. Is this
5.8, or something to do with modperl ???
And thanks to everyone for all the insights!
Jeff
>
> //=
>
> , the defined-or operator.
------------------------------
Date: Tue, 05 Nov 2002 15:38:28 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: ||= |=
Message-Id: <i7pfsu8km7j3f00drqihuvbfq6vbienvis@4ax.com>
Jeff Thies wrote:
>A quick Google search has left me unilluminated about bleedperl. Is this
>5.8, or something to do with modperl ???
It's is the pre-release, where the Perl5Porters, the people who are
developing Perl, include all the newest features, partly to see that it
works, and if they all work together; and partly to see if they're any
use. They may appear in the next mainstream version of Perl, or they may
be dropped again before that gets released. So, currently, it is beyond
5.8. I expect it to have or get a number 5.9.x. The next generation big
release will be 5.10.0.
--
Bart.
------------------------------
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 4067
***************************************