[31538] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2797 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 30 09:09:26 2010

Date: Sat, 30 Jan 2010 06:09:10 -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           Sat, 30 Jan 2010     Volume: 11 Number: 2797

Today's topics:
    Re: [OT] Re: Inconsistent results from (dos)glob <hjp-usenet2@hjp.at>
    Re: [OT] Re: Inconsistent results from (dos)glob <nospam-abuse@ilyaz.org>
    Re: [OT] Re: Inconsistent results from (dos)glob <nospam-abuse@ilyaz.org>
    Re: [OT] Re: Inconsistent results from (dos)glob <ben@morrow.me.uk>
    Re: [OT] Re: Inconsistent results from (dos)glob <ben@morrow.me.uk>
    Re: [OT] Re: Inconsistent results from (dos)glob <nospam-abuse@ilyaz.org>
    Re: permalink to latest devel release of perl? <no.email@please.post>
    Re: permalink to latest devel release of perl? <ben@morrow.me.uk>
    Re: should C<++$_ for -1..1> croak? <derykus@gmail.com>
        steps <robin1@cnsp.com>
    Re: steps <rvtol+usenet@xs4all.nl>
    Re: What are the minimum and maximum float numbers and  sln@netherlands.com
    Re: What are the minimum and maximum float numbers and  sln@netherlands.com
    Re: What are the minimum and maximum float numbers and  <hjp-usenet2@hjp.at>
    Re: What are the minimum and maximum float numbers and  <rvtol+usenet@xs4all.nl>
    Re: What are the minimum and maximum float numbers and  <hjp-usenet2@hjp.at>
    Re: What are the minimum and maximum float numbers and  <hjp-usenet2@hjp.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 29 Jan 2010 22:36:55 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: [OT] Re: Inconsistent results from (dos)glob
Message-Id: <slrnhm6l7o.fkk.hjp-usenet2@hrunkner.hjp.at>

On 2010-01-29 17:17, Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> On 2010-01-29, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>> That's impossible. All the syscalls dealing with filenames treat "\0" as
>> a terminator. There is no way to create or access a file with a null in
>> its name[1].
>
> It is not a problem to create or access a file with a null in its name
> on Unix.  (Remember read()/write() syscalls?)

read and write syscalls do not create or access files. Unless you are
talking about opening the block device and reading from/writing to that.
But in that case you aren't "accessing files with a null in its name",
you are just accessing one huge file the size of your (logical) disk.

	hp


------------------------------

Date: Sat, 30 Jan 2010 00:59:22 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: [OT] Re: Inconsistent results from (dos)glob
Message-Id: <slrnhm713a.e4n.nospam-abuse@powdermilk.math.berkeley.edu>

On 2010-01-29, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>>> That's impossible. All the syscalls dealing with filenames treat "\0" as
>>> a terminator. There is no way to create or access a file with a null in
>>> its name[1].
>>
>> It is not a problem to create or access a file with a null in its name
>> on Unix.  (Remember read()/write() syscalls?)
>
> read and write syscalls do not create or access files. Unless you are
> talking about opening the block device and reading from/writing to that.

Either that, or doing read()/write() with a directory.

> But in that case you aren't "accessing files with a null in its name",
> you are just accessing one huge file the size of your (logical) disk.

Yes I do.  As your "filesystem driver" would eventually do as when you
ask for

   mv foo bar

Hope this helps,
Ilya


------------------------------

Date: Sat, 30 Jan 2010 01:03:03 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: [OT] Re: Inconsistent results from (dos)glob
Message-Id: <slrnhm71a7.e4n.nospam-abuse@powdermilk.math.berkeley.edu>

On 2010-01-29, Ben Morrow <ben@morrow.me.uk> wrote:
> Yes. Jan Dubois is trying quite hard to get perl there without breaking
> anything. The problem is that naive programs that read a filename from
> the console (or the command-line) will then break, because the name will
> be in the current 'ANSI' encoding

No it won't.  AFAIK, arguments to a program are available in Unicode.

Yours,
Ilya


------------------------------

Date: Sat, 30 Jan 2010 01:35:47 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: [OT] Re: Inconsistent results from (dos)glob
Message-Id: <j0fc37-nuh1.ln1@osiris.mauzo.dyndns.org>


Quoth Ilya Zakharevich <nospam-abuse@ilyaz.org>:
> On 2010-01-29, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
> >>> That's impossible. All the syscalls dealing with filenames treat "\0" as
> >>> a terminator. There is no way to create or access a file with a null in
> >>> its name[1].
> >>
> >> It is not a problem to create or access a file with a null in its name
> >> on Unix.  (Remember read()/write() syscalls?)
> >
> > read and write syscalls do not create or access files. Unless you are
> > talking about opening the block device and reading from/writing to that.
> 
> Either that, or doing read()/write() with a directory.

Depending on what you mean by 'Unix', many systems will not let you
read (Linux) or write (FreeBSD) a directory, for obvious reasons.

Obviously, if you have raw access to the disk you can corrupt the
filesystem in any way you please, including by creating a directory
entry with a null in it.

Ben



------------------------------

Date: Sat, 30 Jan 2010 01:48:52 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: [OT] Re: Inconsistent results from (dos)glob
Message-Id: <4pfc37-nuh1.ln1@osiris.mauzo.dyndns.org>


Quoth Ilya Zakharevich <nospam-abuse@ilyaz.org>:
> On 2010-01-29, Ben Morrow <ben@morrow.me.uk> wrote:
> > Yes. Jan Dubois is trying quite hard to get perl there without breaking
> > anything. The problem is that naive programs that read a filename from
> > the console (or the command-line) will then break, because the name will
> > be in the current 'ANSI' encoding
> 
> No it won't.  AFAIK, arguments to a program are available in Unicode.

An 'ordinary' program using main() (such as perl) will receive 'ANSI'
arguments in argv. You can get Unicode arguments by using wmain, or,
presumably, other more Win32ish entry points, but that doesn't help:
existing Perl programs that expect @ARGV to contain bytes in the current
code page will be broken. As I said, this is a known problem, the
solution is known, and people are working to get perl there without
breaking too much along the way.

Ben



------------------------------

Date: Sat, 30 Jan 2010 13:42:27 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: [OT] Re: Inconsistent results from (dos)glob
Message-Id: <slrnhm8dq3.gu4.nospam-abuse@powdermilk.math.berkeley.edu>

On 2010-01-30, Ben Morrow <ben@morrow.me.uk> wrote:
> You can get Unicode arguments by using wmain, or,
> presumably, other more Win32ish entry points, but that doesn't help:

???

> existing Perl programs that expect @ARGV to contain bytes in the current
> code page will be broken.

Perl strings contain characters, not bytes.  Hence

  a) such programs are already broken; there is no need to support
     such programs in the default configuration.
     $ENV{PERL_ARGV_IN_CP} and -Margv_in_cp should be enough to handle this.

  b) More often then not, Perl programs which did not work before
     would "magically start working".  This is in itself an incentive...

> As I said, this is a known problem, the
> solution is known, and people are working to get perl there without
> breaking too much along the way.

Good to hear this,
Ilya


------------------------------

Date: Fri, 29 Jan 2010 20:42:28 +0000 (UTC)
From: kj <no.email@please.post>
Subject: Re: permalink to latest devel release of perl?
Message-Id: <hjvh7j$c53$1@reader1.panix.com>

In <thib37-a4g1.ln1@osiris.mauzo.dyndns.org> Ben Morrow <ben@morrow.me.uk> writes:

>Quoth kj <no.email@please.post>:

>> Hi Ben.  My ultimate goal here is to always have the latest devel
>> release of perl installed locally under my subdirectory ~/develperl.
>> I was hoping to set up a cron job to perform this installation at
>> night whenever a new release comes out.  The stable URL you gave
>> is very helpful for this.

>Then I would probably recommend building from git instead. Although p5p
>has recently committed to monthly blead releases, they really aren't
>much more than snapshots. You can checkout the source from git with

>    git clone git://perl5.git.perl.org/perl.git perl
>    cd perl

>and then do a build with

>    git clean -dfx
>    git pull
>    ./Configure -des ...
>    make && make test && make install

>The 'git clean' is not strictly necessary, but it's best to clean
>everything out if you're going to update the source in case the
>dependancies have changed in a way the Makefile doesn't understand.

This is extremely helpful.  Thanks!

~K


------------------------------

Date: Fri, 29 Jan 2010 21:30:24 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: permalink to latest devel release of perl?
Message-Id: <gk0c37-73h1.ln1@osiris.mauzo.dyndns.org>


Quoth kj <no.email@please.post>:
> In <thib37-a4g1.ln1@osiris.mauzo.dyndns.org> Ben Morrow
> <ben@morrow.me.uk> writes:
> 
> >Then I would probably recommend building from git instead. Although p5p
> >has recently committed to monthly blead releases, they really aren't
> >much more than snapshots. You can checkout the source from git with
> 
> >    git clone git://perl5.git.perl.org/perl.git perl
> >    cd perl
> 
> >and then do a build with
> 
> >    git clean -dfx
> >    git pull
> >    ./Configure -des ...
> >    make && make test && make install
> 
> >The 'git clean' is not strictly necessary, but it's best to clean
> >everything out if you're going to update the source in case the
> >dependancies have changed in a way the Makefile doesn't understand.
> 
> This is extremely helpful.  Thanks!

I should probably also mention: if you're doing regular builds of perl
(or anything, really) ccache (http://ccache.samba.org) is absolutely
invaluable. It's reached the point where AFAICS make is pretty much
redundant: for new projects it would be *much* quicker to just have a
shell script that compiles everything, and let ccache handle things that
have been compiled already.

Ben



------------------------------

Date: Fri, 29 Jan 2010 13:45:00 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: should C<++$_ for -1..1> croak?
Message-Id: <5cb02942-95cd-43eb-9f12-0e6f054cf99d@l24g2000prh.googlegroups.com>

On Jan 29, 10:43=A0am, Steve C <smallp...@juno.com> wrote:
> John Bokma wrote:
> > Steve C <smallp...@juno.com> writes:
>
> >> Dr.Ruud wrote:
> >>> Should C<++$_ for -1..1> croak?
>
> >>> Or is it better to leave it as it is?
>
> >>> $ perl -wle'++$_ for 1..1'
>
> >>> $ perl -wle'++$_ for 1'
> >>> Modification of a read-only value attempted at -e line 1.
> >> for implicitly aliases $_ to the constant 1, which cannot be
> >> incremented.
>
> > Note that there are two examples and only the last one complains about =
a
> > modification of ro value.
>
> perlop says:
> "In the current implementation, no temporary array is created when the
> range operator is used as the expression in "foreach" loops"
>
> I assume that to mean that in the first case $_ is being set to an lvalue
> by the loop code rather than aliased to a constant in a list.
> Would this throw an error in older perl versions that did build a list,
> or has it always worked?


I think you're right and B::Concise seems to confirm your
statement that the first case tries to set the constant to
a modifiable lvalue while the second doesn't. Maybe someone
familiar with the internals can clarify...

perl -MO=3DConcise,-exec -wle'++$_ for 1'

1  <0> enter
2  <;> nextstate(main 1 -e:1) v:{
3  <;> nextstate(main 1 -e:1) v:{
4  <0> pushmark sM
5  <$> const[IV 1] sM   <----    M =3D Will modify (lvalue)
 ...

perl -MO=3DConcise,-exec perl -wle'++$_ for 1..1'
1  <0> enter
2  <;> nextstate(main 1 -e:1) v:{
3  <;> nextstate(main 1 -e:1) v:{
4  <0> pushmark s
5  <$> const[IV 1] s
 ...


Deja vu all over again too. Didn't Ben just mention the likelihood
this was a bug:

http://groups.google.com/group/comp.lang.perl.misc/browse_thread/thread/f5f=
e9cb45c9adb90?hl=3Den

--
Charles DeRykus


------------------------------

Date: Fri, 29 Jan 2010 17:05:06 -0800 (PST)
From: Robin <robin1@cnsp.com>
Subject: steps
Message-Id: <eb14e1f3-4985-4b6f-937c-d820b5a5fe68@h2g2000yqj.googlegroups.com>

What would some of the steps be to design modules for perl that are a
way people can do gui programming on windows?
I don't exactly know where to start and would like some human input.

Thank you,
-robin


------------------------------

Date: Sat, 30 Jan 2010 12:56:53 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: steps
Message-Id: <4b641e86$0$22941$e4fe514c@news.xs4all.nl>

Robin wrote:

> What would some of the steps be to design modules for perl that are a
> way people can do gui programming on windows?
> I don't exactly know where to start and would like some human input.

It's already been done, so you can find out how.

For example: wxperl
http://en.wikipedia.org/wiki/WxPerl

-- 
Ruud


------------------------------

Date: Fri, 29 Jan 2010 16:07:45 -0800
From: sln@netherlands.com
Subject: Re: What are the minimum and maximum float numbers and integers?
Message-Id: <3bo6m5579jqv3rfpcgbk2v8l261f4uiv59@4ax.com>

On Fri, 29 Jan 2010 01:13:14 -0800 (PST), ilovelinux <c7eqjyg02@sneakemail.com> wrote:

>On 26 jan, 18:52, s...@netherlands.com wrote:
>
>> Something like this should get you in the range.
>[...]
>> printf ("INT:    +/- %d\n", sprintf ("%u", -1) / 2);
>
>This didn't work for me; it printed:
>INT:    +/- -9223372036854775808
>(platform = CYGWIN_NT-5.1 1.7.1(0.218/5/3))
>
Scary stuff.
Is this run under Windows XP-64 or 32?
Is 64 bit native in the OS? What perl distribution?

>Replacing it with:
>printf ("INT:    +/- %d\n", sprintf ("%u", -1) / 2 - 1);
>didn't help, surprisingly:
>INT:    +/- -9223372036854775808
             ^
Since this is supposed to be 'unsigned', its not too suprising.
>
>But the following did the trick:
>printf ("INT:    +/- %d\n", sprintf("%u", -1)>>1);
>INT:    +/- 9223372036854775807
>
I don't know why division by 2 should be any different than >>1.
Funny things can happen like the sign bit is duplicated during arithmatic.
But thats seems more a consequence for signed types less than the native
machine word (int) of a typed language like C.

Well, if shift right 1 (not division by 2) works for you, then you don't
need the sprintf(), a simple  printf ("INT:    +/- %d\n", -1>>1 );
will do.

What does
  printf "%d", 18446744073709551615;
  printf "%d", 18446744073709551615 / 2;
return? It should return:
  -1
  9223372036854775807
If not, arithmatic operations would be suspect.

>
>Instead of interpolating "$places", use a * in the format
>specification and add $places as an extra argument to printf.
^^
Thanks.

-sln




------------------------------

Date: Fri, 29 Jan 2010 16:28:07 -0800
From: sln@netherlands.com
Subject: Re: What are the minimum and maximum float numbers and integers?
Message-Id: <5iu6m5hr4dodu6lvcb1k10jb6u9a4puhgk@4ax.com>

On Fri, 29 Jan 2010 16:07:45 -0800, sln@netherlands.com wrote:

>On Fri, 29 Jan 2010 01:13:14 -0800 (PST), ilovelinux <c7eqjyg02@sneakemail.com> wrote:
>
>>On 26 jan, 18:52, s...@netherlands.com wrote:
[snip]
>What does
>  printf "%d", 18446744073709551615;
>  printf "%d", 18446744073709551615 / 2;
>return? It should return:
>  -1
>  9223372036854775807
>If not, arithmatic operations would be suspect.

Or, to clarify (at least in your case), arithmatic operations
resulting in or on values outside the range of  (+/-) signed int (machine word).
But Windows-64 will run 32-bit programs with sign emulation. It seems more a
processor feature though.

-sln


------------------------------

Date: Sat, 30 Jan 2010 11:44:11 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: What are the minimum and maximum float numbers and integers?
Message-Id: <slrnhm83bs.g6p.hjp-usenet2@hrunkner.hjp.at>

On 2010-01-30 00:07, sln@netherlands.com <sln@netherlands.com> wrote:
> On Fri, 29 Jan 2010 01:13:14 -0800 (PST), ilovelinux <c7eqjyg02@sneakemail.com> wrote:
>>On 26 jan, 18:52, s...@netherlands.com wrote:
>>> Something like this should get you in the range.
>>[...]
>>> printf ("INT:    +/- %d\n", sprintf ("%u", -1) / 2);
>>
>>This didn't work for me; it printed:
>>INT:    +/- -9223372036854775808
>>(platform = CYGWIN_NT-5.1 1.7.1(0.218/5/3))
>>
> Scary stuff.
> Is this run under Windows XP-64 or 32?
> Is 64 bit native in the OS? What perl distribution?
>
>>Replacing it with:
>>printf ("INT:    +/- %d\n", sprintf ("%u", -1) / 2 - 1);
>>didn't help, surprisingly:
>>INT:    +/- -9223372036854775808
>              ^
> Since this is supposed to be 'unsigned', its not too suprising.
>>
>>But the following did the trick:
>>printf ("INT:    +/- %d\n", sprintf("%u", -1)>>1);
>>INT:    +/- 9223372036854775807
>>
> I don't know why division by 2 should be any different than >>1.

Because division is always done in floating point arithmetic in Perl.
So the result of (18446744073709551615/2) should be
9223372036854775807.5 - but that isn't representable in a 53 bit
mantissa, so it is rounded to the next representable value which happens
to be 9223372036854775808 (the next lower representable FP value btw is
9223372036854774784, so subtracting any value <= 512 doesn't have any
effect).

If int(18446744073709551615/2) gives you 9223372036854775807 you
probably have compiled perl to use long double arithmetic.

> Funny things can happen like the sign bit is duplicated during arithmatic.

C doesn't define[1] what happens if you right-shift a negative value.

But Perl does, at least if don't "use integer":

|      Note that both "<<" and ">>" in Perl are implemented directly using
|      "<<" and ">>" in C.  If "use integer" (see "Integer Arithmetic") is in
|      force then signed C integers are used, else unsigned C integers are
|      used.
	(perldoc perlop)

So (-1 >> 1) uses unsigned integer operations. (unsigned)-1 is
guaranteed to be the largest unsigned integer, so (-1 >> 1) is half of
that which is half the largest signed integer (unless there are unused
bits in the implementation, which C allows, but that's exceedingly
rare).

	hp

[1] Although I think it's implementation-defined, not undefined.


------------------------------

Date: Sat, 30 Jan 2010 12:54:45 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: What are the minimum and maximum float numbers and integers?
Message-Id: <4b641e05$0$22913$e4fe514c@news.xs4all.nl>

Peter J. Holzer wrote:

> So (-1 >> 1) uses unsigned integer operations. (unsigned)-1 is
> guaranteed to be the largest unsigned integer, so (-1 >> 1) is half of
> that which is half the largest signed integer (unless there are unused
> bits in the implementation, which C allows, but that's exceedingly
> rare).

ITYM: "(-1) >> 1" is the largest signed integer: 0/1/.
(a 0-bit, and then as many 1-bits as possible)

-- 
Ruud


------------------------------

Date: Sat, 30 Jan 2010 13:30:29 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: What are the minimum and maximum float numbers and integers?
Message-Id: <slrnhm89j7.m41.hjp-usenet2@hrunkner.hjp.at>

On 2010-01-30 11:54, Dr.Ruud <rvtol+usenet@xs4all.nl> wrote:
> Peter J. Holzer wrote:
>> So (-1 >> 1) uses unsigned integer operations. (unsigned)-1 is
>> guaranteed to be the largest unsigned integer, so (-1 >> 1) is half of
>> that which is half the largest signed integer (unless there are unused
>> bits in the implementation, which C allows, but that's exceedingly
>> rare).
>
> ITYM: "(-1) >> 1" is the largest signed integer:

Unary - binds closer than binary >>, so (-1 >> 1) is the same as
((-1) >> 1). So I don't see how that differs from what I wrote.


> 0/1/.  (a 0-bit, and then as many 1-bits as possible)

Yes.

	hp



------------------------------

Date: Sat, 30 Jan 2010 13:42:05 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: What are the minimum and maximum float numbers and integers?
Message-Id: <slrnhm8a8u.moj.hjp-usenet2@hrunkner.hjp.at>

On 2010-01-30 12:30, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
> On 2010-01-30 11:54, Dr.Ruud <rvtol+usenet@xs4all.nl> wrote:
>> Peter J. Holzer wrote:
>>> So (-1 >> 1) uses unsigned integer operations. (unsigned)-1 is
>>> guaranteed to be the largest unsigned integer, so (-1 >> 1) is half of
>>> that which is half the largest signed integer (unless there are unused
>>> bits in the implementation, which C allows, but that's exceedingly
>>> rare).
>>
>> ITYM: "(-1) >> 1" is the largest signed integer:
>
> Unary - binds closer than binary >>, so (-1 >> 1) is the same as
> ((-1) >> 1). So I don't see how that differs from what I wrote.

Ah, I see it now: "half the largest signed integer" should of course
have read "the largest signed integer". Somehow I duplicated the "half".

	hp


------------------------------

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 2797
***************************************


home help back first fref pref prev next nref lref last post