[26238] in Perl-Users-Digest
Perl-Users Digest, Issue: 8423 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 15 18:05:29 2005
Date: Thu, 15 Sep 2005 15:05:04 -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, 15 Sep 2005 Volume: 10 Number: 8423
Today's topics:
Re: Better way of checking file/directory spec in Win32 <news@lawshouse.org>
Re: Better way of checking file/directory spec in Win32 (Anno Siegel)
Re: Better way of checking file/directory spec in Win32 <jgibson@mail.arc.nasa.gov>
Re: Better way of checking file/directory spec in Win32 (Anno Siegel)
Re: FAQ 8.23 How can I open a pipe both to and from a c <1usa@llenroc.ude.invalid>
Re: Need a regex <randy@SpamFree.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 15 Sep 2005 19:07:21 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: Better way of checking file/directory spec in Win32?
Message-Id: <1126807641.29763.0@sabbath.news.uk.clara.net>
Anno Siegel wrote:
> My first idea when I read this was (untested):
>
> my @valid = grep -e, map glob, @specs;
>
> but you seem to want a more detailed analysis of each entry.
Hmm; I've a lot still to learn. That wouldn't have been my first idea;
nor my twenty-first either.
>> if (scalar @globs == 1){
Yes, of course. Laziness, unfortunately.
> There are issues with some forms of glob() that need looking at.
>
> Under Unix, it is quite possible to have a file named like a glob
> pattern: "touch '*.foo'" creates a file with an actual asterisk in
> its name.
How horrible. Fortunately nobody other than me is going to run this
thing and I'll just stay away from things like that.
> This problem may be void under windows, I don't know.
It is; "*" is not a valid character in Redmond's file names.
> A different problem occurs with globs of the form "foo.{a,b,c}".
> This expands to "foo.a", "foo.b" and "foo.c" with no check against
> the file system
Once again I can avoid those and get round the problem. But thank you
for pointing out the breadth and depth of the problem I am trying to solve!
------------------------------
Date: 15 Sep 2005 19:04:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Better way of checking file/directory spec in Win32?
Message-Id: <dgcgjv$m5b$1@mamenchi.zrz.TU-Berlin.DE>
Henry Law <news@lawshouse.org> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > My first idea when I read this was (untested):
> >
> > my @valid = grep -e, map glob, @specs;
> >
> > but you seem to want a more detailed analysis of each entry.
>
> Hmm; I've a lot still to learn. That wouldn't have been my first idea;
> nor my twenty-first either.
Ah, but it isn't hard at all once you get into the habit of considering
data structures (like arrays and lists, in this case) as units that are
the objects of operations. In Perl, there are only three "operators",
map, grep, and sort, that transform one list into another, but they are
powerful because they all take a user-supplied function that works on
list elements.
OO takes that way of thinking a step further and lets you define your
own operations on complex data structures. Working with objects for
a while is habit-forming that way. You start to see would-be objects
all over your normal code as well, which is a productive way of looking
at things.
> >> if (scalar @globs == 1){
> Yes, of course. Laziness, unfortunately.
Ah, the kind of laziness that results in more text rather than less.
Who was it who didn't have time for a short letter, so wrote a long
one instead?
> > There are issues with some forms of glob() that need looking at.
> >
> > Under Unix, it is quite possible to have a file named like a glob
> > pattern: "touch '*.foo'" creates a file with an actual asterisk in
> > its name.
> How horrible. Fortunately nobody other than me is going to run this
> thing and I'll just stay away from things like that.
>
> > This problem may be void under windows, I don't know.
> It is; "*" is not a valid character in Redmond's file names.
Yes, I learned that in the meantime too.
> > A different problem occurs with globs of the form "foo.{a,b,c}".
> > This expands to "foo.a", "foo.b" and "foo.c" with no check against
> > the file system
> Once again I can avoid those and get round the problem. But thank you
> for pointing out the breadth and depth of the problem I am trying to solve!
I'm afraid it is not so much depth, but a certain murkiness in the
problem that I'm pointing out. The question whether a certain string
"is" a glob or a plain filename can be answered variously. As a
programmer, you must decide. It seems to me that the decision is
rather implicit in the code. If it mattered (as it probably doesn't)
it would be advisable to make the decision explicit.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Thu, 15 Sep 2005 12:39:59 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Better way of checking file/directory spec in Win32?
Message-Id: <150920051239592149%jgibson@mail.arc.nasa.gov>
In article <dgcgjv$m5b$1@mamenchi.zrz.TU-Berlin.DE>, Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de> wrote:
>
> Ah, the kind of laziness that results in more text rather than less.
> Who was it who didn't have time for a short letter, so wrote a long
> one instead?
>
Mark Twain
------------------------------
Date: 15 Sep 2005 19:58:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Better way of checking file/directory spec in Win32?
Message-Id: <dgcjpo$npq$2@mamenchi.zrz.TU-Berlin.DE>
Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in comp.lang.perl.misc:
> In article <dgcgjv$m5b$1@mamenchi.zrz.TU-Berlin.DE>, Anno Siegel
> <anno4000@lublin.zrz.tu-berlin.de> wrote:
> >
> > Ah, the kind of laziness that results in more text rather than less.
> > Who was it who didn't have time for a short letter, so wrote a long
> > one instead?
> >
>
> Mark Twain
Thanks!
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Thu, 15 Sep 2005 22:02:14 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: FAQ 8.23 How can I open a pipe both to and from a command?
Message-Id: <Xns96D2B77CE50A9asu1cornelledu@127.0.0.1>
"Omar Zakaria" <crono@cc.gatech.edu> wrote in
news:dgc2u9$3a4$1@news-int2.gatech.edu:
> The following is the code I'm using:
Post real code! This cannot be the code you are using.
D:\Home\asu1\UseNet\clpmisc> perl -v
This is perl, v5.8.7 built for MSWin32-x86-multi-thread
(with 7 registered patches, see perl -V for more detail)
> #!/usr/bin/
D:\Home\asu1\UseNet\clpmisc> perl c.pl
Can't exec /usr/bin/ at c.pl line 1.
#!/usr/bin/perl
use IPC::Open2;
use strict;
use warnings;
open2 my $read, my $write, 'cmd.exe'
or die "Could not open! $!";
select $write;
$| = 1;
print $write "echo We are the pirates who don't do anything!\n";
print $write "dir t*/w\n";
print STDOUT while <$read>;
__END__
D:\Home\asu1\UseNet\clpmisc> c.pl
D:\Home\asu1\UseNet\clpmisc> echo We are the pirates who don't do
anything!
We are the pirates who don't do anything!
D:\Home\asu1\UseNet\clpmisc> dir t*/w
Volume in drive D is DATA
Volume Serial Number is ACC0-AC7B
Directory of D:\Home\asu1\UseNet\clpmisc
[t] [T1] [test] t.c t.csv
t.gif t.html t.o t.pl t.png
t.zip t1.pl t2.pl T2.pm table.pl
tada.pl taint.pl Test.class test.db test.gif
Test.java test.lock test.txt Test2.java TestMulti.pm
thr.pl tpng tt.pl ttt.pl
26 File(s) 103,179 bytes
3 Dir(s) 6,603,915,264 bytes free
The last print to STDOUT is there so you can actually see the output.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Thu, 15 Sep 2005 20:19:29 GMT
From: "Randy Harris" <randy@SpamFree.com>
Subject: Re: Need a regex
Message-Id: <lHkWe.1367$D42.153@newssvr19.news.prodigy.com>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
news:Xns96D0B43E61878asu1cornelledu@127.0.0.1...
> Shane <shane@weasel.is-a-geek.net> wrote in
> news:pan.2005.09.13.21.28.25.356154@weasel.is-a-geek.net:
>
> > On Tue, 13 Sep 2005 21:20:38 +0000, Randy Harris wrote:
> >
> >> I would appreciate help creating a regex. I have a file that
> >> contains lines that begin with several groups of numbers separated by
> >> a dash followed by a dash and then non digit data. For example:
> >>
> >> 123-12-23-Bottom Bracket
> >> 561-318-001-Cowling Spacer 2
> >> 453-2193-Fitting Hose
> >>
> >> I need to capture the numeric portion, up to but not including the
> >> last dash. From the above samples I would want:
> >>
> >> 123-12-23
> >> 561-318-001
> >> 453-2193
> >>
> >> Thank you for any help.
>
> To the OP: This is not a "write my code for me" service. If you do not
> put any effort into helping others help you, you cannot expect others to
> put much effort into helping you.
>
What could I have done differently to ask for help without incurring the
wrath of regulars such as yourself and Tad?
------------------------------
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 8423
***************************************