[31698] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2961 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 22 18:09:27 2010

Date: Sat, 22 May 2010 15:09:09 -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           Sat, 22 May 2010     Volume: 11 Number: 2961

Today's topics:
    Re: bit-twiddling on 32-bit machines sln@netherlands.com
    Re: Conflict between 32 and 64bit (WAS: FAQ 5.6 How can <jurgenex@hotmail.com>
    Re: Conflict between 32 and 64bit (WAS: FAQ 5.6 How can <No_4@dsl.pipex.com>
        Example of the operator '..' in scalar context? <pengyu.ut@gmail.com>
    Re: Example of the operator '..' in scalar context? <ben@morrow.me.uk>
    Re: Example of the operator '..' in scalar context? <tadmc@seesig.invalid>
        Using rename script to change multiple files <jegan473@comcast.net>
    Re: Using rename script to change multiple files <nospam-abuse@ilyaz.org>
        What do N and R in $NR stand for? <pengyu.ut@gmail.com>
    Re: What do N and R in $NR stand for? <uri@StemSystems.com>
    Re: What do N and R in $NR stand for? <ben@morrow.me.uk>
        Where is the perl documentationn for '..' (command line <pengyu.ut@gmail.com>
    Re: Where is the perl documentationn for '..' (command  <peter@makholm.net>
    Re: Where is the perl documentationn for '..' (command  <jurgenex@hotmail.com>
        Why $NR and $INPUT_LINE_NUMBER are not the same as $.? <pengyu.ut@gmail.com>
    Re: Why $NR and $INPUT_LINE_NUMBER are not the same as  <uri@StemSystems.com>
    Re: Why $NR and $INPUT_LINE_NUMBER are not the same as  <pengyu.ut@gmail.com>
    Re: will there be a Strawberry Perl 6 / Rakudo Star ? <dilbert1999@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 22 May 2010 11:38:19 -0700
From: sln@netherlands.com
Subject: Re: bit-twiddling on 32-bit machines
Message-Id: <ei8gv5tdc39a2v0rb7fqnhm30flhl0qnhn@4ax.com>

On Sat, 22 May 2010 10:57:53 +0200, "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:

>On 2010-05-21 16:24, sln@netherlands.com <sln@netherlands.com> wrote:
>> On Thu, 20 May 2010 13:02:08 +0200, "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>>>On 2010-05-19 23:56, sln@netherlands.com <sln@netherlands.com> wrote:
>>>> On Wed, 19 May 2010 23:44:50 +0100, Ben Morrow <ben@morrow.me.uk> wrote:
>>>>>and a C program the does the same operations on a signed 32bit integer
>>>>                                                      ^^ .........^^
>>>> This is redundant. There is only unsigned and int.
>>>
>>>Wrong. "integer" is not the same as "int". The C standard knows five
>>>standard signed integer types and six standard unsigned integer types.
>>>And "int" and "unsigned" are just abbreviations of "signed int" and
>>>"unsigned int", respectively.
>>
>> Technically there are no "integer types", they are integral types.
>
>Please read the standard. 
>
Integer is what it is, a single whole number from the set of all whole numbers.
There is no type of integer. There are subsets, they are called integral types
in computing science.

If the phrase is loosely used, thats a shame. C/C++ standard and all references to
it use integral types as classifier of the subsets.

-sln


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

Date: Sat, 22 May 2010 08:21:13 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Conflict between 32 and 64bit (WAS: FAQ 5.6 How can I copy a file?)
Message-Id: <2dtfv51udonhhf5qqf64d4gkdu9rp9hr7g@4ax.com>

Ben Morrow <ben@morrow.me.uk> wrote:
>Quoth J?Exner <jurgenex@hotmail.com>:
>> PerlFAQ Server <brian@theperlreview.com> wrote:
>> >5.6: How can I copy a file?
>> >    Use the "File::Copy" module. It comes with Perl and can do a true copy
>> >    across file systems, and it does its magic in a portable fashion.
>> 
>> Which reminds me: 
>> The other day I ran into a problem with File::Copy regarding 32 vs. 64
>> bits. We have a standardized environment which is shared across several
>> hundred machines, some 32bit, some 64 bit.
>> 
>> When I tried to use File::Copy I got an error message basically stating
>> that it has been compiled for 32 bit and cannot be run on 64 bit (sorry,
>> I don't have the exact error message. Happened at work and I would need
>> to get back to the office for a repro).
>
>I presume this wasn't actually talking about File::Copy itself (which is
>pure-perl and thus portable) 

That's what confused me, too.

>but about some module it loaded (probably Scalar::Util). 

Hmmm, I'll double check as soon as I'm back in the office on Monday.

>> Is there a version of File::Copy that is agnostic to 32/64bit? Or are
>> there other suggestions for how to deal with a mixed 32/64bit
>> environment? Using separate environments for 32 and 64 bit machines is
>> not an option.
>
>You can't use XS modules across architectures, you need a copy per-arch.
>If you'd followed the standard directory structure for your perl
>install, you would have something like

[...]
>For some reason a lot of vendor distributions of perl seem to break
>this. The standard build on Win32 also breaks this. In both cases (and,
>really, in general) the best solution is to build your own perl
>installed in /opt/perl or somewhere, with the correct directory
>structure.

Thanks. That's very likely the problem because unfortunately in this
environment Perl is really only used as a utilitarian afterthought and
not really maintained to the level of main production tool.

jue


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

Date: Sat, 22 May 2010 16:14:19 +0100
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Conflict between 32 and 64bit (WAS: FAQ 5.6 How can I copy a file?)
Message-Id: <x9idnTOeSutRaWrWnZ2dnUVZ8mmdnZ2d@pipex.net>

On 05/22/10 15:39, Ben Morrow wrote:
>

> For some reason a lot of vendor distributions of perl seem to break
> this. The standard build on Win32 also breaks this. In both cases (and,
> really, in general) the best solution is to build your own perl
> installed in /opt/perl or somewhere, with the correct directory
> structure.

Or, even better, put it on an NFS automount - with arch-specific locations 
mounted via arch-specific variable so all systems of all architectures can 
share one instance of all Pure Perl code, and all systems of each 
architecture share the one arch-specific instance of compiled code.

Install once - run everywhere.


-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: Sat, 22 May 2010 12:34:20 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Example of the operator '..' in scalar context?
Message-Id: <e26fa24f-c6c5-460c-bb68-d393feeb8062@a20g2000vbc.googlegroups.com>

I think that list context refers to something link 1..3.

But I'm not sure how to use .. in scalar context and don't understand
what the following paragraph mean in man perlop mean. In the examples
following the following paragraph in man perlop. I don't see which one
is for scalar context. Would you please give me an easy example on how
to use .. in scalar context?

       In scalar context, ".." returns a boolean value.  The operator
is
       bistable, like a flip-flop, and emulates the line-range (comma)
       operator of sed, awk, and various editors ...


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

Date: Sat, 22 May 2010 21:42:05 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Example of the operator '..' in scalar context?
Message-Id: <t5slc7-0j4.ln1@osiris.mauzo.dyndns.org>


Quoth Peng Yu <pengyu.ut@gmail.com>:
> I think that list context refers to something link 1..3.
> 
> But I'm not sure how to use .. in scalar context and don't understand
> what the following paragraph mean in man perlop mean. In the examples
> following the following paragraph in man perlop. I don't see which one
> is for scalar context. Would you please give me an easy example on how
> to use .. in scalar context?
> 
>        In scalar context, ".." returns a boolean value.  The operator
> is
>        bistable, like a flip-flop, and emulates the line-range (comma)
>        operator of sed, awk, and various editors ...

 .. in scalar context is a very weird operator, but very useful when you
need it. The usual example would be something like

    while (<>) {
        /START/../STOP/ and print;
    }

or the equivalent one-liner

    perl -ne'/START/../STOP/ and print'

This will read a file up to the first line containing START, then print
the lines from there until a line containing STOP.

The special behaviour with integer arguments (they are compared with $.,
the current input line number) is also for cases like this, so that

    perl -ne'2../^$/ and print'

will extract just the header of the first message in a Unix mailbox (for
example).

Ben



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

Date: Sat, 22 May 2010 16:25:10 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Example of the operator '..' in scalar context?
Message-Id: <slrnhvgijd.3dp.tadmc@tadbox.sbcglobal.net>

Peng Yu <pengyu.ut@gmail.com> wrote:

> I think that list context refers to something link 1..3.


This illustrates that you do yet have a clear understanding of context,
as described in the "Context" section in 

    perldoc perldata

The "context" of an expression depends on what is "around" it (ie. its
context).

It is not possible to know which behaviour .. will give you given only

    1..3

as we cannot see what is "around" that expression.

    print 1..3;     # .. in list context (print takes a LIST)

    print if (1..3) # .. in scalar context (booleans are always scalars)


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Sat, 22 May 2010 20:21:09 GMT
From: James Egan <jegan473@comcast.net>
Subject: Using rename script to change multiple files
Message-Id: <V0XJn.671505$FK3.158072@en-nntp-06.dc1.easynews.com>

I'm trying to use the perl "rename" script to rename batches of files.  
So if the files are say:

0123.mov
0124.mov
0125.mov


I want to rename something like:

birthday-01.mov
birthday-02.mov
birthday-03.mov

I've been experimenting with the rename script like this:

rename s/\..+$/Birthday-01/ *


Can this be done with regular expressions only?  I was thinking of trying 
to use the seq command to get the numeric sequence part of the file names.

-Thanks


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

Date: Sat, 22 May 2010 22:03:33 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Using rename script to change multiple files
Message-Id: <slrnhvgl5l.jms.nospam-abuse@powdermilk.math.berkeley.edu>

On 2010-05-22, James Egan <jegan473@comcast.net> wrote:
> 0123.mov
> 0124.mov
> 0125.mov

> I want to rename something like:

> birthday-01.mov
> birthday-02.mov
> birthday-03.mov

> Can this be done with regular expressions only?

Regular expressions may contain arbitrary code.  With pfind
(ilyaz.org/software/tmp) which is a much improved version of `rename',
I would do

 pfind -nosubdir '-var=$c' . '++$c; s/^[^.]*/birthday-$c/'

Not what you want?  Add a sprintf...  (I would do it outside s///, but
one can do it inside too with s///e; then one can do ++$c there
too...)

Hope this helps,
Ilya


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

Date: Sat, 22 May 2010 12:13:32 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: What do N and R in $NR stand for?
Message-Id: <eb46c38b-f1bc-427f-9650-9027bdbeb22a@y12g2000vbg.googlegroups.com>

I know $NR is the same as $INPUT_LINE_NUMBER. But I'm wondering what N
and R in NR stand for.

I think R might stand for numbeR? Does N stand for iNput or liNe?


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

Date: Sat, 22 May 2010 15:22:49 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: What do N and R in $NR stand for?
Message-Id: <87632fu4fq.fsf@quad.sysarch.com>

>>>>> "PY" == Peng Yu <pengyu.ut@gmail.com> writes:

  PY> I know $NR is the same as $INPUT_LINE_NUMBER. But I'm wondering what N
  PY> and R in NR stand for.

  PY> I think R might stand for numbeR? Does N stand for iNput or liNe?

Number of Records. it was inherited from awk which has the same variable
NR (from the awk man page):

       NR          The total number of input records seen so far.

and that also works as the line number so they are the same thing with
different names for historical reasons.

it helps when learning perl to know its major influences which are c,
shell and awk. c is still used as is shell. awk is pretty much a side
player if at all today but when i first learned perl, awk was in heavy
use. in any case many awkish things are in perl such as some names, the
range operator (scalar mode), hashes, the -p option loop, etc.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Sat, 22 May 2010 21:36:32 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: What do N and R in $NR stand for?
Message-Id: <grrlc7-0j4.ln1@osiris.mauzo.dyndns.org>


Quoth Peng Yu <pengyu.ut@gmail.com>:
> I know $NR is the same as $INPUT_LINE_NUMBER. But I'm wondering what N
> and R in NR stand for.
> 
> I think R might stand for numbeR? Does N stand for iNput or liNe?

I presume you are using the English module? I would recommend against
it. Quite apart from the minor performance penalty (which can be avoided
with newer versions of English) the puncuation names are much more
familiar to most Perl programmers.

Ben



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

Date: Sat, 22 May 2010 08:09:39 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Where is the perl documentationn for '..' (command line)
Message-Id: <46d26841-79b7-400b-8d9b-8835ce780f60@a20g2000vbc.googlegroups.com>

man perldata touchs '..' a little bit. But it seems that there should
a place that discuss '..' in details. Would you please let me know
where it is?


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

Date: Sat, 22 May 2010 17:17:24 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: Where is the perl documentationn for '..' (command line)
Message-Id: <87tyq0yni3.fsf@vps1.hacking.dk>

Peng Yu <pengyu.ut@gmail.com> writes:

> man perldata touchs '..' a little bit. But it seems that there should
> a place that discuss '..' in details. Would you please let me know
> where it is?

The .. operator is documented in 'man perlop'. Look for the heading
'Range operators'.

//Makholm


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

Date: Sat, 22 May 2010 08:22:54 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Where is the perl documentationn for '..' (command line)
Message-Id: <9ktfv59q14dr323hp93mlqn3aig845vb2p@4ax.com>

Peng Yu <pengyu.ut@gmail.com> wrote:
>man perldata touchs '..' a little bit. But it seems that there should
>a place that discuss '..' in details. Would you please let me know
>where it is?

It's an operator just like +, *, ==, gt, !, ... and can be found in
perldoc perlop.

jue


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

Date: Sat, 22 May 2010 12:23:09 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Why $NR and $INPUT_LINE_NUMBER are not the same as $.?
Message-Id: <cddfc597-ca21-4115-9092-32bfe99b3661@d12g2000vbr.googlegroups.com>

I have the following perl script.

$ cat main.pl
#!/usr/bin/env perl

#use warnings;

while(<STDIN>) {
  print "#$_";
  print "\$INPUT_LINE_NUMBER=$INPUT_LINE_NUMBER\n";
  print "\$NR=$NR\n";
  print "\$.=$.\n";
}

However, the output shows that $NR and $INPUT_LINE_NUMBER are not the
same as $.. According to my understand, these three variable should be
the same. Would you please let me know why they are not the same in
this case? And how to make them the same?

$ ./main.pl < main.pl
##!/usr/bin/env perl
$INPUT_LINE_NUMBER=
$NR=
$.=1
#
$INPUT_LINE_NUMBER=
$NR=
$.=2
##use warnings;
$INPUT_LINE_NUMBER=
$NR=
$.=3
#
$INPUT_LINE_NUMBER=
$NR=
$.=4
#while(<STDIN>) {
$INPUT_LINE_NUMBER=
$NR=
$.=5
#  print "#$_";
$INPUT_LINE_NUMBER=
$NR=
$.=6
#  print "\$INPUT_LINE_NUMBER=$INPUT_LINE_NUMBER\n";
$INPUT_LINE_NUMBER=
$NR=
$.=7
#  print "\$NR=$NR\n";
$INPUT_LINE_NUMBER=
$NR=
$.=8
#  print "\$.=$.\n";
$INPUT_LINE_NUMBER=
$NR=
$.=9
#}
$INPUT_LINE_NUMBER=
$NR=
$.=10
#
$INPUT_LINE_NUMBER=
$NR=
$.=11


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

Date: Sat, 22 May 2010 15:25:36 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Why $NR and $INPUT_LINE_NUMBER are not the same as $.?
Message-Id: <87sk5jspqn.fsf@quad.sysarch.com>

>>>>> "PY" == Peng Yu <pengyu.ut@gmail.com> writes:


  PY> However, the output shows that $NR and $INPUT_LINE_NUMBER are not the
  PY> same as $.. According to my understand, these three variable should be
  PY> the same. Would you please let me know why they are not the same in
  PY> this case? And how to make them the same?

you need to use English to enable the spelled out variables. this is
documented at the very beginning of perlvar. always read that when you
first have a question on any of perl's builtin variables.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Sat, 22 May 2010 12:36:12 -0700 (PDT)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Re: Why $NR and $INPUT_LINE_NUMBER are not the same as $.?
Message-Id: <1bc95c7d-01f0-4351-bbf2-fc768e02796e@b21g2000vbh.googlegroups.com>

On May 22, 2:25=A0pm, "Uri Guttman" <u...@StemSystems.com> wrote:
> >>>>> "PY" =3D=3D Peng Yu <pengyu...@gmail.com> writes:
>
> =A0 PY> However, the output shows that $NR and $INPUT_LINE_NUMBER are not=
 the
> =A0 PY> same as $.. According to my understand, these three variable shou=
ld be
> =A0 PY> the same. Would you please let me know why they are not the same =
in
> =A0 PY> this case? And how to make them the same?
>
> you need to use English to enable the spelled out variables. this is
> documented at the very beginning of perlvar. always read that when you
> first have a question on any of perl's builtin variables.
>
Sorry, I directly jumped to the description of $., and incorrectly
assume that the three variables are the same by default.


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

Date: Sat, 22 May 2010 09:19:51 -0700 (PDT)
From: Dilbert <dilbert1999@gmail.com>
Subject: Re: will there be a Strawberry Perl 6 / Rakudo Star ?
Message-Id: <edac0bad-36e9-4db4-a18a-9e0e72324506@m21g2000vbr.googlegroups.com>

On 22 mai, 16:16, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Dilbert <dilbert1...@gmail.com>:
> > On 22 mai, 13:09, Dilbert <dilbert1...@gmail.com> wrote:
> > > On 10 mai, 18:59, Ben Morrow <b...@morrow.me.uk> wrote:
> > > > Quoth Dilbert <dilbert1...@gmail.com>:
>
> > > > > ...and I was thinking: suppose Rakudo Star will be shipped in June,
> > > > > are there any efforts being made by the good people who gave us
> > > > > Strawberry Perl 5.8, 5.10 and 5.12 to give us also Strawberry Perl 6 /
> > > > > Rakudo Star ?
>
> > > > The last I heard about this washttp://use.perl.org/~Alias/journal/38200
> > > > . That's from Jan 09, though, so some progress may have been made since
> > > > then.
>
> > > So I have downloaded and installed what I think is the "parrotwin32
>
> > setup":http://sourceforge.net/projects/parrotwin32/files/parrotwin32%20setup...
>
> > > ...and what I think is the "matching version of the parrot-rakudo
> > > addon"http://sourceforge.net/projects/parrotwin32/files/parrot-rakudo%20add...
>
> > > After successful installation, I get a nice subdirectory installed
> > > under C:\Parrot-2.4.0\bin
> > > and that directory contains even a "perl6.exe"
>
> > > ...but when I want to run perl6.exe, I get an error because
> > > "libgcc_s_sjlj-1.dll" is missing.
>
> > > Does anybody know where I can find "libgcc_s_sjlj-1.dll" ?
>
> Have you got your PATH set correctly? Win32 uses PATH to find DLLs
> (sometimes... the rules are complicated).

I have the Activestate MinGW package installed ("ppm install MinGW").
This installation does not seem to have the required DLLs. I will try
and download the full MinGW compiler to see if that contains
"libgcc_s_sjlj-1.dll".

> > > Second option is building from source:
>
> I can't help you with this, and I suspect nobody here can. Try one of
> the Perl 6 mailing lists.

I will try one of the Perl 6 mailing lists.


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

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 2961
***************************************


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