[31277] in Perl-Users-Digest
Perl-Users Digest, Issue: 2522 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 17 21:09:47 2009
Date: Fri, 17 Jul 2009 18:09:11 -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 Fri, 17 Jul 2009 Volume: 11 Number: 2522
Today's topics:
Re: FAQ 5.41 How do I delete a directory tree? <jimsgibson@gmail.com>
How to substitute (regex) single newline (0A) character <m@epf.pl>
Re: How to substitute (regex) single newline (0A) chara <smallpond@juno.com>
Re: How to substitute (regex) single newline (0A) chara <m@epf.pl>
Re: How to substitute (regex) single newline (0A) chara <tadmc@seesig.invalid>
Re: How to substitute (regex) single newline (0A) chara sln@netherlands.com
Re: Perl Fails To List All The Multiple Matches In The <m@rtij.nl.invlalid>
Re: Perl Fails To List All The Multiple Matches In The <veatchla@yahoo.com>
Re: Perl Fails To List All The Multiple Matches In The <veatchla@yahoo.com>
Re: Perl Fails To List All The Multiple Matches In The sln@netherlands.com
Re: Perl Fails To List All The Multiple Matches In The sln@netherlands.com
Re: Perl Fails To List All The Multiple Matches In The sln@netherlands.com
Re: Perl Fails To List All The Multiple Matches In The <jurgenex@hotmail.com>
Re: Perl Fails To List All The Multiple Matches In The sln@netherlands.com
Re: Perl Fails To List All The Multiple Matches In The <hjp-usenet2@hjp.at>
Re: Perl Fails To List All The Multiple Matches In The <ben@morrow.me.uk>
Re: Perl Fails To List All The Multiple Matches In The <uri@stemsystems.com>
Re: Perl Fails To List All The Multiple Matches In The <jurgenex@hotmail.com>
Re: Perl Fails To List All The Multiple Matches In The sln@netherlands.com
Re: Perl Fails To List All The Multiple Matches In The <tadmc@seesig.invalid>
Re: Simple Regex Doubt sln@netherlands.com
Re: Simple Regex Doubt sln@netherlands.com
Re: Simple Regex Doubt sln@netherlands.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 17 Jul 2009 17:01:08 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: FAQ 5.41 How do I delete a directory tree?
Message-Id: <170720091701081307%jimsgibson@gmail.com>
In article <6gu6j6-sc4.ln1@blue.stonehenge.com>, PerlFAQ Server
<brian@stonehenge.com> wrote:
> This is an excerpt from the latest version perlfaq5.pod, which
> comes with the standard Perl distribution. These postings aim to
> reduce the number of repeated questions as well as allow the community
> to review and update the answers. The latest version of the complete
> perlfaq is at http://faq.perl.org .
>
> --------------------------------------------------------------------
>
> 5.41: How do I delete a directory tree?
>
> (contributed by brian d foy)
>
> If you have an empty directory, you can use Perl's built-in "rmdir". If
> the directory is not empty (so, no files or subdirectories), you either
> have to empty it yourself (a lot of work) or use a module to help you.
I can't really figure out what "(so, no files or subdirectories)" means
here. It seems contradictory to me.
--
Jim Gibson
------------------------------
Date: Fri, 17 Jul 2009 04:40:01 -0700 (PDT)
From: msciwoj <m@epf.pl>
Subject: How to substitute (regex) single newline (0A) character on Win32
Message-Id: <d58a6048-a6d5-4970-9e6f-7068a8dd2386@s15g2000yqs.googlegroups.com>
Does anyone have an idea how to do output single \n (0A) character
instead of \r\n (0D0A) in win32?
Let's say I do replacement:
s/newlinemarker/\n/mg
and want to substitute single character 0A
Windows implementation seems to always be smarter and uses 0D0A
automatically... How to prevent it?
I tried:
\n
\r
\x0a
\cJ
...nothing worked so far...
------------------------------
Date: Fri, 17 Jul 2009 09:30:21 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: How to substitute (regex) single newline (0A) character on Win32
Message-Id: <h3pup6$8kq$1@news.eternal-september.org>
msciwoj wrote:
> Does anyone have an idea how to do output single \n (0A) character
> instead of \r\n (0D0A) in win32?
> Let's say I do replacement:
> s/newlinemarker/\n/mg
> and want to substitute single character 0A
> Windows implementation seems to always be smarter and uses 0D0A
> automatically... How to prevent it?
> I tried:
> \n
> \r
> \x0a
> \cJ
> ...nothing worked so far...
binmode should work.
------------------------------
Date: Fri, 17 Jul 2009 07:54:56 -0700 (PDT)
From: msciwoj <m@epf.pl>
Subject: Re: How to substitute (regex) single newline (0A) character on Win32
Message-Id: <91f7d67b-b8c9-4238-af04-abae795b1c6b@v20g2000yqm.googlegroups.com>
It is! Thanks!
------------------------------
Date: Fri, 17 Jul 2009 10:58:32 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: How to substitute (regex) single newline (0A) character on Win32
Message-Id: <slrnh617je.m34.tadmc@tadmc30.sbcglobal.net>
msciwoj <m@epf.pl> wrote:
> It is!
What is?
What is what?
It is customary to quote some context in Usenet followups.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 17 Jul 2009 14:13:00 -0700
From: sln@netherlands.com
Subject: Re: How to substitute (regex) single newline (0A) character on Win32
Message-Id: <h5q1655l4aesdr8e1c7k4n1e0vkiigrlp5@4ax.com>
On Fri, 17 Jul 2009 04:40:01 -0700 (PDT), msciwoj <m@epf.pl> wrote:
>Does anyone have an idea how to do output single \n (0A) character
>instead of \r\n (0D0A) in win32?
>Let's say I do replacement:
>s/newlinemarker/\n/mg
>and want to substitute single character 0A
>Windows implementation seems to always be smarter and uses 0D0A
>automatically... How to prevent it?
>I tried:
>\n
>\r
>\x0a
>\cJ
>...nothing worked so far...
Well, you would like to write it out to a file in binmode, but
that doesen't mean you have to set binmode on a read file to manipulate
raw data internally.
-sln
-----------------------------------
use strict;
use warnings;
while (<DATA>)
{
s/\x{0d}\x{0a}|\x{0d}/\x{0a}/;
# to fixup stuff, say its mangled or something
# (the cart or the horse, pick your poison)
# s/\x{0a}\x{0d}/\x{0d}\x{0a}/;
print;
print ord($_), ' ' for ( split // );
print "\n\n";
# open a file for output (above 'while'), set to binmode,
# then write it out here with a ord/split.
}
__DATA__
line 1
line 2
line 3
line 4
---------------------
output:
line 1
108 105 110 101 32 49 10
line 2
108 105 110 101 32 50 10
line 3
108 105 110 101 32 51 10
line 4
108 105 110 101 32 52 10
------------------------------
Date: Fri, 17 Jul 2009 22:24:19 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <j837j6-9mn.ln1@news.rtij.nl>
On Mon, 13 Jul 2009 13:36:32 -0700, sln wrote:
>>It merely provides the typical Unix utilities in the Windows
>>environment.
>
> This means a compiler right?
No it means binaries (and in typical unix tradition, also a compiler,
it's one of the binaries).
M4
------------------------------
Date: Fri, 17 Jul 2009 16:13:55 -0500
From: l v <veatchla@yahoo.com>
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <gZGdnXBrVd8GdP3XnZ2dnUVZ_hidnZ2d@supernews.com>
sln@netherlands.com wrote:
> On Wed, 08 Jul 2009 01:27:10 -0700, "John W. Krahn" <someone@example.com> wrote:
>
>> Cibalo wrote:
>>> I would like to list all the 5-digit zip codes in my database, of
>>> which a line may contain more than one zip codes. Then, I create a
>>> test database, testdb, for testing as follows.
>>>
>>> # echo -e 'zip1 10036; zip2 48226; zip3 94128\nzip4 V8Y 1L1; zip5
>>> 400069\nzip6 \nzip7 12345' > testdb
>>> # cat testdb
>>> zip1 10036; zip2 48226; zip3 94128
>>> zip4 V8Y 1L1; zip5 400069
>>> zip6
>>> zip7 12345
>>> # perl -wnl -e '/\b[0-9]{5}\b/g and print "$.: $&";' testdb
>>> 1: 10036
>>> 4: 12345
>>> # grep -now -e '[0-9]\{5\}' testdb
>>> 1:10036
>>> 48226
>>> 94128
>>> 4:12345
>>> #
>>>
>>> Even with the global modifier, the above perl script lists only the
>>> first pattern match with multiple matches in the same line. But I can
>>> make it worked with grep as listed above.
>> The problem is that even with the global option the pattern is evaluated
>> in scalar context and so will only match once. You need to either match
>> in list context:
>>
>> $ echo "zip1 10036; zip2 48226; zip3 94128
>> zip4 V8Y 1L1; zip5 400069
>> zip6
>> zip7 12345
>> " | perl -lne'print "$.: $_" for /\b[0-9]{5}\b/g'
>> 1: 10036
>> 1: 48226
>> 1: 94128
>> 4: 12345
>>
>>
>> Or match all patterns in scalar context:
>>
>> $ echo "zip1 10036; zip2 48226; zip3 94128
>> zip4 V8Y 1L1; zip5 400069
>> zip6
>> zip7 12345
>> " | perl -lne'print "$.: $1" while /\b([0-9]{5})\b/g'
> ^^^^^^^^^^^^^^^^^^^^^^^
>> 1: 10036
>> 1: 48226
>> 1: 94128
>> 4: 12345
>>
>>
>>
>> John
>
> I always enjoy (and marvel at) seeing Unix 1 liner shell
> compositions here. Seems so at ease and natural. I just got Windyo'z.
> When I cut and paste these 1 liners (even though my shell does 'echo')
> each line is treated as a new command, even when I batch it.
> Unfortunately, the {'"} syntax is also different under Windows (and I
> have XP, the great).
>
You just need to adjust the one-liner a bit to make the unix one-liners
work on windows.
unix:
$ echo "zip1 10036; zip2 48226; zip3 94128" | perl -lne'print "$.: $1"
while /\b([0-9]{5})\b/g'
1: 10036
1: 48226
1: 94128
windows:
d:\>echo "zip1 10036; zip2 48226; zip3 94128" | perl -nle "print qq($.:
$1) while /\b([0-9]{5})\b/g"
1: 10036
1: 48226
1: 94128
I tend to use the qq() syntax when I need a double-quote in the
one-liner for windows.
--
Len
------------------------------
Date: Fri, 17 Jul 2009 16:21:46 -0500
From: l v <veatchla@yahoo.com>
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <QridnTF83qzudv3XnZ2dnUVZ_jOdnZ2d@supernews.com>
sln@netherlands.com wrote:
> Why does Unix do /dir/dir/dir/not_dir (whatever that means), and why forward slashes?
> Is /dir/dir/dir/not_\dir available?
>
Windows uses back slashes while unix uses forward slashes. A mainframe
uses periods (.).
Therefore unix's /dir/dir/dir/not_dir
is windows c:\dir\dir\dir\file
In your Perl code you should use forward slashed even when on windows.
For example:
open FH, '<', 'c:/dir/dir/dir/file') or die ........
Although not_dir does not mean a file for unix. For example, not_dir can
be a link to another file or directory. But I won't go into that here.
--
Len
------------------------------
Date: Fri, 17 Jul 2009 14:26:40 -0700
From: sln@netherlands.com
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <7lq165lg9onc9qs5emhk2j2lkkhnr34gnk@4ax.com>
On Fri, 17 Jul 2009 22:24:19 +0200, Martijn Lievaart <m@rtij.nl.invlalid> wrote:
>On Mon, 13 Jul 2009 13:36:32 -0700, sln wrote:
>
>>>It merely provides the typical Unix utilities in the Windows
>>>environment.
>>
>> This means a compiler right?
>
>No it means binaries (and in typical unix tradition, also a compiler,
>it's one of the binaries).
>
>M4
Since I have to learn everything on my own (because class is too slow),
they (an employer) would have to pay me (unix deliverables) while I am
forced to learn. To shift to different OSs' all the time takes a lot
out of me. I can deliver unix code with a compiler that keeps me in line.
I'm so lazy I make the compiler do my work. Make it tell me my errors,
take me to my errors, take me to the docs, make it fix it for me.
IDE's are my slave's, they get out of line ... I pop em in the mout'
-sln
------------------------------
Date: Fri, 17 Jul 2009 14:40:26 -0700
From: sln@netherlands.com
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <gkr165d6j80c2s1v9golaskm02vevfrb51@4ax.com>
On Fri, 17 Jul 2009 16:21:46 -0500, l v <veatchla@yahoo.com> wrote:
>sln@netherlands.com wrote:
>
>> Why does Unix do /dir/dir/dir/not_dir (whatever that means), and why forward slashes?
>> Is /dir/dir/dir/not_\dir available?
>>
>
>Windows uses back slashes while unix uses forward slashes. A mainframe
>uses periods (.).
>
>Therefore unix's /dir/dir/dir/not_dir
> is windows c:\dir\dir\dir\file
>
>In your Perl code you should use forward slashed even when on windows.
>For example:
>
>open FH, '<', 'c:/dir/dir/dir/file') or die ........
>
>
>Although not_dir does not mean a file for unix. For example, not_dir can
>be a link to another file or directory. But I won't go into that here.
Hey thanks! I already had an idea 'not_dir can be a link to another file or directory',
but I didn't go down that path when I scanned that line somewhere.
The ///// slashes are a Perl comfort thing, unfortunately, intrinsic separators asigned
to my $sep are platform useless given the former thanks. But, OS normalization is, like
you said, maybe not guaranteed. I just hate OS'.
-sln
------------------------------
Date: Fri, 17 Jul 2009 14:46:52 -0700
From: sln@netherlands.com
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <b9s16592nr5377m7dmv0qo58mfhb9sjkgr@4ax.com>
On Fri, 17 Jul 2009 16:13:55 -0500, l v <veatchla@yahoo.com> wrote:
>sln@netherlands.com wrote:
>> On Wed, 08 Jul 2009 01:27:10 -0700, "John W. Krahn" <someone@example.com> wrote:
>>
>>> Cibalo wrote:
>>>> I would like to list all the 5-digit zip codes in my database, of
>>>> which a line may contain more than one zip codes. Then, I create a
>>>> test database, testdb, for testing as follows.
>>>>
>>>> # echo -e 'zip1 10036; zip2 48226; zip3 94128\nzip4 V8Y 1L1; zip5
>>>> 400069\nzip6 \nzip7 12345' > testdb
>>>> # cat testdb
>>>> zip1 10036; zip2 48226; zip3 94128
>>>> zip4 V8Y 1L1; zip5 400069
>>>> zip6
>>>> zip7 12345
>>>> # perl -wnl -e '/\b[0-9]{5}\b/g and print "$.: $&";' testdb
>>>> 1: 10036
>>>> 4: 12345
>>>> # grep -now -e '[0-9]\{5\}' testdb
>>>> 1:10036
>>>> 48226
>>>> 94128
>>>> 4:12345
>>>> #
>>>>
>>>> Even with the global modifier, the above perl script lists only the
>>>> first pattern match with multiple matches in the same line. But I can
>>>> make it worked with grep as listed above.
>>> The problem is that even with the global option the pattern is evaluated
>>> in scalar context and so will only match once. You need to either match
>>> in list context:
>>>
>>> $ echo "zip1 10036; zip2 48226; zip3 94128
>>> zip4 V8Y 1L1; zip5 400069
>>> zip6
>>> zip7 12345
>>> " | perl -lne'print "$.: $_" for /\b[0-9]{5}\b/g'
>>> 1: 10036
>>> 1: 48226
>>> 1: 94128
>>> 4: 12345
>>>
>>>
>>> Or match all patterns in scalar context:
>>>
>>> $ echo "zip1 10036; zip2 48226; zip3 94128
>>> zip4 V8Y 1L1; zip5 400069
>>> zip6
>>> zip7 12345
>>> " | perl -lne'print "$.: $1" while /\b([0-9]{5})\b/g'
>> ^^^^^^^^^^^^^^^^^^^^^^^
>>> 1: 10036
>>> 1: 48226
>>> 1: 94128
>>> 4: 12345
>>>
>>>
>>>
>>> John
>>
>> I always enjoy (and marvel at) seeing Unix 1 liner shell
>> compositions here. Seems so at ease and natural. I just got Windyo'z.
>> When I cut and paste these 1 liners (even though my shell does 'echo')
>> each line is treated as a new command, even when I batch it.
>> Unfortunately, the {'"} syntax is also different under Windows (and I
>> have XP, the great).
>>
>
>You just need to adjust the one-liner a bit to make the unix one-liners
> work on windows.
>
>unix:
>$ echo "zip1 10036; zip2 48226; zip3 94128" | perl -lne'print "$.: $1"
>while /\b([0-9]{5})\b/g'
>1: 10036
>1: 48226
>1: 94128
>
>
>windows:
>d:\>echo "zip1 10036; zip2 48226; zip3 94128" | perl -nle "print qq($.:
>$1) while /\b([0-9]{5})\b/g"
>1: 10036
>1: 48226
>1: 94128
>
>I tend to use the qq() syntax when I need a double-quote in the
>one-liner for windows.
Thanks Len, I really appretiate that!
-sln
------------------------------
Date: Fri, 17 Jul 2009 15:03:43 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <mhs1651d2tgrdsuutjkvrbbdhpb88987ou@4ax.com>
l v <veatchla@yahoo.com> wrote:
>sln@netherlands.com wrote:
>
>> Why does Unix do /dir/dir/dir/not_dir (whatever that means), and why forward slashes?
Wrong question. Question should have been "Why does Windows not use
forward slashes?" After all Unix predates Windows by a decade and a
half.
>> Is /dir/dir/dir/not_\dir available?
Sure, why not?
I'm not absoluely certain but I thing this should be the same name as
just not_dir. The \d is not a special character (unlike \t or \r),
therefore the escape should be ignored.
jue
------------------------------
Date: Fri, 17 Jul 2009 15:17:37 -0700
From: sln@netherlands.com
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <4lt165dmupca2oe0cekoro3m7dfmjtm59u@4ax.com>
On Fri, 17 Jul 2009 15:03:43 -0700, Jürgen Exner <jurgenex@hotmail.com> wrote:
>l v <veatchla@yahoo.com> wrote:
>>sln@netherlands.com wrote:
>>
>>> Why does Unix do /dir/dir/dir/not_dir (whatever that means), and why forward slashes?
>
>Wrong question. Question should have been "Why does Windows not use
>forward slashes?" After all Unix predates Windows by a decade and a
>half.
I still have Unix programming Manual's 1 & 2 by Bell Labratories sitting
in my book case (dark blue-green). I can probably still use them, huh?
What year did you say that was?
Seems since (mostly) the begining, unix had to be compiled with the features
you wanted. Was it all source available or dlls as well?
Its a good thing you don't have to compile Windowz, anything goes wrong, all
you have to do is blame Microsoft, the winner (or weenier)!
Slash unix AND windoz.
-sln
------------------------------
Date: Sat, 18 Jul 2009 00:57:35 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <slrnh620f8.fic.hjp-usenet2@hrunkner.hjp.at>
On 2009-07-17 22:03, Jürgen Exner <jurgenex@hotmail.com> wrote:
> l v <veatchla@yahoo.com> wrote:
>>sln@netherlands.com wrote:
>>
>>> Why does Unix do /dir/dir/dir/not_dir (whatever that means), and why forward slashes?
>
> Wrong question. Question should have been "Why does Windows not use
> forward slashes?" After all Unix predates Windows by a decade and a
> half.
Easy to answer: MS-DOS 1.0 had inherited the forward slash as an option
marker from CP/M. MS-DOS 2.0 added a lot of Unix features (like a
filedescriptor-based I/O API and a hierarchical file system) but they
didn't want an incompatible change to the CLI. So the slash remained the
option marker and the (previously unused) backslash became the directory
separator. But there was a "switchar" (sic!) system call, which could be
used to set and query the current switch (=option) character. All
Microsoft and many third party utilities used this, so you could set the
option character to '-' and then use commands like:
dir -w c:/foo
Regardless of this setting, the system calls always accepted both the
slash and the backslash as a directory separator (and that's still the
case in Windows).
hp
------------------------------
Date: Fri, 17 Jul 2009 23:50:02 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <qpb7j6-8fe1.ln1@osiris.mauzo.dyndns.org>
Quoth Jürgen Exner <jurgenex@hotmail.com>:
> l v <veatchla@yahoo.com> wrote:
> >sln@netherlands.com wrote:
> >
> >> Why does Unix do /dir/dir/dir/not_dir (whatever that means), and why
> forward slashes?
>
> Wrong question. Question should have been "Why does Windows not use
> forward slashes?" After all Unix predates Windows by a decade and a
> half.
I don't know if you're actually interested, but the answer is something
like 'because DOS inherited / to indicate an option from CP/M, which was
the previous OS for 8086s, so it couldn't also be used as the directory
separator'. CP/M in turn inherited the syntax from various DEC OSen,
which had existed since 1970.
Not every Windows incompatibility with Unix is stupid: they are simply
different OSen with rather different histories and influences.
Ben
------------------------------
Date: Fri, 17 Jul 2009 19:45:03 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <87fxcu98n4.fsf@quad.sysarch.com>
>>>>> "PJH" == Peter J Holzer <hjp-usenet2@hjp.at> writes:
PJH> Easy to answer: MS-DOS 1.0 had inherited the forward slash as an
PJH> option marker from CP/M. MS-DOS 2.0 added a lot of Unix features
PJH> (like a filedescriptor-based I/O API and a hierarchical file
you have to go back even farther than that. cp/m was derived from dec's
RT-11 which has / for option markers. and most dec OS's did that too.
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: Fri, 17 Jul 2009 17:03:55 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <t64265pi9derjpsnd2pfvi132qm5ro7krm@4ax.com>
Ben Morrow <ben@morrow.me.uk> wrote:
>Quoth Jürgen Exner <jurgenex@hotmail.com>:
>> l v <veatchla@yahoo.com> wrote:
>> >sln@netherlands.com wrote:
>> >
>> >> Why does Unix do /dir/dir/dir/not_dir (whatever that means), and why
>> forward slashes?
>>
>> Wrong question. Question should have been "Why does Windows not use
>> forward slashes?" After all Unix predates Windows by a decade and a
>> half.
[...]
>Not every Windows incompatibility with Unix is stupid: they are simply
>different OSen with rather different histories and influences.
Fair enough. And certainly true.
But how dare you adding reason to an argument about the best editor,
errrm, best OS, errrrm , longest ..... :-)
jue
------------------------------
Date: Fri, 17 Jul 2009 17:14:04 -0700
From: sln@netherlands.com
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <qs42651d1bmjaafeo87cg6gv074e9a2d10@4ax.com>
On Fri, 17 Jul 2009 19:45:03 -0400, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "PJH" == Peter J Holzer <hjp-usenet2@hjp.at> writes:
>
> PJH> Easy to answer: MS-DOS 1.0 had inherited the forward slash as an
> PJH> option marker from CP/M. MS-DOS 2.0 added a lot of Unix features
> PJH> (like a filedescriptor-based I/O API and a hierarchical file
>
>you have to go back even farther than that. cp/m was derived from dec's
>RT-11 which has / for option markers. and most dec OS's did that too.
>
>uri
Then, the guy who did Dec, did Windowz.
-sln
------------------------------
Date: Fri, 17 Jul 2009 19:52:32 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Perl Fails To List All The Multiple Matches In The Same Line?
Message-Id: <slrnh626sk.rop.tadmc@tadmc30.sbcglobal.net>
l v <veatchla@yahoo.com> wrote:
> sln@netherlands.com wrote:
>
>> Why does Unix do /dir/dir/dir/not_dir (whatever that means), and why forward slashes?
>> Is /dir/dir/dir/not_\dir available?
>>
>
> Windows uses back slashes while unix uses forward slashes.
It is not Windows that uses backslashes for the dir separator.
It is the Windows _command line_ that uses backslashes for
the dir separator. (try using forward slashes in any M$ GUI,
should work fine)
I believe that slash has been supported since DOS 2.0 or some such...
> Therefore unix's /dir/dir/dir/not_dir
> is windows c:\dir\dir\dir\file
It is also window's c:/dir/dir/dir/not_dir (unless you are using
M$'s command line).
> In your Perl code you should use forward slashed even when on windows.
> For example:
>
> open FH, '<', 'c:/dir/dir/dir/file') or die ........
Because there is no shell involved, there is none of a shell's
interpretation of what all the funny characters mean.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 17 Jul 2009 12:46:17 -0700
From: sln@netherlands.com
Subject: Re: Simple Regex Doubt
Message-Id: <55k1659qk3jgg4709gamckh5al0hnjpv13@4ax.com>
On Thu, 16 Jul 2009 09:17:59 -0700 (PDT), Donato Azevedo <donatoaz@gmail.com> wrote:
>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?
Wow, looks complicated, but isin't. Yes, as DeRykus says,
you need a quantifier '?' (0 or 1) around a non capture grouping
of --> Critic:(?<criticality>.*) in the first regex.
This will at least assign $+{criticality} a '' if there is no 'Critic:'
data (.*)and will assign (just like the $n vars I think) undef if there is no 'Critic:'
I haven't checked 5.10 much but, there may not even exist $+{criticality} if '?'
for the group is 0. Regex satisfied, but who knows how %+ hash is reset.
Probably exists, but set to undef, like its unamed capture counterpart.
Btw, whats this bizz: /(.*?)\r\n/s ??
-sln
------------------------------
Date: Fri, 17 Jul 2009 12:52:22 -0700
From: sln@netherlands.com
Subject: Re: Simple Regex Doubt
Message-Id: <8fl165ts7aehhd43pi737hioj56agttniv@4ax.com>
On Fri, 17 Jul 2009 12:46:17 -0700, sln@netherlands.com wrote:
>On Thu, 16 Jul 2009 09:17:59 -0700 (PDT), Donato Azevedo <donatoaz@gmail.com> wrote:
<snip>
>Wow, looks complicated, but isin't. Yes, as DeRykus says,
>you need a quantifier '?' (0 or 1) around a non capture grouping
>of --> Critic:(?<criticality>.*) in the first regex.
>
>This will at least assign $+{criticality} a '' if there is no 'Critic:'
>data (.*)and will assign (just like the $n vars I think) undef if there is no 'Critic:'
>
>I haven't checked 5.10 much but, there may not even exist $+{criticality} if '?'
>for the group is 0. Regex satisfied, but who knows how %+ hash is reset.
>Probably exists, but set to undef, like its unamed capture counterpart.
>
>Btw, whats this bizz: /(.*?)\r\n/s ??
>
>-sln
>
^^
Oh, I'm sorry, s/comments/criticality/g it the above reply-post.
-sln
------------------------------
Date: Fri, 17 Jul 2009 14:32:14 -0700
From: sln@netherlands.com
Subject: Re: Simple Regex Doubt
Message-Id: <3br165ls75khmc01gam1oj9isvfmp8q7qi@4ax.com>
On Fri, 17 Jul 2009 12:52:22 -0700, sln@netherlands.com wrote:
>On Fri, 17 Jul 2009 12:46:17 -0700, sln@netherlands.com wrote:
>
>>On Thu, 16 Jul 2009 09:17:59 -0700 (PDT), Donato Azevedo <donatoaz@gmail.com> wrote:
>
><snip>
>
>>Wow, looks complicated, but isin't. Yes, as DeRykus says,
>>you need a quantifier '?' (0 or 1) around a non capture grouping
>>of --> Critic:(?<criticality>.*) in the first regex.
>>
>>This will at least assign $+{criticality} a '' if there is no 'Critic:'
>>data (.*)and will assign (just like the $n vars I think) undef if there is no 'Critic:'
>>
>>I haven't checked 5.10 much but, there may not even exist $+{criticality} if '?'
>>for the group is 0. Regex satisfied, but who knows how %+ hash is reset.
>>Probably exists, but set to undef, like its unamed capture counterpart.
>>
>>Btw, whats this bizz: /(.*?)\r\n/s ??
>>
>>-sln
>>
>
>^^
>Oh, I'm sorry, s/comments/criticality/g it the above reply-post.
>
>-sln
Warning!! ignore that man behind the curtain..
The saga continues, s/criticality/comments/g
Dyslexia is a terrible thing to waste.
-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 2522
***************************************