[32970] in Perl-Users-Digest
Perl-Users Digest, Issue: 4246 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 6 21:09:18 2014
Date: Sun, 6 Jul 2014 18:09:05 -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 Sun, 6 Jul 2014 Volume: 11 Number: 4246
Today's topics:
Re: best way to build an absolute spec <nospam-abuse@ilyaz.org>
Re: Cost of qr// vs m// <nospam-abuse@ilyaz.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 6 Jul 2014 23:15:19 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: best way to build an absolute spec
Message-Id: <lpcla6$9oq$2@dont-email.me>
On 2014-06-01, Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
> oldyork90@yahoo.com writes:
>> I have a directory $my_dir. I test this with -d.
>> $my_dir is user defined.
>>
>> I want to build the file spec "$my_dir . $my_fn", but $my_dir may be
>> constructed as either /one/two or /one/two/.
>>
>> I could test for the trailing path separator and act accordingly, but is
>> there a better way, a "standard" or best practice way, of doing this?
>>
>> How do you pros build the absolute paths?
>>
>>
>> I find that in Windows "/one/two//my_file" will work, but I'd rather
>> not.
>
> POSIX/ UNIX(*) pathnames may separate two components with any number of
> /-characters (subject to pathname lenght limits).
… But it does not work on DOSISH, where //foo is different from /foo.
Hope this helps,
Ilya
------------------------------
Date: Sun, 6 Jul 2014 23:08:03 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Cost of qr// vs m//
Message-Id: <lpcksj$9oq$1@dont-email.me>
On 2014-03-28, Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
> This mystery is easily explained when looking the the decompiled/
> disassembled internal represention (I've omitted everything except the
> actual loop). 'live' becomes
I do not see how it explains anything…
> [rw@sable]/tmp#perl -MO=Concise,live b.pl
> main::live:
> - <1> null K/1 ->b
> a <|> and(other->7) K/1 ->b
> 9 <0> iter s ->a
> - <@> lineseq sK ->-
> 7 </> match(/"some.*3"/) v/RTIME ->8
> 8 <0> unstack s ->9
>
> In contrast to that, 'compiled' is
>
> - <1> null K/1 ->i
> h <|> and(other->b) K/1 ->i
> g <0> iter s ->h
> - <@> lineseq sK ->-
> e </> match() vK/RTIME ->f
> d <|> regcomp(other->e) sK/1 ->e
> b <1> regcreset sK/1 ->c
> c <0> padsv[$r:601,602] s ->d
> f <0> unstack s ->g
>
> For the qr'ed case, it actually calls into the top-level regexp compiler
> routine (pp_regcomp) on each iteration which gets the already compiled
> regexp out of the passed argument in case contained a (reference) to an
^^^^ it
> already compiled regexp instead of calling the 'real' regexp compiler.
> Judging from the (5.10.1) C-code, the compiled regexp is also copied to
> 'a temporary object' for each match.
With 5.8.8 (the last version for which I bear some responsibility),
the timing is
qr 2.28
q 2.19
inline 1.78
for (I do believe in Benchmark):
D:\ilya\math>time D:\Programs\win32_utils\perl\bin\perl.exe -wle "$r=qr/some/; /$r/ for 1e5..1e7"
0.00user 0.07system 0:02.28elapsed 3%CPU (0avgtext+0avgdata 252416maxresident)k
0inputs+0outputs (1021major+0minor)pagefaults 0swaps
D:\ilya\math>time D:\Programs\win32_utils\perl\bin\perl.exe -wle "$r= q/some/; /$r/ for 1e5..1e7"
0.01user 0.12system 0:02.19elapsed 6%CPU (0avgtext+0avgdata 252416maxresident)k
0inputs+0outputs (1021major+0minor)pagefaults 0swaps
D:\ilya\math>time D:\Programs\win32_utils\perl\bin\perl.exe -wle " /some/ for 1e5..1e7"
0.00user 0.09system 0:01.78elapsed 5%CPU (0avgtext+0avgdata 252416maxresident)k
0inputs+0outputs (1021major+0minor)pagefaults 0swaps
*This* is reasonable, and matches what I intended with qr//. The
observed with newer versions behaviour MUST be a bug.
Yours,
Ilya
------------------------------
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 4246
***************************************