[33071] in Perl-Users-Digest
Perl-Users Digest, Issue: 4347 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 12 09:09:19 2015
Date: Mon, 12 Jan 2015 06:09:03 -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 Mon, 12 Jan 2015 Volume: 11 Number: 4347
Today's topics:
Question on file glob operator. <see.my.sig@for.my.address>
Re: Question on file glob operator. (Tim McDaniel)
Re: Question on file glob operator. <hjp-usenet3@hjp.at>
Re: Question on file glob operator. (Tim McDaniel)
Re: Question on file glob operator. <gravitalsun@hotmail.foo>
Re: Twelve Drummers Drumming <rweikusat@mobileactivedefense.com>
Re: Twelve Drummers Drumming <tzz@lifelogs.com>
Re: Twelve Drummers Drumming <rweikusat@mobileactivedefense.com>
Re: Twelve Drummers Drumming <gravitalsun@hotmail.foo>
Re: Twelve Drummers Drumming <tzz@lifelogs.com>
Re: Twelve Drummers Drumming <rweikusat@mobileactivedefense.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 10 Jan 2015 13:27:52 -0800
From: Robbie Hatley <see.my.sig@for.my.address>
Subject: Question on file glob operator.
Message-Id: <p_idnfXR_vnQBCzJnZ2dnUVZ57ydnZ2d@giganews.com>
I just discovered the "file glob operator". (Been reading
"Programming Perl".) It seems to do most of what opendir,
readdir, closedir do, more concisely. But by default, it
doesn't list "hidden" files (eg, ".bashrc"). I can force
the issue by using <.* *> instead of <*>. But is there
some other way to tell Perl that one wants the <*> operator
to also return the names of files starting with "."?
For working examples, see these two scripts, which do exactly
the same thing, in very different ways:
#!/usr/bin/perl
# file-glob-test-1.perl
opendir($::dot, $::CurDir) or die "Can\'t open directory. $!. ";
@::Files = readdir($::dot);
closedir($::dot);
foreach my $filename (@::Files) {
my ($inode, $size, $mtime) = (stat($filename))[1,7,9];
print("$filename $inode $size $mtime\n");
};
#!/usr/bin/perl
# file-glob-test-2.perl
foreach my $filename (<.* *>) {
my ($inode, $size, $mtime) = (stat($filename))[1,7,9];
print("$filename $inode $size $mtime\n");
};
--
Cheers,
Robbie Hatley
Midway City, CA, USA
perl -le 'print "\154o\156e\167o\154f\100w\145ll\56c\157m"'
http://www.well.com/user/lonewolf/
------------------------------
Date: Sat, 10 Jan 2015 21:48:02 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Question on file glob operator.
Message-Id: <m8s6mi$ksf$1@reader2.panix.com>
In article <p_idnfXR_vnQBCzJnZ2dnUVZ57ydnZ2d@giganews.com>,
Robbie Hatley <see.my.sig@for.my.address> wrote:
>I just discovered the "file glob operator". (Been reading
>"Programming Perl".) It seems to do most of what opendir,
>readdir, closedir do, more concisely. But by default, it
>doesn't list "hidden" files (eg, ".bashrc"). I can force
>the issue by using <.* *> instead of <*>. But is there
>some other way to tell Perl that one wants the <*> operator
>to also return the names of files starting with "."?
Yeah, there are two ways:
- force the issue by using <.* *>
- opendir, readdir, closedir
If you read up on this use of <...>, like at
http://perldoc.perl.org/functions/glob.html
http://perldoc.perl.org/File/Glob.html
you see that it has all the convenience and limitations of csh
globbing
- * in csh (and sh and bash) doesn't match dot files
- glob splits at whitespace unless you take heroic measures
and I don't see a File::Glob flag that does what you want.
For safety and full power, I'd just use opendir, readdir, closedir
and Perl regular expression matching to select the files I want.
--
Tim McDaniel, tmcd@panix.com
------------------------------
Date: Sun, 11 Jan 2015 01:13:55 +0100
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: Question on file glob operator.
Message-Id: <slrnmb3g23.pn8.hjp-usenet3@hrunkner.hjp.at>
On 2015-01-10 21:48, Tim McDaniel <tmcd@panix.com> wrote:
> If you read up on this use of <...>, like at
> http://perldoc.perl.org/functions/glob.html
> http://perldoc.perl.org/File/Glob.html
> you see that it has all the convenience and limitations of csh
> globbing
> - * in csh (and sh and bash) doesn't match dot files
> - glob splits at whitespace unless you take heroic measures
> and I don't see a File::Glob flag that does what you want.
Glob doesn't split on whitespace. Not even in csh, and definitely not in
Perl:
hrunkner:~/tmp/t 1:09 :-) 225% touch 'a file'
hrunkner:~/tmp/t 1:09 :-) 226% perl -E 'say for <*>'
a file
hrunkner:~/tmp/t 1:09 :-) 227% csh
hrunkner:~/tmp/t% foreach d (*)
foreach? echo $d
foreach? end
a file
hrunkner:~/tmp/t%
> For safety and full power, I'd just use opendir, readdir, closedir
> and Perl regular expression matching to select the files I want.
ACK. Or File::Find for recursively processing a file tree.
hp
--
_ | Peter J. Holzer | Fluch der elektronischen Textverarbeitung:
|_|_) | | Man feilt solange an seinen Text um, bis
| | | hjp@hjp.at | die Satzbestandteile des Satzes nicht mehr
__/ | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel
------------------------------
Date: Sun, 11 Jan 2015 04:39:19 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Question on file glob operator.
Message-Id: <m8supn$5mc$1@reader2.panix.com>
In article <slrnmb3g23.pn8.hjp-usenet3@hrunkner.hjp.at>,
Peter J. Holzer <hjp-usenet3@hjp.at> wrote:
>On 2015-01-10 21:48, Tim McDaniel <tmcd@panix.com> wrote:
>> If you read up on this use of <...>, like at
>> http://perldoc.perl.org/functions/glob.html
>> http://perldoc.perl.org/File/Glob.html
>> you see that it has all the convenience and limitations of csh
>> globbing
>> - * in csh (and sh and bash) doesn't match dot files
>> - glob splits at whitespace unless you take heroic measures
>> and I don't see a File::Glob flag that does what you want.
>
>Glob doesn't split on whitespace.
It doesn't split on whitespace *in its results*. It does split on
whitespace in its argument:
Note that "glob" splits its arguments on whitespace and treats
each segment as separate pattern. As such, "glob("*.c *.h")"
matches all files with a .c or .h extension. The expression
"glob(".* *")" matches all files in the current working directory.
--
Tim McDaniel, tmcd@panix.com
------------------------------
Date: Sun, 11 Jan 2015 21:41:56 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Question on file glob operator.
Message-Id: <m8ujm9$dts$1@mouse.otenet.gr>
On 10/1/2015 23:27, Robbie Hatley wrote:
>
> I just discovered the "file glob operator". (Been reading
...
# what you ask is
print "*$_*\n" for <~/{.*,*}>;
# or
print "*$_*\n" for glob '~/{.*,*}';
------------------------------
Date: Fri, 09 Jan 2015 22:17:58 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Twelve Drummers Drumming
Message-Id: <874mrzsind.fsf@doppelsaurus.mobileactivedefense.com>
Ted Zlatanov <tzz@lifelogs.com> writes:
> On Fri, 09 Jan 2015 17:11:44 +0000 Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
>
> RW> George Mpouras <gravitalsun@hotmail.foo> writes:
>>> On 8/1/2015 17:57, Ted Zlatanov wrote:
>>>> use Lingua::EN::Inflect qw( NUMWORDS ORD );
>>>>
>>>> say ORD(NUMWORDS($_)) for 1..12;
>
>>> for (1..@Gift) { say
>>> "On the ", ORD(NUMWORDS $_),
>>> " day of Christmas my true love gave to me
>>> @Gift[reverse 0..$_-1]" }
>
> RW> You've now successfully replaced a single line of code with 1,273 lines
> RW> of code most of which have no relation to the problem at hand whatsoever
>
> I think you mean "one thousand, two hundred and seventy-three"[1]
>
> HTH
> Ted
>
> [1] perl -MLingua::EN::Inflect=NUMWORDS -e'print scalar NUMWORDS(1273)'
I'm not in the mood to download this but you may want to try
perl -MLingua::EN::Inflect=NUMWORDS -e'print scalar NUMWORDS(1_273)'
------------------------------
Date: Fri, 09 Jan 2015 20:44:58 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Twelve Drummers Drumming
Message-Id: <87lhlbo1d1.fsf@lifelogs.com>
On Fri, 09 Jan 2015 22:17:58 +0000 Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
RW> Ted Zlatanov <tzz@lifelogs.com> writes:
>> [1] perl -MLingua::EN::Inflect=NUMWORDS -e'print scalar NUMWORDS(1273)'
RW> I'm not in the mood to download this but you may want to try
RW> perl -MLingua::EN::Inflect=NUMWORDS -e'print scalar NUMWORDS(1_273)'
Yes, now you're getting it. Can you "hex-press" yourself?
Ted
------------------------------
Date: Sat, 10 Jan 2015 18:36:54 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Twelve Drummers Drumming
Message-Id: <871tn2o52x.fsf@doppelsaurus.mobileactivedefense.com>
Ted Zlatanov <tzz@lifelogs.com> writes:
> On Fri, 09 Jan 2015 22:17:58 +0000 Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
> RW> Ted Zlatanov <tzz@lifelogs.com> writes:
>>> [1] perl -MLingua::EN::Inflect=NUMWORDS -e'print scalar NUMWORDS(1273)'
>
> RW> I'm not in the mood to download this but you may want to try
>
> RW> perl -MLingua::EN::Inflect=NUMWORDS -e'print scalar NUMWORDS(1_273)'
>
> Yes, now you're getting it. Can you "hex-press" yourself?
I "get"[*] that this seems related to use of thousands-separators with
4-digit numbers. There's no unique convention for that in German, eg,
both 1000 and 1.000 exist, and there isn't one in English, either (as
Wikipedia will tell anyone asking).
[*] Actually, I'm conjecturing this since you didn't bother to express
yourself clearly.
------------------------------
Date: Sat, 10 Jan 2015 21:35:01 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Twelve Drummers Drumming
Message-Id: <m8rut8$jgi$1@mouse.otenet.gr>
On 9/1/2015 20:28, Ted Zlatanov wrote:
ich have no relation to the problem at hand whatsoever
>
> I think you mean "one thousand, two hundred and seventy-three"[1]
>
>
just for the quriosty, how does the 1273 comes concerning the code
efficiecly and quality ;
------------------------------
Date: Sun, 11 Jan 2015 12:10:09 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Twelve Drummers Drumming
Message-Id: <87h9vxnszy.fsf@lifelogs.com>
On Sat, 10 Jan 2015 18:36:54 +0000 Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
RW> Ted Zlatanov <tzz@lifelogs.com> writes:
>> On Fri, 09 Jan 2015 22:17:58 +0000 Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
RW> Ted Zlatanov <tzz@lifelogs.com> writes:
>>>> [1] perl -MLingua::EN::Inflect=NUMWORDS -e'print scalar NUMWORDS(1273)'
>>
RW> I'm not in the mood to download this but you may want to try
>>
RW> perl -MLingua::EN::Inflect=NUMWORDS -e'print scalar NUMWORDS(1_273)'
>>
>> Yes, now you're getting it. Can you "hex-press" yourself?
RW> I "get"[*] that this seems related to use of thousands-separators with
RW> 4-digit numbers. There's no unique convention for that in German, eg,
RW> both 1000 and 1.000 exist, and there isn't one in English, either (as
RW> Wikipedia will tell anyone asking).
Clearly, I was actually commenting on the art of Salvador Dali.
RW> [*] Actually, I'm conjecturing this since you didn't bother to express
RW> yourself clearly.
ITYM "hex-press."
Ted
------------------------------
Date: Sun, 11 Jan 2015 18:43:30 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Twelve Drummers Drumming
Message-Id: <87zj9pyx7x.fsf@doppelsaurus.mobileactivedefense.com>
Ted Zlatanov <tzz@lifelogs.com> writes:
> On Sat, 10 Jan 2015 18:36:54 +0000 Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
> RW> Ted Zlatanov <tzz@lifelogs.com> writes:
>>> On Fri, 09 Jan 2015 22:17:58 +0000 Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
> RW> Ted Zlatanov <tzz@lifelogs.com> writes:
>>>>> [1] perl -MLingua::EN::Inflect=NUMWORDS -e'print scalar NUMWORDS(1273)'
>>>
> RW> I'm not in the mood to download this but you may want to try
>>>
> RW> perl -MLingua::EN::Inflect=NUMWORDS -e'print scalar NUMWORDS(1_273)'
>>>
>>> Yes, now you're getting it. Can you "hex-press" yourself?
>
> RW> I "get"[*] that this seems related to use of thousands-separators with
> RW> 4-digit numbers. There's no unique convention for that in German, eg,
> RW> both 1000 and 1.000 exist, and there isn't one in English, either (as
> RW> Wikipedia will tell anyone asking).
>
> Clearly, I was actually commenting on the art of Salvador Dali.
"Whatever turns your crank"
------------------------------
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 4347
***************************************