[31275] in Perl-Users-Digest
Perl-Users Digest, Issue: 2520 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 16 14:09:41 2009
Date: Thu, 16 Jul 2009 11:09:06 -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 Thu, 16 Jul 2009 Volume: 11 Number: 2520
Today's topics:
Re: cpan fails to work after machine relocation <josef.moellers@ts.fujitsu.com>
Re: FAQ 6.7 How can I make "\w" match national characte <whynot@pozharski.name>
Re: FAQ 6.7 How can I make "\w" match national characte <whynot@pozharski.name>
Re: getting return value of external application on win <alfonso.baldaserra@gmail.com>
moving a match into a subroutine (Stefan Ram)
Re: open()ing strings as filehandles <naveedm9@gmail.com>
Re: open()ing strings as filehandles <uri@stemsystems.com>
Re: Perl WTF (David Combs)
Re: Perl WTF (David Combs)
RegEx - finding the innermost block <m@epf.pl>
Re: RegEx - finding the innermost block <donatoaz@gmail.com>
Simple Regex Doubt <donatoaz@gmail.com>
Re: Why doesn't this 'next if' work? (Doug Miller)
Re: Why doesn't this 'next if' work? sln@netherlands.com
Re: Why doesn't this 'next if' work? <ben@morrow.me.uk>
Re: Why doesn't this 'next if' work? sln@netherlands.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 16 Jul 2009 09:47:34 +0200
From: Josef Moellers <josef.moellers@ts.fujitsu.com>
Subject: Re: cpan fails to work after machine relocation
Message-Id: <h3mlul$il2$1@nntp.fujitsu-siemens.com>
sln@netherlands.com wrote:
> On Mon, 13 Jul 2009 15:37:27 +0200, Josef Moellers <josef.moellers@ts.fujitsu.com> wrote:
>
>> j.keßler wrote:
>>> -----BEGIN xxx SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Josef Moellers wrote:
>>>> j.keßler wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> did you tried what comes with the error message ?(below)
>>>>>> You have not configured a urllist and do not allow connections to the
>>>>>> internet to get a list of mirrors. If you wish to get a list of CPAN
>>>>>> mirrors to pick from, use this command
>>>> I noticed this only after I posted the message. Cancelling was probably
>>>> too late. Thing was ... it did work at home!
>>>>
>>>> Josef
>>> but it sounds like you have to configure CPAN again.
>> Being a person who goes for pragmatic solutions ... I just used my swiss
>> army knife (vi ;-) to edit the /etc/perl/CPAN/config.pm to insert the
>> URL from the old config.
>>
>> It now works.
>>
>> Josef
>
> Aren't you supposed to be able to do that without modifying a .pm file?
TMTOWTDI ;-)
In the end, any other way will most likely modify the .pm file anyhow,
whether I'm using The Official Way(tm) or sneaking in through the back
door. I like having someone lead the way if I'm unfamiliar with things,
but sometimes I just take a shortcut, especially if I've switched to
frantic mode.
As to whether a .pm file should be modified at all: that's a
configuration file in the form of a Perl Module, much like a number of
configuration files in some Linux distributions' /etc/default are shell
scripts. But you probably know that.
Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html
------------------------------
Date: Thu, 16 Jul 2009 16:41:14 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: FAQ 6.7 How can I make "\w" match national character sets?
Message-Id: <slrnh5ubih.bqc.whynot@orphan.zombinet>
On 2009-07-15, Ben Morrow <ben@morrow.me.uk> wrote:
> Quoth Eric Pozharski <whynot@pozharski.name>:
>> {2982:24} [0:1]$ perl -wle 'print "Ñ„" =~ /\w/'
>>
>> {2996:25} [0:0]$ perl -Mlocale -wle 'print "Ñ„" =~ /\w/'
> I don't know what your locale is set to, so I wouldn't expect this to
> work.
{6896:46} [0:0]$ perl -wle 'print "$_ = $ENV{$_}" foreach grep /^LC_/ || /^LANG/, keys %ENV'
LC_ALL = en_US.UTF-8
LANG = en_US.UTF-8
LC_CTYPE = ru_UA.UTF-8
*SKIP*
>> {3011:28} [0:0]$ LC_ALL=ru_UA.UTF-8 perl -Mlocale -wle 'print "Ñ„" =~ /\w/'
>
> This I would expect to work, and in simple cases it does:
>
> ~% LC_ALL=en_GB.ISO8859-1 perl -E'say chr(0xff) =~ /\w/'
>
> ~% LC_ALL=en_GB.ISO8859-1 perl -Mlocale -E'say chr(0xff) =~ /\w/'
> 1
> ~%
>
> I suspect that either the locale system as a whole or perl's
> implementation of it doesn't understand character sets that aren't just
> an 8-bit extension of ASCII.
And see this:
{7475:50} [0:0]$ LC_ALL=ru_UA.koi8u perl -Mlocale -wle 'print "\xD0" =~ /\w/'
1
{7482:51} [0:0]$ LANG=ru_UA.koi8u perl -Mlocale -wle 'print "\xD0" =~ /\w/'
{7488:52} [0:0]$
BTW, what surprised me most in this investigation, that
{7488:52} [0:0]$ perl -wle 'print "Ñ„"'
Ñ„
doesn't give me "Wide character..." warning any more (yesterday I've
upgraded Perl binaries (5.10.0-19 -> 5.10.0-23) -- Debian conspiracy).
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Thu, 16 Jul 2009 16:20:47 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: FAQ 6.7 How can I make "\w" match national character sets?
Message-Id: <slrnh5uac7.bqc.whynot@orphan.zombinet>
On 2009-07-15, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
> On 2009-07-13 19:03, PerlFAQ Server <brian@stonehenge.com> wrote:
>> 6.7: How can I make "\w" match national character sets?
>>
>> Put "use locale;" in your script. The \w character class is taken from
>> the current locale.
>>
>> See perllocale for details.
>>
>
> Here is a more radical rewrite:
>
> 6.7: How can I make "\w" match national character sets?
>
> Since perl 5.8.x, \w matches all Unicode word characters if matched
> against a character string (sometimes also called a "utf8 string").
> The best way to deal with national character sets is to always
> decode them to character strings on input (either with
> Encode::decode or with an ":encoding(...)" I/O layer) and then
> continue to work with the character string.
>
> See perlunitut for details.
I, personally, vote for this rewrite. I think, it's better clearly
state the state.
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Thu, 16 Jul 2009 04:30:53 -0700 (PDT)
From: alfonsobaldaserra <alfonso.baldaserra@gmail.com>
Subject: Re: getting return value of external application on win32
Message-Id: <6333b5fd-fafe-4ca5-bf46-8d6a3923dede@i4g2000prm.googlegroups.com>
>
> Why wouldn't system work?
>
> =A0 =A0if ($? =3D=3D -1) {
> =A0 =A0 =A0 =A0 print "failed to execute: $!\n";
> =A0 =A0 }
thank you for response. i tried with system and $? but it still
returns 0. however it should return 3.
any more ideas?
thanks.
------------------------------
Date: 16 Jul 2009 11:15:56 GMT
From: ram@zedat.fu-berlin.de (Stefan Ram)
Subject: moving a match into a subroutine
Message-Id: <match-20090716125738@ram.dialup.fu-berlin.de>
I want to have the match »something =~ /(.)/g« to be kept in a
separate subroutine, because then, I can keep this at the
start of my script. (I like to collect those parts of my
script that I change often there.)
However, as one can see from the script below, my first attempt
(exhibit 0) does not work, it only prints empty lines.
When I do not use a subroutine (exhibit 1), the behavior is as
wanted: it prints lines with »a«, »b«, and »c«.
Can I put the match »something =~ /(.)/g« in a separate
source code entity that can be moved to the top of my script
(like a subroutine) and still get the behavior of exhibit 1?
#!/usr/bin/perl
#perl 5.8.3
use strict;
use warnings;
my $text = "abc";
# exhibit 0
sub match($){ $_[0] =~ /(.)/g }
while( match( $text ))
{ print $1, "\n"; }
# exhibit 1
while( $text =~ /(.)/g )
{ print $1, "\n"; }
------------------------------
Date: Wed, 15 Jul 2009 22:39:01 -0700 (PDT)
From: Naveed <naveedm9@gmail.com>
Subject: Re: open()ing strings as filehandles
Message-Id: <ddd82775-46ee-465e-973b-7e7e6d1a1905@y19g2000yqy.googlegroups.com>
On Jul 15, 11:30=A0pm, "J. Sharp" <rhed...@gmail.com> wrote:
> Hello all,
>
> I'm trying to use ImageMagick to create a thumbnail from an image (JPEG) =
that I
> have as a string returned from an SQL query. =A0Image::Magick->Read() wil=
l accept
> either a filename or an open file handle, so I'm opening the string as an=
d
> passing it a reference (?) to it.
>
> =A0 =A0 my $immk =3D Image::Magick->new();
>
> =A0 =A0 open(FH, "<", \$image);
> =A0 =A0 $immk->Read(file =3D> \*FH);
> =A0 =A0 close(FH);
>
> =A0 =A0 $immk->Thumbnail(width =3D> THUMBNAIL_WIDTH);
>
> =A0 =A0 open(FH, ">", \$image);
> =A0 =A0 $immk->Write(file =3D> \*FH, filename =3D> 'image.jpg');
> =A0 =A0 close(FH);
>
> When I'm done, I expect to have the thumbnailed image in $image, but I ha=
ve
> NULL! =A0If I try this with real files, everything works fine:
>
> =A0 =A0 my $immk =3D Image::Magick->new();
> =A0 =A0 $immk->Read('/tmp/01.jpg');
> =A0 =A0 $immk->Thumbnail(width =3D> THUMBNAIL_WIDTH);
> =A0 =A0 $immk->Write('/tmp/thumbnailed.jpg');
>
> I really have no clue what I'm doing wrong. =A0Thoughts, anyone?
>
> =A0 Thanks.
One thing you can try is write the contents of $image to a temp file,
open a file handle to that file, and pass that to imagemagick.
------------------------------
Date: Thu, 16 Jul 2009 01:58:48 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: open()ing strings as filehandles
Message-Id: <873a8xmanb.fsf@quad.sysarch.com>
>>>>> "JS" == J Sharp <rhedbox@gmail.com> writes:
JS> open(FH, ">", \$image);
JS> $immk->Write(file => \*FH, filename => 'image.jpg');
JS> close(FH);
JS> When I'm done, I expect to have the thumbnailed image in $image,
JS> but I have NULL! If I try this with real files, everything works
JS> fine:
JS> my $immk = Image::Magick->new();
JS> $immk->Read('/tmp/01.jpg');
JS> $immk->Thumbnail(width => THUMBNAIL_WIDTH);
JS> $immk->Write('/tmp/thumbnailed.jpg');
there you have a single arg as the filename. above you have both a
handle AND a filename. try dropping the filename as it isn't needed. you
want it to write to the string handle only. the docs show both args for
a write call which makes no sense. so i bet the docs are in error.
$image->Write(file=>\*IMAGE, filename=>$filename);
in fact if it can detect a handle vs a filename you may just be able to
pass the handle by itself (no key) and it may work. a single arg seems
to be assumed the file or filename. worth trying anyhow.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 16 Jul 2009 07:47:37 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Perl WTF
Message-Id: <h3mlup$3sp$1@reader1.panix.com>
In article <Xns9C2F7F993BBD7asu1cornelledu@127.0.0.1>,
A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
>Brandon Metcalf <brandon@geronimoa11oys.invalid> wrote in
>news:slrnh3ndvd.6il.brandon@cedar.geronimoalloys.com:
>
>> On 2009-06-19, A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
>>> sisyphus <sisyphus359@gmail.com> wrote in
>>> news:da9c3cc3-f551-41b7-a666-8e79331dc0c2
>@x6g2000vbg.googlegroups.com:
>>
>> ...
>>
>>>> Another way of looking at it - all of the following are true (on
>>>> many systems):
>>>> "infertility" == "infertility"
>>>> "infertility" == "informal"
>>>> "fanaticists" == "fanaticists"
>>>> "fanaticists" == "most strings"
>>>> but
>>>> "infertility" != "most strings"
>>>> "nanoseconds" != "nanoseconds"
>>>>
>>>> What *were* they thinking of ;-)
>>>
>>> Excellent examples. It is clear what is going on if you know what is
>>> going on but to understand what is going on one needs to connect way
>>> too many dots. ;-)
>>
>>
>> I'll bite. What is going on?
>
>Strings that start with 'inf' are being interpreted as infinity (because
>the comparison is numeric). By the rules of IEEE floating point
>arithmetic, infinity == infinity is true.
>
>Strings that start with 'nan' are being interpreted as nan (because the
>comparison is numeric). By the rules of IEEE floating point arithmetic,
>a nan cannot compare equal to any other number, even another nan.
How long does it take to discover that infert... isn't infini..?
That's really weird, to take only the first three letters and just
IGNORE the REST of the word.
What with computers being SO DARNED FAST these days, I'd call that
a design-bug. An unwelcome IED in the road.
David
------------------------------
Date: Thu, 16 Jul 2009 07:57:29 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Perl WTF
Message-Id: <h3mmh9$3sp$2@reader1.panix.com>
In article <0b5a4be1-4cd9-41b0-bcd6-952c6378e912@o21g2000prn.googlegroups.com>,
sisyphus <sisyphus359@gmail.com> wrote:
>On Jun 20, 2:42 am, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
>
>
>> So, my AS perl on Windows does not seem to support NaNs.
>
>It supports them (and Inf's), but, unlike most nixes, you can't assign
>them using strings 'nan' and 'inf' (or any other strings, for that
>matter) because the Windows C runtime doesn't support that.
Really sits wrong in the stomach. I'd sure like it to be (in normal use)
ILLEGAL to do things that will work differently on one machine or os
than on another.
If I really NEED that ability, then I'd like perl to require
me to wrap that code in some kind of a LOUD begin-end structure,
where it shouts out in the code LOOK HERE -- WATCH OUT, I'M DOING
CRAZY THINGS HERE!
>Strawberry Perl and ActivePerl use the same C runtime - so expect
>identical behaviour.
>
Unless you LIKE living dangerously.
David
------------------------------
Date: Thu, 16 Jul 2009 03:51:05 -0700 (PDT)
From: msciwoj <m@epf.pl>
Subject: RegEx - finding the innermost block
Message-Id: <5ef29403-a65e-45e8-ad8d-f1562a236a5b@o15g2000yqm.googlegroups.com>
Does any one have an idea is it possible to catch the block that has
no nested blocks of its type using regular expressions?
In other words how to catch
<blockbeginmark>.....-NO <blockbeginmark> until <blockendmark>
For instance, can
<div> ..... </div>
block can be caught with the condition it has no nested <div> blocks
in it?
Any ideas?
------------------------------
Date: Thu, 16 Jul 2009 10:06:01 -0700 (PDT)
From: Donato Azevedo <donatoaz@gmail.com>
Subject: Re: RegEx - finding the innermost block
Message-Id: <602565d5-5166-4a31-994d-86cf0b51e085@k26g2000vbp.googlegroups.com>
On Jul 16, 7:51=A0am, msciwoj <m...@epf.pl> wrote:
> Does any one have an idea is it possible to catch the block that has
> no nested blocks of its type using regular expressions?
> In other words how to catch
> <blockbeginmark>.....-NO <blockbeginmark> until <blockendmark>
>
> For instance, can
> <div> ..... </div>
> block can be caught with the condition it has no nested <div> blocks
> in it?
>
> Any ideas?
Regular Expressions are not really good for context aware matching and
parsing (which is what your match looks to be). For that, I would
recommend you do a little search on CPAN for HTML parsing modules such
as HTML::Parser
Cheers!
--
Donato Azevedo
------------------------------
Date: Thu, 16 Jul 2009 09:17:59 -0700 (PDT)
From: Donato Azevedo <donatoaz@gmail.com>
Subject: Simple Regex Doubt
Message-Id: <f2e997be-e9dc-4751-b779-d9f3bc496192@p15g2000vbl.googlegroups.com>
Hi everyone,
I've got a simple question to which Ive, to this point, not been able
to solve:
I have these regexes which I want to convert into a single one:
if ( $raw_content =~ /Doc1(?:=rev)?:(?<document1>.*?)\r\n
Doc2(?:=rev)?:(?<document2>.*?)\r\n
Item:(?<item>.*?)\r\n
Data\s+doc1:(?<data1>.*?)\r\n
Data\s+doc2:(?<data2>.*?)\r\n
Obs:(?<observation>.*?)\r\n
Critic:(?<criticality>.*?)\r\n
Comments:(?<comments>.*)
/isx ||
$raw_content =~ /Doc1(?:=rev)?:(?<document1>.*?)\r\n
Doc2(?:=rev)?:(?<document2>.*?)\r\n
Item:(?<item>.*?)\r\n
Data\s+doc1:(?<data1>.*?)\r\n
Data\s+doc2:(?<data2>.*?)\r\n
Obs:(?<observation>.*?)\r\n
Critic:(?<criticality>.*)
/isx ) {
this is to match text that can either end in:
Critic:foobartext
or
Critic:foo
Comments:bar
The problem seems to be the greediness of the last captures: I tried
doing
Critic:(?<criticality>.*?)(\r\nComments:(?<comments>.*))?
and
Critic:(?<criticality>.*)(\r\nComments:(?<comments>.*))?
but I must be missing something... It must be something quite simple
I'd say.
Well, any ideas?
------------------------------
Date: Thu, 16 Jul 2009 01:38:14 GMT
From: spambait@milmac.com (Doug Miller)
Subject: Re: Why doesn't this 'next if' work?
Message-Id: <qwv7m.8168$cl4.1398@flpi150.ffdc.sbc.com>
In article <i7os55p81d2rehgopcjfgs292pupdddioe@4ax.com>, Jürgen Exner <jurgenex@hotmail.com> wrote:
>spambait@milmac.com (Doug Miller) wrote:
>>Likewise, he can't pick and choose in the other comparison either. If the
>>operands are numeric, he *must* use ==; if they are strings, he *must* use eq.
>
>Actually you can mix and match. But you better know exactly what you are
>doing.
>
>There is nothing stopping you from comparing the string values of two
>numbers
As long as you consider unexpected results to be "nothing".
> and actually of the top my head I can't think of a scenario,
>where you would get an unexpected surprise.
I can...
1 gt 02
-1 lt -2
1 ne 01
-0 ne 0
1 ne +1
+1 lt -1
8 ne 010
15 ne 0xF
0xF ne 0xf
>
>And you can also compare the numerical values of two strings. However in
>this case you really better know what those numerical values are going
>to be because most of the time it's probably not what you would expect.
OK, perhaps I should have added "... if he plans on getting the results that a
naive failure to understand the difference would lead him to expect." <g>
------------------------------
Date: Wed, 15 Jul 2009 19:14:41 -0700
From: sln@netherlands.com
Subject: Re: Why doesn't this 'next if' work?
Message-Id: <p63t559febgsir1l78e4ddq750mjbshb2e@4ax.com>
On Thu, 16 Jul 2009 01:38:14 GMT, spambait@milmac.com (Doug Miller) wrote:
>In article <i7os55p81d2rehgopcjfgs292pupdddioe@4ax.com>, Jürgen Exner <jurgenex@hotmail.com> wrote:
>>spambait@milmac.com (Doug Miller) wrote:
>>>Likewise, he can't pick and choose in the other comparison either. If the
>>>operands are numeric, he *must* use ==; if they are strings, he *must* use eq.
>>
>>Actually you can mix and match. But you better know exactly what you are
>>doing.
>>
>>There is nothing stopping you from comparing the string values of two
>>numbers
>
>As long as you consider unexpected results to be "nothing".
>
>> and actually of the top my head I can't think of a scenario,
>>where you would get an unexpected surprise.
>
>I can...
>
>1 gt 02
>-1 lt -2
>1 ne 01
>-0 ne 0
>1 ne +1
>+1 lt -1
>8 ne 010
>15 ne 0xF
>0xF ne 0xf
>>
>>And you can also compare the numerical values of two strings. However in
>>this case you really better know what those numerical values are going
>>to be because most of the time it's probably not what you would expect.
>
>OK, perhaps I should have added "... if he plans on getting the results that a
>naive failure to understand the difference would lead him to expect." <g>
But, but, the point is that its allowable, not necesarily always right.
-sln
------------------------------
Date: Thu, 16 Jul 2009 03:05:39 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Why doesn't this 'next if' work?
Message-Id: <jge2j6-07u2.ln1@osiris.mauzo.dyndns.org>
Quoth spambait@milmac.com (Doug Miller):
> In article <i7os55p81d2rehgopcjfgs292pupdddioe@4ax.com>, Jürgen Exner
> <jurgenex@hotmail.com> wrote:
> >spambait@milmac.com (Doug Miller) wrote:
> >>Likewise, he can't pick and choose in the other comparison either. If the
> >>operands are numeric, he *must* use ==; if they are strings, he *must* use eq.
> >
> >Actually you can mix and match. But you better know exactly what you are
> >doing.
> >
> >There is nothing stopping you from comparing the string values of two
> >numbers
>
> As long as you consider unexpected results to be "nothing".
>
> > and actually of the top my head I can't think of a scenario,
> >where you would get an unexpected surprise.
>
> I can...
>
> 1 gt 02
> -1 lt -2
> 1 ne 01
> -0 ne 0
> 1 ne +1
> +1 lt -1
> 8 ne 010
> 15 ne 0xF
> 0xF ne 0xf
Only one of these gives a different result from a numerical comparison.
On systems that support IEEE floats, you can add
-0.0 ne 0
Of course, if you replace all those literal numbers with quoted strings,
they all compare different numerically, though in some cases this is
because they don't numify as you might expect.
> >And you can also compare the numerical values of two strings. However in
> >this case you really better know what those numerical values are going
> >to be because most of the time it's probably not what you would expect.
Talking about comparing 'strings' and 'numbers' is incorrect in Perl.
The appropriate question is 'do you wish to compare string values or
numeric values?'.
Ben
------------------------------
Date: Wed, 15 Jul 2009 20:25:31 -0700
From: sln@netherlands.com
Subject: Re: Why doesn't this 'next if' work?
Message-Id: <n77t55dhdn9mmsetph2h6n4dhnpf8l57jn@4ax.com>
On Thu, 16 Jul 2009 03:05:39 +0100, Ben Morrow <ben@morrow.me.uk> wrote:
>
>Quoth spambait@milmac.com (Doug Miller):
>> In article <i7os55p81d2rehgopcjfgs292pupdddioe@4ax.com>, Jürgen Exner
>> <jurgenex@hotmail.com> wrote:
>> >spambait@milmac.com (Doug Miller) wrote:
>> >>Likewise, he can't pick and choose in the other comparison either. If the
>> >>operands are numeric, he *must* use ==; if they are strings, he *must* use eq.
>> >
>> >Actually you can mix and match. But you better know exactly what you are
>> >doing.
>> >
>> >There is nothing stopping you from comparing the string values of two
>> >numbers
>>
>> As long as you consider unexpected results to be "nothing".
>>
>> > and actually of the top my head I can't think of a scenario,
>> >where you would get an unexpected surprise.
>>
>> I can...
>>
>> 1 gt 02
>> -1 lt -2
>> 1 ne 01
>> -0 ne 0
>> 1 ne +1
>> +1 lt -1
>> 8 ne 010
>> 15 ne 0xF
>> 0xF ne 0xf
>
>Only one of these gives a different result from a numerical comparison.
>On systems that support IEEE floats, you can add
>
> -0.0 ne 0
>
>Of course, if you replace all those literal numbers with quoted strings,
>they all compare different numerically, though in some cases this is
>because they don't numify as you might expect.
>
>> >And you can also compare the numerical values of two strings. However in
>> >this case you really better know what those numerical values are going
>> >to be because most of the time it's probably not what you would expect.
>
>Talking about comparing 'strings' and 'numbers' is incorrect in Perl.
>The appropriate question is 'do you wish to compare string values or
>numeric values?'.
>
>Ben
Yeah, its a formulea, its undefined too, really, throw that in, but, whats in
a conversion, nobody wants to know, thats why its !defined $value instead of !$value.
-sln
------------------------------
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 V11 Issue 2520
***************************************