[24007] in Perl-Users-Digest
Perl-Users Digest, Issue: 6205 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 2 18:05:49 2004
Date: Tue, 2 Mar 2004 15:05:09 -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, 2 Mar 2004 Volume: 10 Number: 6205
Today's topics:
Re: DBI->connect fails with perl 5.8? <pkent77tea@yahoo.com.tea>
Re: DBI->connect fails with perl 5.8? <andy@andyh.co.uk>
How do I reference myself? (D. Alvarado)
Re: How do I reference myself? <ittyspam@yahoo.com>
Re: How do I reference myself? <1usa@llenroc.ude>
Re: How do I reference myself? <twhu@lucent.com>
Re: How do I reference myself? <cyde@umd.edu>
Re: Macros <chatiman@free.fr>
Re: Need to find a file on the execution PATH <me@privacy.net>
Re: Need to find a file on the execution PATH <me@privacy.net>
Re: perl implementation of rand() and srand() <simschla@freesurf.ch>
Re: perl implementation of rand() and srand() <simschla@freesurf.ch>
Perl running on Windows and Berkeley DB (Researcher)
Re: process communication design (c++ <-> perl) <jgibson@mail.arc.nasa.gov>
Re: Sexy code? <pkent77tea@yahoo.com.tea>
Re: split into array <g_klinedinst@hotmail.com>
Re: Spreadsheet::WriteExcel (Christopher Hamel)
Re: Spreadsheet::WriteExcel (John McNamara)
Re: Suppress "mytime redefined" message from Benchmark? <ddunham@redwood.taos.com>
Re: Suppress "mytime redefined" message from Benchmark? <krahnj@acm.org>
Re: Suppress "mytime redefined" message from Benchmark? <noreply@gunnar.cc>
use question <nomail@please.post.com>
Re: use question (Peter Scott)
Re: while loop display of files in a directory <krahnj@acm.org>
wish: a comparison operator that is no more sensitive t <jidanni@jidanni.org>
Re: wish: a comparison operator that is no more sensiti <ThomasKratz@REMOVEwebCAPS.de>
Re: wish: a comparison operator that is no more sensiti <gnari@simnet.is>
Re: wish: a comparison operator that is no more sensiti <usenet@morrow.me.uk>
Re: wish: a comparison operator that is no more sensiti <dwall@fastmail.fm>
Re: wish: a comparison operator that is no more sensiti <tzz@lifelogs.com>
Re: wish: a comparison operator that is no more sensiti <tzz@lifelogs.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 02 Mar 2004 22:48:09 +0000
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: DBI->connect fails with perl 5.8?
Message-Id: <pkent77tea-F07D71.22480802032004@pth-usenet-01.plus.net>
In article <%BU0c.36$u61.297@news.oracle.com>, user@domain.invalid
wrote:
> $dbh = DBI->connect('dbi:Oracle:',"APPS","APPS") or die ("Cannot get
This may be a red herring but for what it's worth we always give the SID
in the DSN, like:
my $dbh = DBI->connect('dbi:Oracle:DM0', 'unittest', 'secret', {
RaiseError => 1}) or die...
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Tue, 02 Mar 2004 23:07:34 +0000
From: Andy Hassall <andy@andyh.co.uk>
Subject: Re: DBI->connect fails with perl 5.8?
Message-Id: <li4a40l239ps6trq6flq2n8oqlf7rlfien@4ax.com>
On Tue, 02 Mar 2004 10:27:56 +0530, user@domain.invalid wrote:
>I am using DBI to connect to an Oracle database.
>
>The following is the simple code to test for the connection :
>
[snip]
>$dbh = DBI->connect('dbi:Oracle:',"APPS","APPS") or die ("Cannot get
>handle to db");
[snip]
>
>I have set all the environment variables (TWO_TASK, TNS_ADMIN, ORACLE_HOME).
>
>The above works fine with perl 5.6.1, but exits with the following on
>perl 5.8 :
>
>sh-2.05$ /local/perl5.8/bin/perl test1.pl
>DBI->connect() failed: (UNKNOWN OCI STATUS 1804) OCIInitialize. Check
>ORACLE_HOME and NLS settings etc. at test1.pl line 14
>Cannot get handle to db at test1.pl line 14.
>sh-2.05$
>
>Please let me know what I am doing wrong ....
Most likely, you have compiled DBD::Oracle against one version of Oracle, and
are trying to run it using an Oracle home of another (previous) version. This
message certainly appears when trying to use a 9i compiled version with 8i
libraries.
Check your ORACLE_HOME (as the error says) and set it (and any subsidiary
variables such as LD_LIBRARY_PATH) to the same one that DBD::Oracle was
compiled against.
Or recompile DBD::Oracle to match your current settings.
Since 5.6 and 5.8 aren't binary compatible you're clearly running two
separately compiled versions of DBD::Oracle; the Perl version is a red herring,
it's down to the Oracle libraries.
--
Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
------------------------------
Date: 2 Mar 2004 13:11:28 -0800
From: laredotornado@zipmail.com (D. Alvarado)
Subject: How do I reference myself?
Message-Id: <9fe1f2ad.0403021311.13ecad20@posting.google.com>
Hello,
From within my perl script, I want to be able to print my file
name. For example, if my file were named "test.pl", I'd link to see:
> perl test.pl
> test.pl
>
print out. I am on Solaris, but I'd prefer the solution be OS
independent. Thanks - Dave
------------------------------
Date: Tue, 2 Mar 2004 16:28:39 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: How do I reference myself?
Message-Id: <20040302162808.V27834@dishwasher.cs.rpi.edu>
On Tue, 2 Mar 2004, D. Alvarado wrote:
> Hello,
> From within my perl script, I want to be able to print my file
> name. For example, if my file were named "test.pl", I'd link to see:
>
> > perl test.pl
> > test.pl
> >
>
> print out. I am on Solaris, but I'd prefer the solution be OS
> independent. Thanks - Dave
>
print "$0\n";
you need to read perldoc perlvar
Paul Lalli
------------------------------
Date: 2 Mar 2004 21:37:44 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: How do I reference myself?
Message-Id: <Xns94A0A9290D369asu1cornelledu@132.236.56.8>
laredotornado@zipmail.com (D. Alvarado) wrote in
news:9fe1f2ad.0403021311.13ecad20@posting.google.com:
> Hello,
> From within my perl script, I want to be able to print my file
> name. For example, if my file were named "test.pl", I'd link to see:
>
>> perl test.pl
>> test.pl
>>
>
> print out. I am on Solaris, but I'd prefer the solution be OS
> independent. Thanks - Dave
You should look at the documentation before posting here:
perldoc perlvar
###
use strict;
use warnings;
use File::Basename;
print basename($0);
__END__
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Tue, 2 Mar 2004 16:31:01 -0500
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: How do I reference myself?
Message-Id: <c22uem$n4m@netnews.proxy.lucent.com>
"D. Alvarado" <laredotornado@zipmail.com> wrote in message ...
> Hello,
> From within my perl script, I want to be able to print my file
> name. For example, if my file were named "test.pl", I'd link to see:
>
> > perl test.pl
> > test.pl
> >
>
> print out. I am on Solaris, but I'd prefer the solution be OS
> independent. Thanks - Dave
print "$0\n";
------------------------------
Date: Tue, 02 Mar 2004 17:49:43 -0500
From: Cyde Weys <cyde@umd.edu>
Subject: Re: How do I reference myself?
Message-Id: <c23327$odd$1@grapevine.wam.umd.edu>
"I"
------------------------------
Date: Tue, 2 Mar 2004 20:08:21 +0100
From: "chatiman" <chatiman@free.fr>
Subject: Re: Macros
Message-Id: <4044db9b$0$28434$636a15ce@news.free.fr>
"Ben Morrow" <usenet@morrow.me.uk> a écrit dans le message de news:
c22kr2$3en$4@wisteria.csv.warwick.ac.uk...
> > Or is there a way to access the caller's function local variables ?
>
> Why do you want to do this? There is almost certainly a better way.
>
Has you saw in my previous post, I'm trying to "localize" my application
(ie support different languages). I took a look at Locale::Maketext but it
seems
to complex to use and require additionnal packages.
So I thought to write a simple module which will do what I want :
The idea is to have a text file for each language (or a simple hash) like:
id1: the text associated to id1 with $variableA
And also I will have a function:
sub my_gettext {
my ($id) = @_
return eval "return \"$localized{$id}\"";
}
where localized is a hash associated to the configuration file
This would work when variable are not localized with "my" ...
But to be "cleaner" I would like it to work in anycases
for that I need to access the caller's localized variables or use macros
But the main idea is to keep it simple ...
> However, if you must: PadWalker.
>
I'll look at it
> Ben
>
------------------------------
Date: Tue, 02 Mar 2004 11:40:26 -0800
From: "davido@codethought.nospamforme.com" <me@privacy.net>
Subject: Re: Need to find a file on the execution PATH
Message-Id: <4oo940hmfu6ijrcdbfnf302okuoa3edua8@4ax.com>
On Tue, 2 Mar 2004 11:54:29 -0500, Paul Lalli <ittyspam@yahoo.com>
wrote:
>Take a look at the modules File::Find and File::Spec (specifially, the
>File::Spec->path() function). Both are in the standard distribution.
Perfect! Do you know how to squelch the messages when find *doesn't*
find something tho? I'm seeing this:
Can't stat C:\Perl\bin\/csdfommand.com: No such file or directory
at sbt_build_deploy_tools.pm line 535
Can't stat C:\Program Files\Borland\BDS\1.0\Bin/csdfommand.com: No
such file or
directory
at sbt_build_deploy_tools.pm line 535
Can't stat c:\j2sdk1.4.1_05\bin/csdfommand.com: No such file or
directory
at sbt_build_deploy_tools.pm line 535
Can't stat C:\WINDOWS\system32/csdfommand.com: No such file or
directory
------------------------------
Date: Tue, 02 Mar 2004 12:19:47 -0800
From: "davido@codethought.nospamforme.com" <me@privacy.net>
Subject: Re: Need to find a file on the execution PATH
Message-Id: <a2r940ttpp3cpmeir9m2tv60bbbi0d2tpk@4ax.com>
On Tue, 02 Mar 2004 11:40:26 -0800,
"davido@codethought.nospamforme.com" <me@privacy.net> wrote:
>On Tue, 2 Mar 2004 11:54:29 -0500, Paul Lalli <ittyspam@yahoo.com>
>wrote:
>
>>Take a look at the modules File::Find and File::Spec (specifially, the
>>File::Spec->path() function). Both are in the standard distribution.
>
>Perfect! Do you know how to squelch the messages when find *doesn't*
>find something tho? I'm seeing this:
Nevermind.. Apparently that was due to a "use diagnostics" statement
in my perl module.
Thanks again!
------------------------------
Date: Tue, 2 Mar 2004 23:45:51 +0100
From: Simon <simschla@freesurf.ch>
Subject: Re: perl implementation of rand() and srand()
Message-Id: <1sjdlf0mh53l6$.1fzri5w7ry8q$.dlg@40tude.net>
On Tue, 2 Mar 2004 00:04:07 +0000 (UTC), Ben Morrow wrote:
> In pp.c, the functions PP(pp_rand) and PP(pp_srand). Basically, they
> just call whatever C-library implementation Configure found:
i'm currently checking this path to find out if this is the help i need to
reimplement the perl random number generator. but thx for that hint!
> I would
> have thought that the usual Java random number function would do just
> fine.
The java rng is fine, but does produce different random numbers than the
one provided by perl. And since I have to reproduce the same number
sequences, i can't use java's rng.
Simon
------------------------------
Date: Wed, 3 Mar 2004 00:02:44 +0100
From: Simon <simschla@freesurf.ch>
Subject: Re: perl implementation of rand() and srand()
Message-Id: <67x4nl11a36p$.1fke0uxh37le6$.dlg@40tude.net>
On 02 Mar 2004 01:23:29 GMT, Martien Verbruggen wrote:
> Perl's rand() just calls whatever rand() function the system it runs
> on provides, and those are notoriously non-identical. In later
> versions of Perl, the person compiling Perl can actually override what
> pseudo-random generator they want to use.
>
> In other words, rand() in Perl is not guaranteed to produce the same
> results at all times.
this is exactly my problem. since i need to produce the same random numbers
as the original razor client, as i believe (see below).
> Are you sure you interpreted the razor code correctly? I couldn't
> actually find a document that describes the server-client exchange.
here is a snipplet from razor source code, where different positions inside
a mail-messages are "randomly" chosen for computing an identifier (hash):
<snip>
srand($$self{seed});
my @content = split /$$self{separator}/, $content;
my $lines = scalar @content;
# Randomly choose relative locations and section sizes (in percent)
my $sections = 6;
my $ssize = 100/$sections;
my @rel_lineno = map { rand($ssize) + ($_*$ssize) } 0 .. ($sections-1);
my @lineno = map { int(($_ * $lines)/100) } @rel_lineno;
my @rel_offset1 = map { rand(50) + ($_*50) } qw(0 1);
my @rel_offset2 = map { rand(50) + ($_*50) } qw(0 1);
</snip>
these positions are then used to compute a hash which is then compared
against stored hashes on the server. i assume that if i chose other
positions in the message, i never end up with a hash, that represents the
message in the right way, when trying to compare with the db on the server
side. don't you agree?
Simon
------------------------------
Date: 2 Mar 2004 15:02:23 -0800
From: phb2911@hotmail.com (Researcher)
Subject: Perl running on Windows and Berkeley DB
Message-Id: <2d337d68.0403021502.5db6e55e@posting.google.com>
I did everything I could to install Berkeley DB for perl running on a
windows system, I tryed unsuccessfully getting online help or reading
the README file but I only found help on installing it on a UNIX
machine. Can anybody help me?
Regards.
Pablo Borges
------------------------------
Date: Tue, 02 Mar 2004 13:31:23 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: process communication design (c++ <-> perl)
Message-Id: <020320041331230645%jgibson@mail.arc.nasa.gov>
In article <40445cd0@sia.uibk.ac.at>, Hannes
<remove_Hannes.Krueger@uibk.ac.at> wrote:
> Hi,
>
> I'm trying to find a better design for communication between a c++ and a
> perl/Tk program (processes running at the same time).
>
> Both processes show some graphical content in a window.
> If the perl/Tk process updates the view (by user interaction) the c++
> program should do so also (immediately) and vice versa.
> The values of some variables have to be exchanged.
>
> Formerly I tried this with an SysV IPC shared memory block, which contains
> the value of some variables. The "signal" to the other process to update
> was implemented via signals (e.g. SIGUSR2). This works fine for the one
> direction (perl->c++) but not for the other way due to some "property" of
> safe signal handling (in Perl) and Tk MainLoop (see topics: "Tk +
> perl-5.8.0 eat and delays signals" and the recent thread "Toplevel doesn't
> update").
>
> While trying to find the best design for such a task a few things should be
> considered:
> 1) The production environment: Perl 5.8, Tk 800.024
> 2) Preferably the solution should be platform independent
> 3) and (of cause) fast and safe.
>
> Has anybody a good idea? Or tried something similar with success?
> Any ideas are welcome...
How often do you need to update the screen? And what latency can you
live with? If not too fast, I would put a counter in shared memory and
increment it everytime shared memory was updated. You can have each
process poll the counter every second, compare the current value in
shared memory with the previous value fetched, and fetch the values in
shared memory when the counter changes.
Are you using a locking mechanism to protect shared memory from
concurrent access? Something like semaphores?
I used the above scheme very successfully, but didn't need really fast
update rates. The screens were changing every 10-15 seconds or so, and
a fraction of a second latency was OK.
------------------------------
Date: Tue, 02 Mar 2004 22:53:44 +0000
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Sexy code?
Message-Id: <pkent77tea-F92D07.22534402032004@pth-usenet-01.plus.net>
In article <db27ea77.0403011341.bb66c9@posting.google.com>,
miko@idocs.com (Miko O'Sullivan) wrote:
> "Right THERE", she says, and puts her finger right under a word:
>
> $exitcode
>
> Interesting how a paradigm shift can really change the meaning of
> things.
I've raised a smile at variables such as $hitCount or $hits - sometimes
the code in question deserved it and sometimes not :-)
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Tue, 02 Mar 2004 11:52:46 -0800
From: Greg Klinedinst <g_klinedinst@hotmail.com>
Subject: Re: split into array
Message-Id: <25m940tee2uktuladipik8csu1m043fn0n@4ax.com>
On 02 Mar 2004 18:21:22 GMT, ctcgag@hotmail.com wrote:
>I think that if one wants something spelled out in exhaustive detail
>equivalent to symbolic logic, one would read the source code rather than
>the documentation.
>
>I thought the documentation was pretty effective at conveying the meaning
>when I first read it.
All I want is complete, unambiguous instructions for each function
telling me everything that is allowed as an argument and what happens
in each case. A table would be ideal, sentences would be ok too.
Obviously there is a problem or else the OP, Gunnar and I wouldn't
have said anything. The symbolic logic was put there to make it clear
that we can't put assumptions in documentation for something technical
like a programming language.
-Greg
------------------------------
Date: 2 Mar 2004 11:10:17 -0800
From: hamelcd@hotmail.com (Christopher Hamel)
Subject: Re: Spreadsheet::WriteExcel
Message-Id: <4f60d5b3.0403021110.5c6f4de2@posting.google.com>
"Richard S Beckett" <spikeywan@bigfoot.com.delete.this.bit> wrote in message news:<c227s3$3td$1@newshost.mot.com>...
> I don't think you can with WriteExcel. I would spend the time learning
> Win32::OLE, as I can do much more with that.
>
> WriteExcel's OK it you just want to quickly produce a new spreadsheet.
It's much more than that... It's a Godsend if you're creating MS
Excel Spreadsheets on a platform other than Windows. We create
Excel-based reports in Unix and users FTP them down from their Windows
clients.
Spreadsheet::ParseExcel can read the spreadsheet file, without
Windows, in the same manner that WriteExcel can create one.
Regards,
Chris
------------------------------
Date: 2 Mar 2004 11:51:37 -0800
From: jmcnamara@cpan.org (John McNamara)
Subject: Re: Spreadsheet::WriteExcel
Message-Id: <8cceb2da.0403021151.3d9ed896@posting.google.com>
Fabio wrote in message news:<c21lb5$9c2$3@nemesis.news.tpi.pl>...
> But how can I put some values into the cells of an existing worksheet?
On Windows you can use the Win32::OLE module and COM automation to
modify an existing Excel file.
On Unix/Windows you can use Spreadsheet::ParseExcel to read an Excel
file and Spreadsheet::WriteExcel to rewrite it.
The Spreadsheet::ParseExcel package also contains a module called
Spreadsheet::ParseExcel::SaveParser which will let you read and
rewrite an Excel workbook. It is a combination of
Spreadsheet::WriteExcel and Spreadsheet::ParseExcel.
http://search.cpan.org/search?dist=Spreadsheet-ParseExcel
Here is an example:
#!/usr/bin/perl -w
use strict;
use Spreadsheet::ParseExcel::SaveParser;
# Open the template with SaveParser
my $parser = new Spreadsheet::ParseExcel::SaveParser;
my $template = $parser->Parse('template.xls');
my $sheet = 0;
my $row = 0;
my $col = 0;
# Get the format from the cell
my $format = $template->{Worksheet}[$sheet]
->{Cells}[$row][$col]
->{FormatNo};
# Write data to some cells
$template->AddCell(0, $row, $col, 1, $format);
$template->AddCell(0, $row+1, $col, "Hello", $format);
# Add a new worksheet
$template->AddWorksheet('New Data');
# The SaveParser SaveAs() method returns a reference to a
# Spreadsheet::WriteExcel object. If you wish you can then
# use this to access any of the methods that aren't
# available from the SaveParser object. If you don't need
# to do this just use SaveAs().
#
my $workbook;
{
# SaveAs generates a lot of harmless warnings about unset
# Worksheet properties. You can ignore them if you wish.
local $^W = 0;
# Rewrite the file or save as a new file
$workbook = $template->SaveAs('new.xls');
}
# Use Spreadsheet::WriteExcel methods
my $worksheet = $workbook->sheets(0);
$worksheet->write($row+2, $col, "World2");
$workbook->close();
__END__
Note, however that this will only rewrite the features that
Spreadsheet::WriteExcel can handle so macros, graphs and some other
features in the original Excel file will be lost.
John.
--
sub item_exists { # Given an item and an array, return 1 if the
@_{@_} = 1; # item is an element of the array or else 0.
$_{$_[0]} ? 0:1; #
} # Ex. item_exists("red", @colours);
------------------------------
Date: Tue, 02 Mar 2004 19:44:37 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Suppress "mytime redefined" message from Benchmark?
Message-Id: <Fu51c.19294$s82.2008@newssvr29.news.prodigy.com>
Jeff Boes <jboes@nexcerpt.com> wrote:
> $ perl -w -e 'no warnings; use Benchmark qw(:hireswallclock)'
> Subroutine Benchmark::mytime redefined at
> /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.
> $ perl -w -e 'no warnings qw(redefine); use Benchmark qw(:hireswallclock)'
> Subroutine Benchmark::mytime redefined at
> /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.
Both of those attempts won't work because the 'no warnings' isn't read
until runtime, while the 'use' is done earlier.
Is this a bug with Benchmark? I suppose you could report it.
Add your 'no warnings qw(redefine)' to Benchmark.pm between 455 and 456.
--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Tue, 02 Mar 2004 22:37:34 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Suppress "mytime redefined" message from Benchmark?
Message-Id: <40450CA7.DBCCAC4@acm.org>
Jeff Boes wrote:
>
> Hmm ... this one's got me puzzled:
>
> $ perl -v
>
> This is perl, v5.8.3 built for i686-linux
>
> $ perl -w -e 'no warnings; use Benchmark qw(:hireswallclock)'
> Subroutine Benchmark::mytime redefined at
> /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.
>
> $ perl -w -e 'no warnings qw(redefine); use Benchmark qw(:hireswallclock)'
> Subroutine Benchmark::mytime redefined at
> /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.
>
> Does anyone know of a way to completely suppress this warning? It's
> irritating, because I have a script running in cron that reports this
> message, over and over. (I don't want to suppress or redirect STDERR,
> because there may be other legitimate errors.)
The warnings pragma and the -w switch are incompatible.
perldoc perllexwarn
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 02 Mar 2004 23:51:08 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Suppress "mytime redefined" message from Benchmark?
Message-Id: <c233o0$1og8qh$1@ID-184292.news.uni-berlin.de>
Jeff Boes wrote:
>
> $ perl -w -e 'no warnings; use Benchmark qw(:hireswallclock)'
> Subroutine Benchmark::mytime redefined at
> /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.
>
> Does anyone know of a way to completely suppress this warning? It's
> irritating, because I have a script running in cron that reports
> this message, over and over. (I don't want to suppress or redirect
> STDERR, because there may be other legitimate errors.)
The -w switch is dynamically scoped, which means that it enables all
kinds of warnings also in modules that you use or require. The
warnings pragma is lexically scoped, so 'no warnings' only switches
off the warnings in the current file.
I suppose that the best solution is to drop the -w switch and enable
warnings lexically by doing
use warnings;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 2 Mar 2004 19:48:21 +0000 (UTC)
From: kj <nomail@please.post.com>
Subject: use question
Message-Id: <c22oe5$osb$1@reader2.panix.com>
If I want all the symbols exported by default by a module, plus a
few more, I find that the following works:
use Some_Module;
use Some_Module qw(some extra symbols);
Is there a way to achieve the same results in one line?
Thanks!
kj
------------------------------
Date: Tue, 02 Mar 2004 20:34:17 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: use question
Message-Id: <dd61c.669797$X%5.342823@pd7tw2no>
In article <c22oe5$osb$1@reader2.panix.com>,
kj <nomail@please.post.com> writes:
>
>
>
>If I want all the symbols exported by default by a module, plus a
>few more, I find that the following works:
>
>use Some_Module;
>use Some_Module qw(some extra symbols);
>
>Is there a way to achieve the same results in one line?
perldoc Exporter
use Some_Module qw(:DEFAULT some extra symbols);
--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/
------------------------------
Date: Tue, 02 Mar 2004 22:19:59 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: while loop display of files in a directory
Message-Id: <40450888.A80F646A@acm.org>
mike wrote:
>
> hi
>
> i did a code to show the files in a directory
> say
>
> while(<test*.txt>)
> {
> print ;
>
> }
>
> it will show all the files with beginning with test and ending with .txt
> but when i assigned it to a variable like this
>
> $files = "test\*\.txt";
> while(<"$files">)
> {
> print ;
> }
> it doesn't show the files.
> Why is this so?
You added quotation marks to the file glob but you probably don't have
any files that start with "test and end with .txt".
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 02 Mar 2004 10:37:41 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: wish: a comparison operator that is no more sensitive than printf
Message-Id: <87wu64nfd6.fsf@jidanni.org>
perldoc perlop says Testing for exact equality of floating-point equality or
inequality is not a good idea.
OK, perhaps add a new "squishy comparison operator" one could use so that even
this wouldn't overrun the last test at least on my computer:
$i=0; while($i<1){printf "$i\n"; $i+=.1};
$i=0; while($i<1){printf "%.19f\n",$i; $i+=.1}; #for details
The main frustration is that the < operator is much more sensitive to
tiny floating trailing digits than any of the printf defaults. I wish
there was a comparison operator "that was no more sensitive than printf".
------------------------------
Date: Tue, 02 Mar 2004 20:41:14 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: wish: a comparison operator that is no more sensitive than printf
Message-Id: <4044e46c.0@juno.wiesbaden.netsurf.de>
Dan Jacobson wrote:
> perldoc perlop says Testing for exact equality of floating-point equality or
> inequality is not a good idea.
>
> OK, perhaps add a new "squishy comparison operator" one could use so that even
> this wouldn't overrun the last test at least on my computer:
> $i=0; while($i<1){printf "$i\n"; $i+=.1};
^^^^
I think you mean:
$i=0; while($i<1){printf "%f\n", $i; $i+=.1}
or else you leave the formatting to the stringification with "".
> $i=0; while($i<1){printf "%.19f\n",$i; $i+=.1}; #for details
>
> The main frustration is that the < operator is much more sensitive to
> tiny floating trailing digits than any of the printf defaults. I wish
> there was a comparison operator "that was no more sensitive than printf".
Thomas
--
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</ #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..
------------------------------
Date: Tue, 2 Mar 2004 19:29:30 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: wish: a comparison operator that is no more sensitive than printf
Message-Id: <c22n8r$p9g$1@news.simnet.is>
"Dan Jacobson" <jidanni@jidanni.org> wrote in message
news:87wu64nfd6.fsf@jidanni.org...
> perldoc perlop says Testing for exact equality of floating-point equality
or
> inequality is not a good idea.
>
> OK, perhaps add a new "squishy comparison operator" one could use so that
even
> this wouldn't overrun the last test at least on my computer:
> $i=0; while($i<1){printf "$i\n"; $i+=.1};
if you need exactness try to use integers
$i=0; while($i<10){printf ($i/10)."\n"; $i+=1};
no amount of wishing for some magic will change the
basic reality of how floating point numbers are stored.
gnari
------------------------------
Date: Tue, 2 Mar 2004 20:16:49 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: wish: a comparison operator that is no more sensitive than printf
Message-Id: <c22q3h$7oc$1@wisteria.csv.warwick.ac.uk>
Dan Jacobson <jidanni@jidanni.org> wrote:
> perldoc perlop says Testing for exact equality of floating-point equality or
> inequality is not a good idea.
>
> OK, perhaps add a new "squishy comparison operator" one could use so that even
> this wouldn't overrun the last test at least on my computer:
> $i=0; while($i<1){printf "$i\n"; $i+=.1};
> $i=0; while($i<1){printf "%.19f\n",$i; $i+=.1}; #for details
>
> The main frustration is that the < operator is much more sensitive to
> tiny floating trailing digits than any of the printf defaults. I wish
> there was a comparison operator "that was no more sensitive than printf".
Ummm.... what's wrong with
printf('%.19f', $a) < printf('%.19f', $b)
?
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Tue, 02 Mar 2004 20:55:26 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: wish: a comparison operator that is no more sensitive than printf
Message-Id: <Xns94A0A1FC1F578dkwwashere@216.168.3.30>
Ben Morrow <usenet@morrow.me.uk> wrote:
> Dan Jacobson <jidanni@jidanni.org> wrote:
>> perldoc perlop says Testing for exact equality of floating-point
>> equality or inequality is not a good idea.
>>
>> OK, perhaps add a new "squishy comparison operator" one could use so
>> that even this wouldn't overrun the last test at least on my computer:
>> $i=0; while($i<1){printf "$i\n"; $i+=.1};
>> $i=0; while($i<1){printf "%.19f\n",$i; $i+=.1}; #for details
>>
>> The main frustration is that the < operator is much more sensitive to
>> tiny floating trailing digits than any of the printf defaults. I wish
>> there was a comparison operator "that was no more sensitive than
>> printf".
>
> Ummm.... what's wrong with
>
> printf('%.19f', $a) < printf('%.19f', $b)
>
> ?
I think you meant sprintf(), not printf().
------------------------------
Date: Tue, 02 Mar 2004 15:49:24 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: wish: a comparison operator that is no more sensitive than printf
Message-Id: <4nptbvq8iz.fsf@collins.bwh.harvard.edu>
On Tue, 02 Mar 2004, jidanni@jidanni.org wrote:
> perldoc perlop says Testing for exact equality of floating-point
> equality or inequality is not a good idea.
>
> OK, perhaps add a new "squishy comparison operator" one could use so
> that even this wouldn't overrun the last test at least on my
> computer:
[...]
> The main frustration is that the < operator is much more sensitive
> to tiny floating trailing digits than any of the printf defaults. I
> wish there was a comparison operator "that was no more sensitive
> than printf".
Right below the advice you mention is this code:
sub fp_equal {
my ($X, $Y, $POINTS) = @_;
my ($tX, $tY);
$tX = sprintf("%.${POINTS}g", $X);
$tY = sprintf("%.${POINTS}g", $Y);
return $tX eq $tY;
}
(at least since the Perl 5.6.1 docs)
Did you not see that code? Or are you asking just because you want a
new operator in Perl 5 (a wish very unlikely to be granted)?
Ted
------------------------------
Date: Tue, 02 Mar 2004 15:52:23 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: wish: a comparison operator that is no more sensitive than printf
Message-Id: <4nllmjq8e0.fsf@collins.bwh.harvard.edu>
On Tue, 2 Mar 2004, gnari@simnet.is wrote:
> if you need exactness try to use integers
>
> $i=0; while($i<10){printf ($i/10)."\n"; $i+=1};
>
> no amount of wishing for some magic will change the
> basic reality of how floating point numbers are stored.
I think the OP doesn't want exactness, but the illusion of it :)
Ted
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6205
***************************************