[13269] in Perl-Users-Digest
Perl-Users Digest, Issue: 679 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 30 14:07:22 1999
Date: Mon, 30 Aug 1999 11:05:16 -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 Mon, 30 Aug 1999 Volume: 9 Number: 679
Today's topics:
[New Maintainer and Version] HTTP::Headers::UserAgent (Ivan Kohler)
[New Module] Net::APP v0.1 (Ivan Kohler)
Absolute Beginner's Question (local web-servers) <Ulrich.Schreglmann@t-online.de>
Re: Absolute Beginner's Question (local web-servers) <jbc@shell2.la.best.com>
ANNOUNCE: New script for upgrading perl: find_used_modu (David Muir Sharnoff)
ANNOUNCE: XML::RSS 0.4 <eisen@pobox.com>
Re: CGI in PERL <jimmy@blackhole-designs.com>
Re: CGI in PERL (Larry Rosler)
checking return status on system() <bmetcalf@nortelnetworks.com>
Re: Converting strings to arrays question <ilya@speakeasy.org>
DBD - DBI and postgresql <ethanc@congruency.com>
Design by Contract Seminar Series <training@eiffel.com>
Re: File listing <rolf.raven@quantis.nl>
Re: Help! Syntax error that I can't find! <aqumsieh@matrox.com>
How to do this... <eirik@netmaking.com>
how to open file descriptor by number? (Dave Meyer)
Re: how to open file descriptor by number? (Anno Siegel)
Re: how to open file descriptor by number? (Randal L. Schwartz)
Re: how to open file descriptor by number? (Anno Siegel)
Inheriting from Bit::Vector (Anno Siegel)
Re: need help with constants <davidrubin@lucent.com>
Net::Whois v1.02 now in CPAN <dhudes@ncdsl.com>
Re: parsing through constant multiline input (Larry Rosler)
Re: Pattern Matching <aqumsieh@matrox.com>
Re: Perl Y2K Bugs on the Internet (Mark W. Schumann)
Re: Random number (Larry Rosler)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Aug 1999 17:53:15 GMT
From: ivan@rootwood.sisd.com (Ivan Kohler)
Subject: [New Maintainer and Version] HTTP::Headers::UserAgent
Message-Id: <7qegeb$iro$1@play.inetarena.com>
Keywords: perl module HTTP User-Agent
HTTP::Headers::UserAgent v2.00
has been uploaded to CPAN, and can also be downloaded from
<http:/www.sisd.com/useragent>.
This is a class that deals with the HTTP User-Agent header. It will parse
the header, and (hopefully) report the correct platform, operating system,
browser, and browser version.
This is version 2.00 of the HTTP::Headers::UserAgent class. While the
interface provides backward-compatibility with version 1.00, it is not based
on the 1.00 code.
Portions of this software were originally taken from the Bugzilla Bug Tracking
system <http://www.mozilla.org/bugs/>, and are reused here with permission of
the original author, Terry Weissman <terry@mozilla.org>.
DLSI status is adpO or adph, depending on whether you count the depriciated
1.00 interface. I am unsure if I should send that to someone?
NAME
HTTP::Headers::UserAgent - Class encapsulating the HTTP
User-Agent header
SYNOPSIS
use HTTP::Headers::UserAgent;
HTTP::Headers::UserAgent->DumpFile( $fh );
$user_agent = new HTTP::Headers::UserAgent $ENV{HTTP_USER_AGENT};
$user-agent->string( $ENV{HTTP_USER_AGENT} );
$string = $user_agent->string;
$platform = $user_agent->platform;
$bugzilla_platform = $user_agent->bugzilla_platform;
$os = $user_agent->os;
$bugzilla_os = $user_agent->os;
( $browser, $version ) = $user_agent->browser;
#backwards-compatibility with HTTP::Headers::UserAgent 1.00
$old_platform = HTTP::Headers::UserAgent::GetPlatform $ENV{HTTP_USER_AG
ENT};
DESCRIPTION
The HTTP::Headers::UserAgent class represents User-Agent
HTTP headers.
This is version 2.00 of the HTTP::Headers::UserAgent
class. While the interface provides backward-
compatibility with version 1.00, it is not based on the
1.00 code.
METHODS
DumpFile FILEHANDLE
Class method - pass an open filehandle to this method,
and all unparsable user-agent strings will be written
to this filehandle.
This will be triggered when you actually call the
platform, os or browser methods.
Pass the undefined value to disable this behavior.
new HTTP_USER_AGENT
Creates a new HTTP::Headers::UserAgent object. Takes
the HTTP_USER_AGENT string as a parameter.
string [ HTTP_USER_AGENT ]
If a parameter is given, sets the user-agent string.
Returns the user-agent as an unprocessed string.
platform
Tries to guess the platform. Returns ia32, ppc,
alpha, hppa, mips, sparc, or unknown.
ia32 Intel archetecure, 32-bit (x86)
ppc PowerPC
alpha DEC (now Compaq) Alpha
hppa HP
mips SGI MIPS
sparc Sun Sparc
bugzlla_platform
Same as the platform method, with the following
translations (for bugzilla compatbility):
ia32 PC
ppc Macintosh
alpha DEC
hppa HP
mips SGI
sparc Sun
unknown Other
os Tries to guess the operating system. Returns irix,
win16, win95, win98, winnt, win32 (Windows
95/98/NT/?), macos, osf1, linux, solaris, sunos, bsdi,
os2, or unknown.
bugzilla_os
Same as the os method, with the following translations
(for bugzilla):
irix IRIX
macos Mac System 8.5
osf1 OSF/1
linux Linux
solaris Soalris
sunos SunOS
bsdi BSDI
win16 Windows 3.1
win95 Windows 95
win98 Windows 95
winnt Windows NT
win32 Windows 95
os2 other
unknown other
browser
Returns a list consisting of the browser name and
version. Possible browser names are:
Netscape, IE, Opera, Lynx, Mozilla, Emacs-W3, or
Unknown
BACKWARDS COMPATIBILITY
For backwards compatibility with HTTP::Headers::UserAgent
1.00, a GetPlatform subroutine is provided.
GetPlatform HTTP_USER_AGENT
Returns Win95, Win98, WinNT, UNIX, MAC, Win3x, OS2,
Linux, or undef.
In some cases ( `Win32', `Windows CE' ) where
HTTP::Headers::UserAgent 1.00 would have returned
`Win95', will return undef instead.
Will return `UNIX' for some cases where
HTTP::Headers::UserAgent would have returned undef.
AUTHOR
Ivan Kohler <ivan-useragent@sisd.com>
Portions of this software were originally taken from the
Bugzilla Bug Tracking system
<http://www.mozilla.org/bugs/>, and are reused here with
permission of the original author, Terry Weissman
<terry@mozilla.org>.
COPYRIGHT
Copyright (c) 1999 iQualify, Inc.
<http://www.iqualify.com/> All rights reserved. This
program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
BUGS
Needs more testing, especially with less common
platforms/OSs/browsers. Help save the world! Send
unparsable user-agent headers (and the platform/OS/browser
that generated them) to <ivan-useragent@sisd.com>. Please
be sure you have the latest version of
HTTP::Headers::UserAgent first!
bugzilla_os returns "Windows 95" instead of "Windows 98",
because stock Bugzilla doesn't have a "Windows 98" choice.
You can work around this by setting
$HTTP::Headers::UserAgent::bugzilla_os{win98} = "Windows
98";
The bugzilla_* methods are a kludge and should probably
replaced with a general method for doing arbitrary
translation tables.
The version number is 2.00 rather than the more
traditional 0.01, because the previous
HTTP::Headers::UserAgent module had version number 1.00.
SEE ALSO
perl(1), the HTTP::Headers manpage
--
Ivan Kohler <ivan@sisd.com> - finger for PGP key - <com.dsis@navi> Relhok Navi
Open-source billing and administration for ISPs - http://www.sisd.com/freeside
20 4,16 * * * saytime # please don't be surprised if you find me dreaming too
------------------------------
Date: 30 Aug 1999 17:53:30 GMT
From: ivan@rootwood.sisd.com (Ivan Kohler)
Subject: [New Module] Net::APP v0.1
Message-Id: <7qegeq$irr$1@play.inetarena.com>
Keywords: perl module Critical Path APP
Net::APP v0.1 has been uploaded to CPAN.
It can also be downloaded from <http://www.sisd.com/netapp>.
The module provides a client interface to Critical Path's <http://www.cp.net/>
Account Provisioning Protocol. It won't be useful unless you are a Critical
Path customer.
DLSI status is ampO; I am unsure if I should send that to someone.
NAME
Net::APP - Critical Path Account Provisioning Protocol
SYNOPSIS
use Net::APP;
$app = new Net::APP ( 'host:port' )
or die "Can't connect: $@";
$app = new Net::APP ( 'host:port', Timeout => 60, Debug => 1 )
or die "Can't connect: $@";
$app->
DESCRIPTION
This module implements a client interface to Critical
Path's Account Provisioning Protocol, enabling a perl
application to talk to APP servers. This documentation
assumes that you are familiar with the APP protocol
documented in the Account Provisioning Protocol
Developer's Guide.
A new Net::APP object must be created with the new method.
Once this has been done, all APP commands are accessed via
method calls on the object.
METHODS
new ( HOST:PORT [ , OPTIONS ] )
This is the constructor for a new Net::APP object.
HOST and PORT specify the host and port to connect to
in cleartext. Typically this connection is proxied
via Safe Passage Secure Tunnel to Critical Path.
OPTIONS are passed in a hash like fastion, using key
and value pairs. Possible options are:
Timeout - Set a timeout value (defaults to 120)
Debug - Enable debugging information (see the debug
method in the Net::Cmd manpage)
If the constructor failes undef will be returned and
an error message will be in $@.
AUTHOR
Ivan Kohler <ivan-netapp@sisd.com>.
This module is not sponsored or endorsed by Critical Path.
COPYRIGHT
Copyright (c) 1999 Ivan Kohler. Copyright (c) 1999
Silicon Interactive Software Design. All rights reserved.
This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
VERSION
$Id: APP.pm,v 1.1.1.1 1999/06/21 10:11:11 ivan Exp $
This module currently implements APP v2.1, as documented
in the Account Provisioning Protocol Developers Guide
v2.1.
BUGS
The Account Provisioning Protocol Developer's Guide is not
publicly available.
It appears that Safe Passage Secure Tunnel establishes a
standard SSL connection. It should be possible to use
Net::SSLeay and connect to the APP server directly.
SEE ALSO
Critical Path <http://www.cp.net/>, Safe Passage Secure
Tunnel <http://www.c2.net/products/spst>, the Net::Cmd
manpage, perl(1).
--
Ivan Kohler <ivan@sisd.com> - finger for PGP key - <com.dsis@navi> Relhok Navi
Open-source billing and administration for ISPs - http://www.sisd.com/freeside
20 4,16 * * * saytime # please don't be surprised if you find me dreaming too
------------------------------
Date: Mon, 30 Aug 1999 18:16:55 +0200
From: "Ulrich.Schreglmann" <Ulrich.Schreglmann@t-online.de>
Subject: Absolute Beginner's Question (local web-servers)
Message-Id: <7qeb4k$mk5$1@news07.btx.dtag.de>
Hello.
I tried to find a newsgroup I could post a question about local web-
servers into. Didn't find any, but since I need to install one in or-
der to test Perl CGIs I thought this might be the right place.
I have no idea how Windows (95B) internally handles internet connec-
tions at all. My online service works. But when I try to run locally
installed web servers while offline one would complain about the miss-
ing "winsock.dll" and the other gave me two errors "10050 socket not
found" and "10038 socket listen error".
I've added the winsock.dll by now, but the servers still complain.
Of course I need a local server ONLY when I'm offline, in order to
connect to and to check out my local files and programs via http.
No one I know can help me. Can you? Or is there a group somewhere
out there this is more on-topic in?
Thank you for any help.
--
©OOL mcmxcix
"There's nothing good--unless you do't." (Erich Kästner)
------------------------------
Date: 30 Aug 1999 17:51:43 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Absolute Beginner's Question (local web-servers)
Message-Id: <37cac4af$0$207@nntp1.ba.best.com>
Ulrich.Schreglmann <Ulrich.Schreglmann@t-online.de> wrote:
> I tried to find a newsgroup I could post a question about local web-
> servers into. Didn't find any, but since I need to install one in or-
> der to test Perl CGIs I thought this might be the right place.
Try this:
http://www.activestate.com/support/faqs/win32/perlwin32faq6.html
Future discussion on this point should probably go somewhere like
comp.infosystems.www.servers.ms-windows.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: 30 Aug 1999 17:52:29 GMT
From: muir@idiom.com (David Muir Sharnoff)
Subject: ANNOUNCE: New script for upgrading perl: find_used_modules
Message-Id: <7qegct$ird$1@play.inetarena.com>
find_used_modules is a script to help in the process of upgrading
a perl installation.
It runs through the system looking for perl scripts. When it finds
them it reads them and looks for "use" and "require" statements. It
compiles a list of the modules that are actually used.
Once it has its list, it outputs a perl program that can be used to
check a prospective perl instantiation prior to installation to make
sure that all the needed perl modules can at least be use'd.
You can find find_used_modules at:
http://www.cpan.org/authors/id/MUIR/scripts/find_used_modules.gz
-Dave
------------------------------
Date: 30 Aug 1999 17:51:34 GMT
From: Jonathan Eisenzopf <eisen@pobox.com>
Subject: ANNOUNCE: XML::RSS 0.4
Message-Id: <7qegb6$ir4$1@play.inetarena.com>
DLSI=adpO
This release fixes an extraneous print statement that
I neglected to remove before I released 0.3. Please
upgrade to this version if you're using XML::RSS 0.3.
I also updated examples/rss2html.pl to use a few of
the optional elements added to RSS 0.91.
This is an alpha release because the API has not been
finalized. The module will be available at your local
CPAN archive. Alternatively, try this URL:
http://www.perlxml.com/modules/XML-RSS-0.4.tar.gz
This Perl module provides a basic framework for creating and
maintaining Rich Site Summary (RSS) files. RSS is primarily
used for distributing news headlines, commonly called
channels, and is used primarily on Netscape's Netcenter,
http://my.netscape.com, and Userland Software's
http://my.userland.com.
More information on RSS can be found at:
http://my.netscape.com/publish/help/mnn20/quickstart.html
Please send comments, problems, etc. to eisen@pobox.com.
Jonathan.
------------------------------
Date: Mon, 30 Aug 1999 15:15:14 GMT
From: Jimmy Humphrey <jimmy@blackhole-designs.com>
Subject: Re: CGI in PERL
Message-Id: <37CA9FF4.10522A48@blackhole-designs.com>
> If you're going to use CGI.pm then use it:
>
> print start_header, "\n";
Call me old fashioned, I just find it easier to read print
"Content-type: text/html\n\n"; I don't like having to use another
persons code unless I have to.
Jimmy
------------------------------
Date: Mon, 30 Aug 1999 08:49:12 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: CGI in PERL
Message-Id: <MPG.123447d058942ca9989ed5@nntp.hpl.hp.com>
In article <37CA9FF4.10522A48@blackhole-designs.com> on Mon, 30 Aug 1999
15:15:14 GMT, Jimmy Humphrey <jimmy@blackhole-designs.com> says...
> > If you're going to use CGI.pm then use it:
> >
> > print start_header, "\n";
There is no such CGI function. It is called simply 'header'.
> Call me old fashioned, I just find it easier to read print
> "Content-type: text/html\n\n"; I don't like having to use another
> persons code unless I have to.
CGI.pm tries to make it unnecessary to know HTML, which is a bit
foolish. So you get things like:
print br, "\n"; # so all the output isn't on one physical line
instead of a straightforward:
print "<BR>\n";
Having disparaged these aspects of CGI.pm output, I tried using CGI.pm
when I ran into my first need for file uploading using multi-part forms,
which I found tedious to parse. It worked just fine.
So I've started to write all the HTML using CGI.pm functions, to achieve
a foolish consistency. The HTML is prim and prissy -- all sorts of
unnecessary quoting and unnecessary explicit use of defaults. For
example, start_html produces a superfluous DTD line ahead of the
'<HTML><HEAD>' tags.
But the input-parsing stuff is excellent.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 30 Aug 1999 09:35:11 -0700
From: Brandon Metcalf <bmetcalf@nortelnetworks.com>
Subject: checking return status on system()
Message-Id: <37CAB2BF.E154C7CF@nortelnetworks.com>
I've written a Perl job where I'm making quite a few system() calls.
Instead of doing something like
system("exec this") && die "system() failed\n";
I've written a simple function _system() that looks like
sub _system
{
my ($cmd) = @_;
system("$cmd") && die "system() call failed on $cmd\n";
}
Using this I don't have to use system() and check the return status for
every system() call I want to make. I simply say something like
_system("exec this");
Is this fairly efficient or is there a better way of doing this?
Thanks,
Brandon
------------------------------
Date: Mon, 30 Aug 1999 17:39:32 GMT
From: Ilya <ilya@speakeasy.org>
Subject: Re: Converting strings to arrays question
Message-Id: <rslgekafj7142@corp.supernews.com>
Ala Qumsieh <aqumsieh@matrox.com> wrote:
> Ilya <ilya@speakeasy.org> writes:
>> Nope.... I don't want to take the values of %input_params. They merely
>> represent something. i.e. if $input_params{$key} eq 1 I want to take @value,
>> not $value and do something with it.
> What do you mean?
> What is @value? What do you suspect it should contain?
> The following
> for my $value (values %input_params) {
> ....
> }
> iterates through the values of your hash, ONE by ONE. $value will
> point to each value in each iteration. There is no @value.
Well, @value comes from another subroutine.
==============================================================================
Though we have many valleys to travel and mountains to climb, by nature we are
inclined to fear the unknown. Life rewards those of us who accept the call to
go where we have never been even when we, seemingly, have to go there alone.
==============================================================================
------------------------------
Date: Mon, 30 Aug 1999 18:11:43 +0200
From: "ciprut ethan" <ethanc@congruency.com>
Subject: DBD - DBI and postgresql
Message-Id: <7qe6t0$duj$1@news.netvision.net.il>
Hi,
Iv been using Pg for posting queries to postgresql from apache,
it all worked well so....
I tried to work with the DBI module, but from some reason i get
Unsupported frontend protocol - from the postmaster when calling
the DBI->connect(....
any clue whats going on ??
Thanks ....
Ciprut Ethan
------------------------------
Date: Mon, 30 Aug 1999 10:39:09 -0700
From: "Interactive Software Engineering, Inc." <training@eiffel.com>
Subject: Design by Contract Seminar Series
Message-Id: <7qefi4$3uq$1@news.rain.org>
ISE'S EXCLUSIVE SEMINARS ON DESIGN BY CONTRACT AND THE COMPONENT REVOLUTION.
A ONE-DAY COURSE BY BERTRAND MEYER.
If you are involved in software development, either as a manager or as a
developer, you know how crucial it is to improve software quality and
productivity. In spite of the major advances of recent years, especially
Object Technology, it is still much too hard to produce correct, reliable
systems at a reasonable cost.
This state of the art seminar is a unique opportunity to hear about the
approach that is revolutionizing the software industry - not from an outside
observer, but from one of the key originators of the discipline, Dr.
Bertrand Meyer, one of a handful of object- oriented movers and shakers
whose work made modern object-oriented technology possible.
"Design by Contract" is the major technological breaktrough in software
engineering in the past 15 years. This course introduces Design by Contract
and shows why it can, like no other technique since the invention of classes
and objects, dramatically affect the way we develop software, and why it is
a required condition for achieving the promise of the Component Revolution.
For more information about the seminar, as well as locations, please visit
our Web site at http://www.designbycontract.com. You can also contact us by
email: training@eiffel.com.
Interactive Software Engineering, Inc
Goleta, California
------------------------------
Date: Mon, 30 Aug 1999 17:55:20 +0200
From: Rolf Raven <rolf.raven@quantis.nl>
Subject: Re: File listing
Message-Id: <37CAA968.C9CD86A0@quantis.nl>
Abigail wrote:
>
> Rolf Raven (rolf.raven@quantis.nl) wrote on MMCXC September MCMXCIII in
> || opendir THISDIR, "." or die "$!";
> || @allfiles = readdir THISDIR;
> || closedir THISDIR;
> || print "@allfiles\n";
>
> And that selects the files matching a specific criteria exactly how?
Well... you know... uhm... yeah... just write "*.txt" instead of "."
And yes, I know you should use 'glob'...
(thanks Remco)
------------------------------
Date: Mon, 30 Aug 1999 10:20:45 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Help! Syntax error that I can't find!
Message-Id: <x3yk8qdwds3.fsf@tigre.matrox.com>
gary@onegoodidea.com (Gary O'Keefe) writes:
> foreach $i keys(%product_tally) {
The above line won't compile. for() and foreach() need the brackets:
foreach $i (keys %product_tally) {
> if ($product_tally{$i} > 20) { <-- here
> push(@products_kw,$i)
> }
> }
>
> foreach $i keys(%product_tally) {
Same thing here.
> while ($index > 0) { <-- here
> if ($product_tally{$i} == $index) { <-- here
> push(@products_kw,$i);
> --$index;
> }
> }
> }
Careful :)
Ala
------------------------------
Date: Mon, 30 Aug 1999 19:40:35 +0200
From: "Eirik Johansen [netmaking.com]" <eirik@netmaking.com>
Subject: How to do this...
Message-Id: <37CAC212.E9C2A3F3@netmaking.com>
Hi,
I've just started writing my very own Perl scripts (almost done
reading "Learning Perl" and have just started "Programming
Perl"). I've started working on a script which is supposed to
analyze a text-file for me, but I've encountered a problem which
I don't know how to deal with.
Could anyone please assist me in how the following can be done:
I have a file opened using a filhandle called "MAILS". I'm
looping through the lines using a while loop. Well, this is what
I want the script to do. When it encounters a line in the
text-file which consists only of a newline, I want it to read the
next four lines (excluding the line which only consists of a
newline) into a variable for further editing. (The fifth line
always starts with "From:" if that's of any help to you.)
Thanks very much for any useful suggestions !
Best Regards,
Eirik Johansen
webmaster of
http://www.netmaking.com
------------------------------
Date: Mon, 30 Aug 1999 14:45:28 GMT
From: dmeyer@news.bellatlantic.net (Dave Meyer)
Subject: how to open file descriptor by number?
Message-Id: <7qe586$l26$1@jhereg.dmeyer.org>
I want to be able to open a file descriptor by number, and haven't
been able to figure out how to do it. If the fd is 0, 1, or 2 I can
just use STDIN, STDOUT, or STDERR, but what if the fd is 7?
The goal here is to do something like this:
my $program_to_exec="/bin/cat";
pipe(RDR,WTR);
my $pid=fork();
if ($pid == 0) {
#child
close(WTR);
open(STDIN,"<&RDR") or die "trouble: $!";
exec($program_to_exec);
}
#parent
close(RDR);
print WTR "send this to $program_to_exec\n";
close(WTR);
which is a simple enough pipe/exec thing. However, if
$program_to_exec is expecting input on fd 3 (instead of on fd 0 as
shown in my example), what do I do? I suppose I could use the syscall
interface to dup2, but having never used syscall before I was hoping
for something a little easier.
Thanks,
Dave
--
David M. Meyer
meyer@virtc.com
------------------------------
Date: 30 Aug 1999 15:10:59 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to open file descriptor by number?
Message-Id: <7qe6u3$pf5$1@lublin.zrz.tu-berlin.de>
Dave Meyer <dmeyer0@bellatlantic.net> wrote in comp.lang.perl.misc:
>I want to be able to open a file descriptor by number, and haven't
>been able to figure out how to do it. If the fd is 0, 1, or 2 I can
>just use STDIN, STDOUT, or STDERR, but what if the fd is 7?
open FD7, '>&7' or die "Can't dup fd 7: $!\n";
should do it (untested). See perldoc opentut (and presumably perldoc
-f open) for details.
[...]
Anno
------------------------------
Date: 30 Aug 1999 08:54:41 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: how to open file descriptor by number?
Message-Id: <m1vh9xxnzy.fsf@halfdome.holdit.com>
>>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
Anno> open FD7, '>&7' or die "Can't dup fd 7: $!\n";
Anno> should do it (untested). See perldoc opentut (and presumably perldoc
Anno> -f open) for details.
Unless something changed since the last time I looked at this feature,
you need to say:
open FD7, ">&=7" ...
because otherwise "7" would be treated as the filehandle "7". :) The
"=" makes it unambiguous.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 30 Aug 1999 16:47:56 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to open file descriptor by number?
Message-Id: <7qecjs$pko$1@lublin.zrz.tu-berlin.de>
Randal L. Schwartz <merlyn@stonehenge.com> wrote in comp.lang.perl.misc:
>>>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
>
>Anno> open FD7, '>&7' or die "Can't dup fd 7: $!\n";
>
>Anno> should do it (untested). See perldoc opentut (and presumably perldoc
>Anno> -f open) for details.
>
>Unless something changed since the last time I looked at this feature,
>you need to say:
>
> open FD7, ">&=7" ...
>
>because otherwise "7" would be treated as the filehandle "7". :) The
>"=" makes it unambiguous.
And here I thought I could get by posting untested code JUST THIS
ONCE...
Experimentally, both constructs ( >&2 vs. >&=2 ) are accepted and work
as expected on STDERR. The documentation is less than clear on the
issue: perldoc -f open says in one place (my *-hilighting):
You may also, in the Bourne shell tradition, specify an EXPR
beginning with C<'E<gt>&'>, in which case the rest of the string
is interpreted as the name of a filehandle (*or file descriptor,
if numeric*) to be duped and opened.
implying in passing that a number in the filehandle position is
treated as a file descriptor. But a little later it continues
If you specify *C<'E<lt>&=N'>*, where C<N> is a number, then Perl
will do an equivalent of C's C<fdopen()> of that file descriptor;
this is more parsimonious of file descriptors. For example:
open(FILEHANDLE, "<&=$fd")
So here, the "=" seems to be required. Inconclusive, I love it.
Now for those numeric filehandles; open( 7, '>&2') works like a
charm, but print 7 "halli hallo\n" is a syntax error. However
syswrite( 7, "halli hallo\n", 12) prints indeed to STDERR, so
these beasts actually work. Amazing. I guess using some indirect
filehandle trickery could persuade even print to use filehandle "7",
but my daily contingent of testing for clpm has just run out. Sorry.
Anno
------------------------------
Date: 30 Aug 1999 14:58:33 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Inheriting from Bit::Vector
Message-Id: <7qe66p$pc8$1@lublin.zrz.tu-berlin.de>
[posted to clpm and mailed to the author]
Playing with various designs for a class that would be derived (in
the broadest sense) from the module Bit::Vector, I am considering
direct inheritance. First thing I found is that Bit::Vector's new()
method insists in blessing its objects into Bit::Vector, instead of
into the class new() is called from. This, apparently, is a big
no-no in OO design the impact of which I'm painfully becoming aware
of.
What's more, the bless operation seems to be buried in the C parts
of the implementation, so an experimental quick fix isn't available.
Even worse, an attempt to re-bless a Bit::Vector object into another
class results in a read-only violation, so it seems that a Bit:Vector
is born that way and there's nothing a user can do about it.
Of course there are work-arounds; the adage that every problem can
be cured by an additional level of indirection seems to be true here.
But... it's unsatisfactory.
Now don't get me wrong, the Bit::Vector module is great stuff and
does great things fast, but the object-orientation seems to be
somewhat flawed.
Anno
------------------------------
Date: Mon, 30 Aug 1999 11:25:13 -0400
From: David L Rubin <davidrubin@lucent.com>
Subject: Re: need help with constants
Message-Id: <37CAA259.9B8CC61D@lucent.com>
Abigail wrote:
>
> David L Rubin (davidrubin@lucent.com) wrote on MMCLXXXV September
> MCMXCIII in <URL:news:37C42430.B6518317@lucent.com>:
> ||
> || But how can I use constants in a hash context? For instance, I could do this
> ||
> || %handle_error=(
> || eval{E_TIMEOUT} => &handle_timeout,
> || eval{E_FILE} => &handle_file,
> || eval{E_NET} => &handle_net,
> || );
> ||
> || What is the preferred "Perl Way?"
[snip]
> %handle_error = (
> +E_TIMEOUT => &handle_timeout,
> +E_FILE => &handle_file,
> +E_NET => &handle_net,
> );
>
Actually, this does not work, but
%handle_error = (
E_TIMEOUT() => &handle_timeout,
E_FILE() => &handle_file,
E_NET() => &handle_net,
);
does. In fact, 'perldoc constant' says so itself, but it's in the BUGS section
of all places. I didn't look there the first time around... :-)
david
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David L Rubin f 1.973.581.6665 v 1.973.386.8598
Lucent Technologies, NJ0117 14J-211, 67 Whippany Rd, Whippany, NJ 07981
------------------------------
Date: 30 Aug 1999 17:52:40 GMT
From: "Dana Hudes" <dhudes@ncdsl.com>
Subject: Net::Whois v1.02 now in CPAN
Message-Id: <7qegd8$irf$1@play.inetarena.com>
Documentation corrections.
There were previously some mirroring problems but all should now work
properly.
------------------------------
Date: Mon, 30 Aug 1999 07:16:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: parsing through constant multiline input
Message-Id: <MPG.1234321e1bd580aa989ed3@nntp.hpl.hp.com>
In article <37CA4EF4.5C93F0E5@ix.netcom.com> on 30 Aug 1999 02:34:27
PDT, Christopher Fadling <cfadling@ix.netcom.com> says...
> First time posting so I thought it would be a good idea to just jump
> in.
...
> Here is what I have, its a skelaton of just the parts I am struggling
> with, how to keep parsing through a block of events via an endless loop.
You will probably not get useful answers until you make your code
compilable and readable. Here are a few tips on the syntax.
> open (INPUT, "(recieving events part) |");
Always check the results of your open statements.
> open (OUTFILE, "(temp output file of parsed events")
Perl statements end in semicolons.
> while <INPUT> { # while reciving input,
Look up the syntax of a while() statement.
> should force you into an endless loop?
> while <$INPUT != "\n"> { # while its not a blank
> line which means its the end of an event?
> $in-eventline = $INPUT
> if ($in-eventline !~ /pattern/) { #
> pattern on first line which I dont need
Perl variables don't contain minus-signs.
Comments that loop around are unreadable.
...
> I look forward to enlightenment of the gurus :)
Please come back when you have done more on your own, with code that
compiles properly and is readable.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 30 Aug 1999 12:32:11 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Pattern Matching
Message-Id: <x3yiu5xw7p0.fsf@tigre.matrox.com>
bart.lateur@skynet.be (Bart Lateur) writes:
> Yup. Note that these options:
>
> print quotemeta($pattern);
> and
> print "\Q$pattern\E";
>
> will insert them (only) where necessary, for you.
This doesn't correspond to perlfunc:
**************************************
=item quotemeta EXPR
=item quotemeta
Returns the value of EXPR with all non-alphanumeric
characters backslashed. (That is, all characters not matching
C</[A-Za-z_0-9]/> will be preceded by a backslash in the
returned string, regardless of any locale settings.)
**************************************
It is generally not necessary to backwack the following characters:
- , ; > < : ~
among others.
--Ala
------------------------------
Date: 30 Aug 1999 13:26:37 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Perl Y2K Bugs on the Internet
Message-Id: <7qeesd$nii@junior.apk.net>
In article <1fby3.609$CY6.92041@typhoon01.swbell.net>,
Benjamin Franz <snowhare@long-lake.nihongo.org> wrote:
>And the non-Unix C people were suppposed to know that how?
>Before the Blue Camel came out in late 1996, the behaviour was
>essentially undocumented (a bad thing for just over 1100 days
>from Jan 1, 2000). The Pink Camel said "don't worry about it."
>Worse - it didn't mention 'ctime' in relation to tm structs
>and on page 321 it actually *used* "19$year"!
I'm fairly certain it was in `man perl` around 1993 or so.
Your example from the Pink Camel is indeed apalling if true.
------------------------------
Date: Mon, 30 Aug 1999 07:44:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Random number
Message-Id: <MPG.123438a4f716d32e989ed4@nntp.hpl.hp.com>
In article <k0nwvude7gy.fsf@ido.phys.ntnu.no> on 30 Aug 1999 15:14:21
+0200, Joakim Hove <hove@ido.phys.ntnu.no> says...
...
> $url =~ s#\/\-\/#\/$random_number\/#;
You got a good start here by using alternate delimiters because of the
slashes in the regex, but then succumbed to Leaning Toothpick Syndrome
anyhow by escaping everything unnecessarily.
The following is readable without eyestrain:
$url =~ s#/-/#/$random_number/#;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 679
*************************************