[31590] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2849 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 4 14:09:45 2010

Date: Thu, 4 Mar 2010 11:09:26 -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           Thu, 4 Mar 2010     Volume: 11 Number: 2849

Today's topics:
    Re: Can you compile a perl executable? <hjp-usenet2@hjp.at>
    Re: Detecting Bourne (or csh) shell from Perl <nospam-abuse@ilyaz.org>
    Re: Detecting Bourne (or csh) shell from Perl <ams@sister.ludd.ltu.se>
    Re: Detecting Bourne (or csh) shell from Perl <ben@morrow.me.uk>
    Re: how to speed up a string-substitution loop? <adam.kellas@gmail.com>
    Re: how to speed up a string-substitution loop? <source@netcom.com>
    Re: how to speed up a string-substitution loop? <hjp-usenet2@hjp.at>
        perl -014pe <nickli2000@gmail.com>
    Re: perl -014pe sln@netherlands.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 4 Mar 2010 19:34:53 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Can you compile a perl executable?
Message-Id: <slrnhovvae.9pk.hjp-usenet2@hrunkner.hjp.at>

On 2010-03-03 09:00, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> Jürgen Exner wrote:
>> Steve <steve@staticg.com> wrote:
>>> If I made an application, and wanted to make it portable, is it
>>> possible to compile it into a single binary?
>> 
>> See "perldoc -q compile":
>> 	"How can I compile my Perl program into byte code or C?"
>> 
>> jue
>
> I note that this perldoc appears to be happy
> that B::Bytecode is the way to do this,

Not in the current version. That paragraph vanished sometime between
5.8.8 and 5.10.0

	hp



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

Date: Thu, 4 Mar 2010 07:07:17 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Detecting Bourne (or csh) shell from Perl
Message-Id: <slrnhoun15.dos.nospam-abuse@powdermilk.math.berkeley.edu>

On 2010-03-04, Ben Morrow <ben@morrow.me.uk> wrote:
>> C::Scan module uses this construct
>> 
>>   my $cmd = qq(echo '#include "$filename"' | $Cpp->{cppstdin} $Defines
>> $addincludes $Cpp->{cppflags} $Cpp->{cppminus} |);
>> 
>> Obviously, is supposes Bourne (or C) shell; so this breaks on ports
>> which use DOSISH shells.
>> 
>>   a) is $^O =~ /win32/i a fool-proof way to detect such ports?
>
> DOS itself ($^O eq "dos") is dead. I presume you know better than I what
> shell is available on OS/2. NetWare, however, also sets $^O = "Win32",
> but looking at ExtUtils::MM_NW5 suggests that it has (or can have?
> $ENV{EMXSHELL} seems to be important) a shish shell.
>
> As for other shells, MacOS Classic and RISC OS are dead, and the Symbian
> port is no longer maintained, so I believe that leaves VMS.

Thanks for this info.  However, I do not see what is the relationship
of this list of dead platforms (whatever this means) to my question...

Reiterating again: is there a way to distinguish (e.g., a Windows)
port which uses "native" shell vs Korn-syntax shell.

> that's an OS matter, and outside the remit of the perl docs.

This, of course, has nothing to do with OS.  Just what the creator of
a particular port decided to use as a shell.  (And, repeating myself:
IMO, if people would listen to me a decade ago, one would not have
this mess at all - all shells would use Bourne syntax...) 

And having docs mentioning how to write portable code would be nice,
would not it?

Thanks,
Ilya


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

Date: Thu, 4 Mar 2010 09:58:48 +0000 (UTC)
From: Martin Str|mberg <ams@sister.ludd.ltu.se>
Subject: Re: Detecting Bourne (or csh) shell from Perl
Message-Id: <hmo08o$det$1@speranza.aioe.org>

Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
>   my $cmd = qq(echo '#include "$filename"' | $Cpp->{cppstdin} $Defines $addincludes $Cpp->{cppflags} $Cpp->{cppminus} |);

> Obviously, is supposes Bourne (or C) shell; so this breaks on ports
> which use DOSISH shells.

>   a) is $^O =~ /win32/i a fool-proof way to detect such ports?

If you still support dos, this isn't fool-proof.


-- 
MartinS


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

Date: Thu, 4 Mar 2010 13:47:53 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Detecting Bourne (or csh) shell from Perl
Message-Id: <99q467-g29.ln1@osiris.mauzo.dyndns.org>


Quoth Ilya Zakharevich <nospam-abuse@ilyaz.org>:
> On 2010-03-04, Ben Morrow <ben@morrow.me.uk> wrote:
> >> C::Scan module uses this construct
> >> 
> >>   my $cmd = qq(echo '#include "$filename"' | $Cpp->{cppstdin} $Defines
> >> $addincludes $Cpp->{cppflags} $Cpp->{cppminus} |);
> >> 
> >> Obviously, is supposes Bourne (or C) shell; so this breaks on ports
> >> which use DOSISH shells.
> >> 
> >>   a) is $^O =~ /win32/i a fool-proof way to detect such ports?
> >
> > DOS itself ($^O eq "dos") is dead. I presume you know better than I what
> > shell is available on OS/2. NetWare, however, also sets $^O = "Win32",
> > but looking at ExtUtils::MM_NW5 suggests that it has (or can have?
> > $ENV{EMXSHELL} seems to be important) a shish shell.
> >
> > As for other shells, MacOS Classic and RISC OS are dead, and the Symbian
> > port is no longer maintained, so I believe that leaves VMS.
> 
> Thanks for this info.  However, I do not see what is the relationship
> of this list of dead platforms (whatever this means) to my question...
> 
> Reiterating again: is there a way to distinguish (e.g., a Windows)
> port which uses "native" shell vs Korn-syntax shell.

Sorry, I thought your question was 'which platforms use DOSish shells'
not 'are there any Win32 ports which don't'. There is presently only one
Win32 port, the one in the core, and that uses $ENV{PERL5SHELL} to
decide which shell to use, falling back to command.com/cmd.exe if it's
empty.

> > that's an OS matter, and outside the remit of the perl docs.
> 
> This, of course, has nothing to do with OS.  Just what the creator of
> a particular port decided to use as a shell.

Meh. IMHO a perl which doesn't use the same shell as used by system(3)
in the standard C library is somewhat broken. 

> (And, repeating myself:
> IMO, if people would listen to me a decade ago, one would not have
> this mess at all - all shells would use Bourne syntax...) 

So you would have Win32 perl ship with a sh.exe, and use that for system
and exec? I suspect that would have made Win32 people coming to perl
rather unhappy.

> And having docs mentioning how to write portable code would be nice,
> would not it?

The docs repeatedly suggest avoiding the shell wherever possible, and
doing things in Perl instead.

Ben



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

Date: Wed, 3 Mar 2010 19:47:19 -0800 (PST)
From: Adam Kellas <adam.kellas@gmail.com>
Subject: Re: how to speed up a string-substitution loop?
Message-Id: <0eff38b3-e638-4f9f-bfcb-87b67834c50d@t20g2000yqe.googlegroups.com>

On Mar 3, 11:42=A0am, s...@netherlands.com wrote:
> Just a comment that no where is it written that you can reconstruct
> variables from the output of =A0variable substitution.

Yes, this is analogous to decompilation; it's not possible to reliably
put it back the way it was, but it may be possible to generate
something which is both correct and fairly readable. There will always
be macroization opportunities missed and bad choices. For a simple
instance:

RM =3D rm
RM_FLAGS =3D -f
MV =3D mv
MV_FLAGS =3D -f

Given this, varify("rm -f foo") might turn into "$(RM) $(MV_FLAGS)
foo" and I don't think there's any way to prevent it without getting
into some serious AI stuff. But in this application that's ok as long
as the result works. The user can be expected to do a little manual
cleanup in an editor if need be.

Thanks for the sample code.

AK


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

Date: Thu, 04 Mar 2010 07:11:46 -0800
From: David Harmon <source@netcom.com>
Subject: Re: how to speed up a string-substitution loop?
Message-Id: <4JmdnZ_276xwUBLWnZ2dnUVZ_oWdnZ2d@earthlink.com>

On Wed, 3 Mar 2010 06:29:38 -0800 (PST) in comp.lang.perl.misc, Adam
Kellas <adam.kellas@gmail.com> wrote,
>but wouldn't we all? Though how you can argue that % is ugly while /
>is not while explicitly rejecting the notion that it's an aesthetic
>disagreement 
 
 % is a poor choice because it is dense, busy, and wide.  It puts more
black on the display, so that is about the same density of many other
characters.  It has more squiggles than / making it indeed harder to
read.  / is lighter that average, and narrow so it leaves minute white
space between it and adjacent characters, for better visual separation.

/ loses these advantages when adjacent characters resemble it, as in the
infamous leaning toothpicks syndrome  s/\/\//\\\\/;  etc. but there are
other solutions for that.
 
And, of course, % is contrary to convention.


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

Date: Thu, 4 Mar 2010 19:31:32 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: how to speed up a string-substitution loop?
Message-Id: <slrnhovv45.9pk.hjp-usenet2@hrunkner.hjp.at>

On 2010-03-03 16:04, Adam Kellas <adam.kellas@gmail.com> wrote:
> On Mar 3, 10:21 am, "Uri Guttman" <u...@StemSystems.com> wrote:
>> >>>>> "AK" == Adam Kellas <adam.kel...@gmail.com> writes:
>>   AK> Really, we have no disagreement here. It's just that when one is
>>   AK> trying desperately to speed something up it's reasonable to try
>>   AK> everything you know of. What I posted was not a published, supported
>>   AK> piece of code, it was the result of a tuning exercise.
>>
>> desperation is not a reason to try everything under the sun for
>> speedups. just applying the benchmark module is a saner way to find out
>> what is actually faster and by how much.
>
> OK, if you insist, we do have a disagreement. I will simply note that
> the benchmark module is of little use when the code you're fixing is
> so slow as to never finish.

If the code you're fixing is so slow as to never finish, blindly
replacing named variables with $_ is even less use. At best that brings
you a small constant speedup. 95% of infinity is still infinity.

If your code is so slow that you can't even measure it you first should
make sure that it isn't stuck in an infinite loop. Then prepare a test
case where it does finish in a practicable time (maybe run with a
reduced data set, or simply exit after a fixed number of iterations),
and look where it spends the time (Devel::NYTProf is a good profiler but
be warned that it can add a lot of overhead (I've had code which ran 5
to 10 times slower with profiling than without[1])). Then try to make
that code faster - and that will almost always mean a change to the
algorithm, not a micro-optimization.

	hp

[1] All the profilers for perl I know hook into the debugger, so they
    execute extra code for each line/block/sub that is executed. Using
    a SIGPROF handler (like the traditional Unix profiler does) should 
    have much less overhead - does anyone know a perl profiler which
    does this?



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

Date: Thu, 4 Mar 2010 10:00:31 -0800 (PST)
From: Ninja Li <nickli2000@gmail.com>
Subject: perl -014pe
Message-Id: <9919d605-26f7-4aac-9e01-8d7cd33362f0@i25g2000yqm.googlegroups.com>

Hi,

  I saw the following code about splitting a file into several pieces:

   perl -014pe 'open(STDOUT,">fred.$.")' fred

  I couldn't find what -014 means. Please advise.

  Thanks in advance.

  Nick


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

Date: Thu, 04 Mar 2010 10:28:49 -0800
From: sln@netherlands.com
Subject: Re: perl -014pe
Message-Id: <isuvo51lf5krhbg39jtja74df53phjkt2t@4ax.com>

On Thu, 4 Mar 2010 10:00:31 -0800 (PST), Ninja Li <nickli2000@gmail.com> wrote:

>Hi,
>
>  I saw the following code about splitting a file into several pieces:
>
>   perl -014pe 'open(STDOUT,">fred.$.")' fred
>
>  I couldn't find what -014 means. Please advise.
>
>  Thanks in advance.
>
>  Nick

perl -h

Usage: .....
  -0[octal]  specify record separator (\0, if no argument)



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

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


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