[9171] in Perl-Users-Digest
Perl-Users Digest, Issue: 2788 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 2 15:17:37 1998
Date: Tue, 2 Jun 98 12:00:30 -0700
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, 2 Jun 1998 Volume: 8 Number: 2788
Today's topics:
"system" output redirect ?? <gclim@NOSPAM.com>
"system" output redirect <gclim@NOSPAM.nt.com>
Re: "system" output redirect <rootbeer@teleport.com>
Re: $salt=.... (urgent!) <lanier@shell6.ba.best.com>
Re: [Help!] : Numeric Checker (Gary Trachier)
Re: Counter or Pause function in Perl? (Gary Trachier)
Dividing and type casting to an int ! <probavm@cat.com>
Re: Don't Know how to decrypt using PERL (Larry Rosler)
Re: file output and modules (Chris Schafer)
libwin32 version 0.12 released (Gurusamy Sarathy)
Re: map in void context regarded as evil - suggestion <jdporter@min.net>
Re: map in void context regarded as evil - suggestion (Larry Rosler)
Re: map in void context regarded as evil - suggestion <jdporter@min.net>
Re: map in void context regarded as evil - suggestion (Abigail)
Re: map in void context regarded as evil - suggestion <tchrist@mox.perl.com>
mSQL Perl Module Under Win'95 - Problem <andrew@boothman.easynet.co.uk>
perl 5.004_04 question ("Rick Bauman")
Re: Perl class for newbie? (Bbirthisel)
Re: Perl class for newbie? (Tad McClellan)
Re: Perl module for doing a unix 'which'? (Larry Rosler)
Re: Perl on Windows32 seeker79@yahoo.com
Re: perl question <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 02 Jun 1998 13:03:25 -0400
From: Gabriel Climescu <gclim@NOSPAM.com>
Subject: "system" output redirect ??
Message-Id: <3574305D.7DC2E018@NOSPAM.nt.com>
Hi, everybody,
I was browsing through some Perl books, as well as some WWW resources,
but still haven't been able to figure out a solution for this problem.
Please accept my apologies if you find this question as trivial.
I have a Perl script running on Solaris. In this script, there is a
{system "sys_command" "arg1" "arg2"} command.
My problem is that "sys_command" is writing occasionally messages on the
standard error (I have no control on that). I'd like these messages to
be redirected to a file (possibly /dev/null). Does anybody know how to
do that?
Please send me a message, I don't read this newsgroup regularly,
Thanks,
Gabriel
PLEASE REMOVE "NOSPAM" FROM MY E-MAIL ADDRESS
------------------------------
Date: Tue, 02 Jun 1998 13:07:43 -0400
From: Gabriel Climescu <gclim@NOSPAM.nt.com>
Subject: "system" output redirect
Message-Id: <3574315F.590F79E0@NOSPAM.nt.com>
(sorry for the first message, I remarked after that my e-mail address
was not setup and I wasn't able to cancel it).
Hi, everybody,
I was browsing through some Perl books, as well as some WWW resources,
but still haven't been able to figure out a solution for this problem.
Please accept my apologies if you find this question as trivial.
I have a Perl script running on Solaris. In this script, there is a
{system "sys_command" "arg1" "arg2"} command.
My problem is that "sys_command" is writing occasionally messages on the
standard error (I have no control on that). I'd like these messages to
be redirected to a file (possibly /dev/null). Does anybody know how to
do that?
Please send me a message, I don't read this newsgroup regularly,
Thanks,
Gabriel
gclim@NOSPAM.nt.com
PLEASE REMOVE "NOSPAM" FROM MY E-MAIL ADDRESS
------------------------------
Date: Tue, 02 Jun 1998 18:35:35 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: "system" output redirect
Message-Id: <Pine.GSO.3.96.980602112533.15370o-100000@user2.teleport.com>
On Tue, 2 Jun 1998, Gabriel Climescu wrote:
> I have a Perl script running on Solaris. In this script, there is a
> {system "sys_command" "arg1" "arg2"} command.
>
> My problem is that "sys_command" is writing occasionally messages on the
> standard error (I have no control on that). I'd like these messages to
> be redirected to a file (possibly /dev/null). Does anybody know how to
> do that?
You may know that system may do a fork call internally. One way to do
what you want would be to do the fork directly. Then, in the child
process, open STDERR to wherever you'd like before using exec (with the
args you would have used for system).
Another possible solution (but a less-advisable one) would be to have
system ask a shell to do the redirection for you. You may do that by
giving system a single command line including redirection, as a single
argument. It's not necessarily the best way because it starts an extra
process that you don't need, and because passing a list of arguments to
system or exec is more secure than involving a shell.
> Please send me a message, I don't read this newsgroup regularly,
You can't mean that how it sounds. This is like dropping in on a potluck
dinner to say that you have nothing to contribute, but that you'd like
four large plates, to go, please! :-) I'm sure that you didn't mean to
ask for the regular participants in this newsgroup to stop helping each
other just so that we could each write individual replies to you. Although
each reply might help you, it would help no one else. Maybe what you meant
to say was that you'd welcome emailed courtesy copies of posted replies,
like this one. Or maybe you meant to say that you'd be glad to gather
emailed responses and summarize them in a message to the newsgroup. Of
course, even if you're not a regular reader, you can search the newsgroup
with one of the popular Usenet archive services.
Hope this helps!
> PLEASE REMOVE "NOSPAM" FROM MY E-MAIL ADDRESS
PLEASE REMOVE "NOSPAM" FROM YOUR E-MAIL ADDRESS
:-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 2 Jun 1998 10:15:57 -0700
From: "matthew d. p. k. lanier" <lanier@shell6.ba.best.com>
Subject: Re: $salt=.... (urgent!)
Message-Id: <Pine.BSF.3.96.980602101535.14895D-100000@shell6.ba.best.com>
> "matthew d. p. k. lanier" <lanier@shell6.ba.best.com> writes:
>
> }> $salt=~s/\S\S(\S\S).*/$1/;
> }this searches for 2 white space charaters, 2 more white space characters,
> }and a bunch of stuff until the end of the string, and replaces all of that
> }with the 2'nd set of whitespace charaters.
>
> s/white ?space/non-whitespace/g;
DOH! that's what i get for posting without checking the book first.
>
> --
> Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
>
>
matt =)
........................................................
: matthew d. p. k. lanier : sf perl user's group :
: matt@lanier.org : sfpug-request@pootpoot.com :
: matt@saturn5.com : http://www.pm.org :
........................................................
------------------------------
Date: Tue, 02 Jun 1998 13:34:23 -0400
From: trachier@crrel.usace.army.mil (Gary Trachier)
Subject: Re: [Help!] : Numeric Checker
Message-Id: <trachier-0206981334240001@trachier.crrel.usace.army.mil>
In article <6l0bc7$meg$1@nnrp1.dejanews.com>, wslim@my-dejanews.com wrote:
> Hi Everyone,
>
> I am writing a CGI script in PERL that has to check the user input that is
> numeric. How to I write an elegant scipt to do that?
> Acceptable Value : 1.2, +1.2, -1.2, 1, 0, -1, +1
>
> Reject Values : abc, a12b, 1a3e, -1a, +2.a, *(dsa), ... any other combination
> of non-numeric that you can think of.
>
> Thank in advance a million!
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
What goes around comes around. I once asked this very question and here
is the response. It works well.
sub isNumeric ($) {
my $warning = '';
local ($SIG{'__WARN__'}) = sub { $warning .= $_[0]; };
local ($^W) = 1; # turn on warnings
(undef) = 0.0 + $_[0]; # does Perl think it's a number?
return scalar ($warning !~ /isn't numeric/);
}
Good luck.
-Gary
/---------------------------------------------------------------------------\
| Gary Trachier / U. S. Army Cold Regions Research & Engineering Laboratory |
| Internet: trachier@crrel.usace.army.mil |
| CorpsMail: Gary.M.Trachier@mail.usace.army.mil |
| Telephone: voice (603) 646-4303 fax (603) 646-4720 |
| USnail: (.^.) USA CRREL / 72 Lyme Road / Hanover, NH USA / 03755-1290 |
\--------A--U--A------------------------------------------------------------/
------------------------------
Date: Tue, 02 Jun 1998 13:27:00 -0400
From: trachier@crrel.usace.army.mil (Gary Trachier)
Subject: Re: Counter or Pause function in Perl?
Message-Id: <trachier-0206981327000001@trachier.crrel.usace.army.mil>
Martien,
> /How can I sleep() or alarm() for under a second?
Take a look at the Perl built-in select(ready file descriptors) for a
higher-resolution sleep function.
-Gary
/---------------------------------------------------------------------------\
| Gary Trachier / U. S. Army Cold Regions Research & Engineering Laboratory |
| Internet: trachier@crrel.usace.army.mil |
| CorpsMail: Gary.M.Trachier@mail.usace.army.mil |
| Telephone: voice (603) 646-4303 fax (603) 646-4720 |
| USnail: (.^.) USA CRREL / 72 Lyme Road / Hanover, NH USA / 03755-1290 |
\--------A--U--A------------------------------------------------------------/
------------------------------
Date: Tue, 02 Jun 1998 13:20:17 -0500
From: "Vincent M. Probasco" <probavm@cat.com>
Subject: Dividing and type casting to an int !
Message-Id: <35744261.A4B0CB67@cat.com>
--------------2AA82D92701DE5E603695938
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I have a script that needs to find a percentage .
Example -
$percent = int ($first_num / $sec_num * 100)
The numbers I'm coming up with are often off by a little. I was
wondering if this could
be because of the int typecasting or should I look elsewhere in the
script ?
Thanks,
Vince
--
Vincent Probasco
Work Hours : 12:00-6:00p.m., Mon.-Fri.
--------------2AA82D92701DE5E603695938
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
I have a script that needs to find a percentage .
<BR>Example -
<P> $percent = int ($first_num / $sec_num * 100)
<BR>
<P>The numbers I'm coming up with are often off by a little. I was wondering
if this could
<BR>be because of the int typecasting or should I look elsewhere in the
script ?
<P>Thanks,
<BR>Vince
<PRE>--
Vincent Probasco
Work Hours : 12:00-6:00p.m., Mon.-Fri.</PRE>
</HTML>
--------------2AA82D92701DE5E603695938--
------------------------------
Date: Tue, 2 Jun 1998 10:16:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Don't Know how to decrypt using PERL
Message-Id: <MPG.fddd353157c2cc989685@hplntx.hpl.hp.com>
In article <6kven2$cj3@eccws1.dearborn.ford.com>,
kfox@pt0204.pto.ford.com says...
...
> BTW, the "README.win32" says:
>
> | crypt() is not available due to silly export restrictions. It may
> | become available when the laws change. Meanwhile, look in CPAN for
> | extensions that provide it.
>
> If this is true, I'm not sure how *any* version of Perl can have
> crypt if the underlying C library doesn't have it.
I posted the `perl -v` output from the MKS perl 5.003. crypt() is not in
the ANSI/ISO Standard C Library, but its source is available. I'm
sure that MKS did just what the Perl implementers did with regard to
(s)printf() -- they implemented it themselves!
...
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 2 Jun 1998 18:21:19 GMT
From: schaferc@stu.beloit.edu (Chris Schafer)
Subject: Re: file output and modules
Message-Id: <6l1fqv$8ak@scooby.beloit.edu>
Thank you for the information. This is what the @INC variable is set to.
/local/lib /local/lib /local/lib
This is on a large AIX SP cluster and the perl distribution is located in
/usr/lpp/ssp/perl5/bin .. lib .. man
There would be no way to recompile/move the installation on all of the
nodes.
Thank you very much IBM.
So if I simply export the lib path for the standard modules in all my
scripts everything will be happy eh?
use lib '/some/path/to/modules';
Thanks for the help.
--
Christopher Lowell Schafer
__________________________ __
________________ _____
_________ ____________
___ _________________
_ ____________________
___ _________________
_________ ____________
________________ ______
__________________________
------------------------------
Date: 2 Jun 1998 18:42:26 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: libwin32 version 0.12 released
Message-Id: <6l1h2i$q1t$1@news.neta.com>
Howdy.
Just a quick note to say there's a new release of libwin32 on CPAN.
http://www.perl.com/CPAN/authors/id/GSAR/libwin32-0.12.tar.gz
http://www.perl.com/CPAN/authors/id/GSAR/libwin32-0.12.zip
This release has a known problem: Win32::Registry may emit noises
about unintialized values when using perl's -w switch. You can apply
this patch to fix it, either by hand or using the GNU patch utility.
-----------------------------------8<-----------------------------------
[Humanspeak: add "$_[0] &&" to the test on line 104 of Registry.pm.]
--- libwin32/Registry/Registry.pm.~1~ Fri May 15 20:09:41 1998
+++ libwin32/Registry/Registry.pm Fri May 15 20:09:41 1998
@@ -101,7 +101,7 @@
sub import
{
my( $pkg )= shift;
- if( "Win32" eq $_[0] ) {
+ if( $_[0] && "Win32" eq $_[0] ) {
Exporter::export( $pkg, "Win32", @EXPORT_OK );
shift;
}
-----------------------------------8<-----------------------------------
The README from the distribution follows.
Enjoy,
- Sarathy.
gsar@umich.edu
------------------------------------------------------------------------
Welcome to libwin32 version 0.12.
WHAT
----
This is a bundle of "Win32-only" extensions that provides a quick migration
path for people wanting to use the core support for win32 in perl 5.004
and later. It features the complete set of Win32-specific extensions
available from CPAN that could previously only be used with ActiveState's
"Perl for Win32"(TM).
Most other non-Win32 extensions should build fairly smoothly using
the MakeMaker support available in perl 5.004 and later, so they are
not included in this bundle.
This distribution has been pre-compiled for the x86 architecture. The
precompiled binaries can ONLY be used with the perl5.00402-bindist04-bc.zip
distribution from CPAN. See the "WHAT TO DO" section for installation
instructions.
WHAT HAS CHANGED
----------------
The top level "Changes" file contains a version by version overview of
the most significant changes.
Version 0.11 was never publicly released. This release has the following
changes over the previous one (version 0.10):
+ Jutta Klebe has contributed a new module, Win32::PerfLib. It
provides comprehensive facilities for accessing performance counters
on Windows NT. See the documentation in PerfLib/PerfLib.pm.
+ Many, many fixes and enhancements in Win32::OLE, thanks to Jan Dubois
See OLE/Changes for a detailed list.
+ Win32::NetAdmin supports new functions: GetAliasFromRID(),
GetUserGroupFromRID(), LocalGroupGetMembersWithDomain(), and
GetServerDisks() (thanks to David Gardiner and Jutta Klebe).
A few broken constants have been fixed and missing ones added
(thanks to Dave Roth). Most symbols are exported on request
(thanks to Tye McQueen).
+ Bug fixes for Win32::ChangeNotify (from Chris Madsen, thanks).
+ Win32::Registry exports older symbols for compatibility (thanks to
Tye McQueen). Reg*Key() functions enable priveleges as needed
(thanks to Jutta Klebe).
+ Win32::Service now reports stopped services (merged from ActiveState's
sources, thanks).
+ Win32::GetArchName() and Win32::GetChipName() functions have been
added, for compatibility.
+ The bug whereby Win32::Process couldn't be loaded on Win95 should be
fixed.
Many thanks to all the contributors.
WHAT IT HAS
-----------
This bundle contains:
* The collection of modules originally distributed by the Activeware
folks as part of their "Perl for Win32"(TM) port. These have been
modified so that they will build under MakeMaker using perls greater
than 5.004 and Visual C++. Along the way, I have added many
bugfixes to make these modules work correctly.
The complete list of Activeware extensions is available:
Win32/ChangeNotify
Win32/EventLog
Win32/File
Win32/FileSecurity
Win32/IPC
Win32/Mutex
Win32/NetAdmin
Win32/NetResource
Win32/OLE
Win32/Process
Win32/Registry
Win32/Semaphore
Win32/Service
Win32/WinError
Note this covers all of the Win32 extensions distributed by
Activeware (as of build 316).
These extensions have been re-engineered to use the XS interface
language, yet the changes are compatible with the originals. This
should minimize any problems for people wanting to migrate their
application to 5.004. The design of these modules is subject to
change in future.
The only deliberately incompatible change is in the Win32::OLE
module. While the Activeware port used the "OLE::" and "Win32::"
namespaces for the functionality contained in this module, this
port uses "Win32::OLE::" consistently. For a list of other
incompatibilities in Win32::OLE, see the embedded documentation
in "OLE/OLE.pm".
* The following five modules maintained by Aldo Calpini
<dada@divinf.it>:
Win32/Clipboard
Win32/Console
Win32/Internet
Win32/Shortcut
Win32/Sound
These also have been converted back to XS. I have added
bug fixes as I found them during the conversion process.
* Two useful modules maintained by Dave Roth <rothd@roth.net>.
Win32/ODBC
Win32/Pipe
These have only received just the bare modifications needed to
build them under MakeMaker. *.xs are really C/C++ files
masquerading as XS.
* The Win32::PerfLib module to access performance counters on
remote and local Windows NT systems, contributed by
Jutta M. Klebe <jmk@exc.bybyte.de>.
WHAT TO DO
----------
You can either use the binaries that come with this distribution,
or choose to recompile them from scratch (recommended if you have
a C compiler that is capable of building perl).
If you want to use the precompiled binaries:
+ Download:
http://www.perl.com/CPAN/authors/id/GSAR/perl5.00402-bindist04-bc.zip
Unzip that, thoroughly read the README file, and install it. Note that
the it comes with an older version of libwin32, but you'll be
completely replacing that in the next few steps. [Well not completely--
the Win32::AdminMisc module has been dropped since Dave Roth is
distributing newer versions compatible with the above binary
distribution, so the old AdminMisc will be left alone. See
http://www.roth.net/perl/adminmisc for how to get the latest.]
+ Make sure the newly installed perl is available from the command line.
Typing "perl -v" should report version 5.004_02. If not, make sure
you've added the installed location of perl.exe to your PATH correctly.
+ cd to wherever you uncompressed this distribution, and type
"install.bat". This should take care of installing everything in the
right place.
+ Many modules come with their own test files. You may want to
use them as a source of examples. Many of the test files will
only run on Windows NT, others may require Windows NT 4.0, and
still others may require Administrator privileges, or a full
fledged Windows network.
The following applies only if you need to rebuild using your C compiler.
(Note that you HAVE to do this if you built Perl yourself.) Otherwise,
skip to the next section.
This set of modules will build with perl5.004_01 and later on the Windows
NT platform. Building on Windows 95 is not supported (but it may be
possible if you use the 4DOS command shell, but YMMV).
+ First you need to build perl 5.004_01 or later (you will need
either Visual C++ 4.x+ or Borland C++ 5.02+), and install it. See
README.win32 in the perl distribution for details on how to build
perl for the Win32 platform.
+ That done, you need to extract this distribution into an NTFS
partition (the tests in the FileSecurity module and Net* modules
will fail otherwise). The testsuite for OLE needs Excel to
run. NetAdmin will only work if you have some kind of
live network connection, and are in a domain with a properly
configured domain controller. NetResource requires that you
be part of a domain or workgroup. You may also need
Administrator privileges for running some of the tests.
If one or more of these conditions will not be met, you may
wish to build in the subdirectories one by one. The steps
below will work either at the toplevel directory, or in each
of the individual extension subdirectories.
+ You need either MS Visual C++ (OLE needs 4.2b, NetAdmin needs ver.
4.x+, Internet needs ver. 5.0. ver. 2.0 should suffice for the
others) or Borland C++ 5.02. Make sure you have the full installation
of either of these compilers ("Minimal" installations or CDROM-based
installations may have problems finding all the libraries).
+ If the Internet extension doesn't build due to lack of libraries
(the wininet.h header is included), fetch the libraries from
Aldo Calpini's website: "http://www.divinf.it/dada/perl/internet/".
Look for a file named "WinInet.zip". If the wininet.h or wininet.dll
in your system are newer than the ones in WinInet.zip, discard them
before copying WinInet.lib into the Internet/ directory. [Aldo's
site doesn't seem to exist anymore. You should be able to get
the files from http://www.microsoft.com/ if you look around.]
+ Remove the 'blib' directory (it contains the precompiled binaries)
+ perl Makefile.PL [either at toplevel or in subdirs]
+ $MAKE [either at toplevel or in subdirs]
+ $MAKE test [optional, some interactive tests]
+ $MAKE install [either at toplevel or in subdirs]
$MAKE above stands for either "dmake" or "nmake" depending on your
available compiler, and perl configuration.
WHAT THEN
---------
A brief statment of intent: I am doing this to ease the transition
for many people who may wish to start using the latest perl on win32
platforms. Long term development of these modules remains the
responsibility of the respective authors.
I wish to thank the authors of these modules for their effort in making
them useful, and for making them freely available.
If you find any problems with these modules, kindly report them to
me. While I have fixed many problems in these modules, I may also have
introduced brand new bugs in the process :)
Suggestions, patches, testsuite additions, wholesale rewrites and
additional ports of modules welcome.
Enjoy!
Gurusamy Sarathy
gsar@umich.edu
11 May 1998
WHATEVER
--------
Copyright for many of the modules is held by their respective authors.
Look in the module subdirectories for any conditions of use.
The following copyright applies to all files that don't have an explicit
copyright statement:
(c) 1995 Microsoft Corporation. All rights reserved.
Developed by ActiveWare Internet Corp., http://www.ActiveWare.com
Other modifications (c) 1997, 1998 by Gurusamy Sarathy <gsar@umich.edu>
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the README file
of the Perl distribution.
------------------------------
Date: Tue, 02 Jun 1998 18:06:33 GMT
From: John Porter <jdporter@min.net>
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <357440D6.4309@min.net>
Tom Christiansen wrote:
> In comp.lang.perl.misc, Tom.Grydeland@phys.uit.no (Tom Grydeland) writes:
> :The major complaint about using C<map> in void context is that it
> :creates a (possibly large) return value which is then discarded.
>
> No, the major complaint is backwards logic confusing people.
Haven't heard that complaint much.
But certain noted Perl authors have yelled many times in recents
months that map in void context is bad for exactly the reason
Tom G. said.
Oh, you meant *your* major complaint.
John Porter
------------------------------
Date: Tue, 2 Jun 1998 11:07:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <MPG.fdddf434918e512989687@hplntx.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <6l1a5i$kbr$3@csnews.cs.colorado.edu>, tchrist@mox.perl.com
says...
...
> I can't see why people use
>
> map { s/foo/bar/ } @list;
> grep { s/foo/bar/ } @list;
>
> when they could more clearly write:
>
> for (@list) { s/foo/bar/ }
>
> Put the important thing first.
Great advice! Yet many Perl stylists write things like this:
die 'like a dog' unless something_good_happens();
instead of
something_good_happens() or die 'like a dog';
The Blue Camel makes its preference for the latter quite clear (p. 97,
bottom) but still has this (p. 93, bottom):
next unless ($dev, $ino, $mode) = stat $file;
Style points count!
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Tue, 02 Jun 1998 18:20:45 GMT
From: John Porter <jdporter@min.net>
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <3574442A.4332@min.net>
Tom Christiansen wrote:
>
> In comp.lang.perl.misc, Tom.Grydeland@phys.uit.no (Tom Grydeland) writes:
> :The major complaint about using C<map> in void context is that it
> :creates a (possibly large) return value which is then discarded.
>
> No, the major complaint is backwards logic confusing people.
So, you're fundamentally opposed to the ST?
Or are back-to-front pipelines o.k. as long the end result isn't
discarded?
> Put the important thing first.
Why is
foreach $city ( keys %USSR )
more "important" than
nuke( $city );
???
John Porter
>
> --tom
> --
> "Don't let it get to you. Shout happens." --Larry Wall
------------------------------
Date: 2 Jun 1998 18:41:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <6l1h19$9l2$3@client3.news.psi.net>
Tom Christiansen (tchrist@mox.perl.com) wrote on MDCCXXXVI September
MCMXCIII in <URL: news:6l1a5i$kbr$3@csnews.cs.colorado.edu>:
++ [courtesy cc of this posting sent to cited author via email]
++
++ In comp.lang.perl.misc, Tom.Grydeland@phys.uit.no (Tom Grydeland) writes:
++ :The major complaint about using C<map> in void context is that it
++ :creates a (possibly large) return value which is then discarded.
++
++ No, the major complaint is backwards logic confusing people.
If that's a problem, then we should argue to get rid of map (), grep ()
and sort () entirely, as the backwards logic doesn't spring to life in
void context.
++ do {{
++ open(OWNER, "< $whosegot") || last;
++ my $lockee = <OWNER>;
++ chomp($lockee);
++ printf STDERR "%s $0\[$$]: lock on %s held by %s\n",
++ scalar(localtime), $pathname, $lockee;
++ close OWNER;
++ }} if $Debug;
++
++ I can't see why people use
++
++ map { s/foo/bar/ } @list;
++ grep { s/foo/bar/ } @list;
++
++ when they could more clearly write:
++
++ for (@list) { s/foo/bar/ }
++
++ Put the important thing first.
Sometimes the conversion is more important than where the data is coming from.
Besides, do you never write things like:
print scalar (localtime (time - 3600));
That's just as backwards as map. The notation of composite functions
predates procedurial programming by a long time.
Abigail
--
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
${qq$\x5F$} = q 97265646f9 and s g..g;
qq e\x63\x68\x72\x20\x30\x78$&eggee;
{eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'
------------------------------
Date: 2 Jun 1998 18:44:50 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <6l1h72$2df$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
lr@hpl.hp.com (Larry Rosler) writes:
:The Blue Camel makes its preference for the latter quite clear (p. 97,
:bottom) but still has this (p. 93, bottom):
:
:next unless ($dev, $ino, $mode) = stat $file;
Yes, that's perfectly fine. "next if" is part of the culture.
In fact, Larry also writes (and blesses)
die unless defined($pid = fork);
Let's not get arried away with this. The point is that writing loops
that aren't loops is unnecessarily obfuscatory. I can call bar() at the
end of my foo() function, or I can just goto &bar instead. But I don't.
--tom
--
ENOSIG: This signature file is empty.
------------------------------
Date: Tue, 02 Jun 1998 18:11:49 +0100
From: Andrew Boothman <andrew@boothman.easynet.co.uk>
Subject: mSQL Perl Module Under Win'95 - Problem
Message-Id: <35743255.92219148@boothman.easynet.co.uk>
Hi!
I've downloaded and installed the msql.pm module, properly patched for
use under the activestate port of perl.
But the script does not appear to be working properly, even though I'm
just using examples from the docs.
My script is:
----
use Msql;
$dbh = Msql->connect('localhost', 'test');
print $dbh->database;
$sth = $dbh->query('select * from test1');
print $sth->numrows;
$dbh = undef;
----
And when I run it, perl (with -w) returns:
----
Use of uninitialized value at msql.pl line 3.
Connect: No error
Can't call method "database" without a package or object reference at
msql.pl line 5.
----
perl -v returns:
----
This is perl, version 5.003_07
Copyright 1987-1996, Larry Wall
+ suidperl security patch
Win32 port Copyright (c) 1995-1996 Microsoft Corporation.
All rights reserved.
Developed by ActiveWare Internet Corp.,
http://www.ActiveWare.com
Perl for Win32 Build 313 - Built 13:30:50 Nov 4 1997
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.
----
and perl -V returns:
----
Summary of my perl5 (patchlevel 1) configuration:
Platform:
osname=MSWin32, osver=3.51, archname=i386-win32
uname=''
hint=recommended
Compiler:
cc='cl', optimize=''
cppflags=''
ccflags =''
ldflags =''
stdchar='char', d_stdstdio=, usevfork=false
voidflags=15, castflags=0, d_casti32=, d_castneg=
intsize=4, alignbytes=4, usemymalloc=n, randbits=15
Libraries:
so=dll
libpth=
libs=
libc=
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=pll, d_dlsymun=
cccdlflags='', ccdlflags='', lddlflags=''
Characteristics of this binary (from libperl):
Built under MSWin32
Compiled at Nov 4 1997 13:30:50
@INC:
E:\andrew\as-perl\lib\i386-win32
E:\andrew\as-perl\lib
.
----
I'd really appriciate any light you can shed on this.
Thanks!!
--
Andrew Boothman : andrew@boothman.easynet.co.uk
(http://easyweb.easynet.co.uk/~boothman/andrew/)
"Do geography teachers eat Water Table biscuits?"
- Me
------------------------------
Date: Tue, 2 Jun 1998 12:20:24 +0000
From: rick@internetx.net ("Rick Bauman")
Subject: perl 5.004_04 question
Message-Id: <19980602161143.AAA8988@sub.internetx.net>
I recently installed Version 5.004_04 on a HPUX 10.20 machine, CGI
scripts run fine, but command line scripts, including ones that
worked before(on 5.003m), and ones provided with the perl distribution, such as
find2perl all come up with the same 3 errors:
Variable Syntax
use: command not found
require: command not found
any ideas on what I can do to fix this would be greatly appreciated.
t
Rick Bauman
System Administrator/Internet Express
rick@internetx.net www.internetx.net
finger rick@internetx.net for pgp public key
http://www.lowcountry.net/
Lowcountry Free Software Archives
------------------------------
Date: 02 Jun 1998 18:10:32 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Perl class for newbie?
Message-Id: <1998060218103300.OAA20319@ladder01.news.aol.com>
Hi Dan:
>> > Can anyone recommend a good Perl course for a non programmer? Perhaps
>> > something that teaches the basics of Perl along with general
>> > programming concepts?
That is quite a bit to get into one class. A course that teaches general
programming
concepts adequately is probably the most you can manage in one shot.
>> I don't recommend that. Perl is a very powerful, flexible language. Perl
>> lets you break the rules when you know better. But how can you know better
>> unless you first learn the rules?
I would agree in principle. Because of its flexibility, Perl is not an ideal
choice
for "learning the rules". However, lots of people have learned Perl on their
own once they knew enough about programming to ask the right questions.
>> For a first programming language, I usually recommend Pascal - not
>> because it's a great language that you'll want to use for everything, but
Pascal also "enforces" the "rules". It insists you define everything, think
about
the order of things in the program, ......
>Thanks for your advice. I understand what you are saying; however I
>have been tasked by my boss to learn Perl, and the company will pay
>for a class. I need to take it this quarter. Any recommendations?
>
>By the way, I did check into the local community college; they don't
>offer Pascal but there is an introductory course in C, which I am
>thinking of enrolling in. Do you think that would be a good
>substitute?
Have a conversation with the instructor. Explain what you are trying to do.
Your explanation to the newsgroup was very good. The instructor should
be able to say, "Yes, good choice." or "No, a better choice would be..."
Take an "I don't know" or "I don't understand" as an "Absolutely Not" and
look elsewhere - the instructor might not use perl personally, but he/she
should know if they are teaching "concepts of programming that may be
useful with other languages.
If you find the right course, buy a copy of "Learning Perl" - and see how
similar topics overlap as you progress through the course.
Good Luck,
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Tue, 2 Jun 1998 12:01:10 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl class for newbie?
Message-Id: <m4b1l6.44o.ln@localhost>
Dan Franco (dfrancoDONTSPAM@fore.com) wrote:
: By the way, I did check into the local community college; they don't
: offer Pascal but
You may also want to check the "Continuing Education" department
(at 2 _and_ 4 year schools), rather than just the "for credit" offerings...
Learning to program *and* learning Perl is going to be Very Hard.
I would use the "free" class to learn programming fundamentals,
rather than looking for "a Perl class". ( C is OK if you can't find
Pascal)
Good luck!
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 2 Jun 1998 11:37:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl module for doing a unix 'which'?
Message-Id: <MPG.fdde659f7c1bcf989688@hplntx.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <6l19g2$kbr$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com
says...
> #!/usr/bin/perl
> # pgrep - grep for files in your path
> chop($cwd = `pwd`) unless $cwd = $ENV{'PWD'};
> $regexp = shift || die "usage: $0 regexp\n";
> for $dir (split(/:/,$ENV{'PATH'})) {
> chdir($dir =~ m#^/# ? $dir : "$cwd/$dir") || next;
> opendir(DOT, '.') || next;
> while ($_ = readdir(DOT)) {
> next unless /$regexp/o;
> next unless -f;
> next unless -x _;
> print "$dir/$_\n";
> }
> }
>
> This cross-platform program has been tested on BSD, Linux, *and* SunOS.
> It has not, of course, been tested on CP/M or MVS.
Did you leave out some less-obsolete operating systems? :-)
With two minor system-dependent changes, it works on Windows/DOS also.
It would be easy to test $^O and choose the correct regexes:
for $dir (split(/;/,$ENV{'PATH'})) {
chdir($dir =~ m#^[A-Za-z]:[/\\]# ? $dir : "$cwd/$dir");
I don't know how to do this for the Mac, but it should be easy also.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Tue, 02 Jun 1998 16:58:20 GMT
From: seeker79@yahoo.com
Subject: Re: Perl on Windows32
Message-Id: <6l1avc$vvg$1@nnrp1.dejanews.com>
> I want to check my CGI Scripts offline... So I wanted to know how to do
> that. It seems I have to use a Server program and a perl program.
>
You might want to try Perl Builder at http://www.solutionsoft.com/perl.htm.
It is an IDE for Perl and will allow you to test CGI scripts without a
webserver.
Dave Seeker
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 02 Jun 1998 16:47:12 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: perl question
Message-Id: <Pine.GSO.3.96.980602094436.15370l-100000@user2.teleport.com>
On Tue, 2 Jun 1998 dow.jones@home.se wrote:
> Subject: perl question
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> I don't know how to store the information from the first text-file. I
> need to do that because I have to compare the information extracted from
> the second textfile to the first.
This sounds like a job for a hash.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2788
**************************************