[26463] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8632 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 5 03:05:26 2005

Date: Sat, 5 Nov 2005 00:05:04 -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           Sat, 5 Nov 2005     Volume: 10 Number: 8632

Today's topics:
    Re: FAQ 3.21 How can I compile my Perl program into byt <samwyse@gmail.com>
    Re: Permutations <bertilow@gmail.com>
    Re: Why my code doesn't look Perl-ish? <someone@example.com>
    Re: Why my code doesn't look Perl-ish? robic0@yahoo.com
    Re: Why my code doesn't look Perl-ish? robic0@yahoo.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 05 Nov 2005 04:58:23 GMT
From: Samwyse <samwyse@gmail.com>
Subject: Re: FAQ 3.21 How can I compile my Perl program into byte code or C?
Message-Id: <PZWaf.12351$dO2.4102@newssvr29.news.prodigy.net>

PerlFAQ Server wrote:
> 3.21: How can I compile my Perl program into byte code or C?
> 
>     (contributed by brian d foy)
> 
>     In general, you can't do this. There are some things that may work for
>     your situation though. People usually ask this question because they
>     want to distribute their works without giving away the source code, and
>     most solutions trade disk space for convenience. You probably won't see
>     much of a speed increase either, since most solutions simply bundle a
>     Perl interpreter in the final product (but see "How can I make my Perl
>     program run faster?").

Having just stumbled across a commercial application that does this, I 
will point out that Crypt::License will perform some serious 
obfuscation.  Of course, it won't stop a determined attacker with a 
valid license file, but most customers are pretty honest about such 
things.  Just mention the DCMA in your README file.

(P.S. The application is ServerGraph, available from 
www.servergraph.com.  It seems to be written entirely in Perl, and 
includes bundled copies of Apache and MySQL.  I've only used it for 
about fifteen minutes, so I can't comment on it, but my Fortune 500 
client bought it.)


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

Date: Sat, 05 Nov 2005 16:49:14 +0900
From: Bertilo Wennergren <bertilow@gmail.com>
Subject: Re: Permutations
Message-Id: <dkho2o$1li$1@domitilla.aioe.org>

Xho wrote:

> Bertilo Wennergren <bertilow@gmail.com> wrote:
>> [...]
>> The print result should be this exciting bunch of numbers:
>>
>>   1 4 6
>>   1 4 7
>>   1 5 6
>>   1 5 7
 
>> Any ideas on how to do that in a better way? The major issue is
>> speed since the number of permutations rise quickly when there
>> are lots of groups with lots of numbers.
 
> That being the case, I would think that memory usage would be much
> more of an issue than speed.  Your code is building the entire set in
> memory.

OK. I'll have to watch out for that.
 
> A couple years ago I posted a module here that does what you want as an
> iterator, so it doesn't hog memory.  (There may be something on CPAN that
> does this, too, but it is easier for me to google my own code).
>
>http://groups.google.com/group/comp.lang.perl.misc/browse_frm/thread/
>b83886616f90cc8c

Perfect. That thread deals with the exact same problem that I have.

I tried out most of the solutions there, including your nice one, and also a
crazy new idea of my own. It turned out that my original code wasn't bad at
all, which really surprised me. However, I finally tried the simple and
elegant solution offered by "bd", and that turned out to be the fastest one
by far:

http://groups.google.com/group/comp.lang.perl.misc/browse_frm/thread/
b83886616f90cc8c

Thanks for all the input!

-- 
Bertilo Wennergren <http://bertilow.com>


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

Date: Sat, 05 Nov 2005 03:57:03 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Why my code doesn't look Perl-ish?
Message-Id: <j4Waf.79460$S4.68293@edtnps84>

V S Rawat wrote:
> I have developed a program that reads one string having several
> codes in octal, decimal and/or hex; and/or has the characters.
> 
> say, input: "ab\o081xy\d66z\\x\x81\aqwer";
                 ^^^^^
081 is not an octal number.  Octal numbers can only contain the digits 0, 1,
2, 3, 4, 5, 6 and 7.


> it interprets above as "ab (\o081) xy (\d66) z (\\) x (\x81)
> (\a) qwer";
> 
> then, it converts the o, d, h codes to chars, and returns the
> entire string.
> 
> \o, \d and \x can be followed by any no. of qualifying
> digits/chars for that coding. \ bypasses the next char, and the
> next char could be \ itself.

This may do what you want:

s{ \\ (?: (\\) | ([odx]) (\d+) ) }
 { $1 ? $1 : chr( $2 eq 'd' ? $3 : oct( $2 eq 'o' ? "0$3" : $2 eq 'x' ? "0x$3"
: '' ) ) }gex;



John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 04 Nov 2005 23:09:06 -0800
From: robic0@yahoo.com
Subject: Re: Why my code doesn't look Perl-ish?
Message-Id: <f2lom19t3v7mc2vk1hkjqakhvi5co8iepq@4ax.com>

On 4 Nov 2005 19:57:36 +0100, "V S Rawat" <VSRawat@Invalid.none>
wrote:

>
>I have developed a program that reads one string having several
>codes in octal, decimal and/or hex; and/or has the characters.
>
>say, input: "ab\o081xy\d66z\\x\x81\aqwer";
>
>it interprets above as "ab (\o081) xy (\d66) z (\\) x (\x81)
>(\a) qwer";
>
>then, it converts the o, d, h codes to chars, and returns the
>entire string.
>
>\o, \d and \x can be followed by any no. of qualifying
>digits/chars for that coding. \ bypasses the next char, and the
>next char could be \ itself.
>
>it is working. The main module is the following:
>========START
>sub get_chrs {
>    $TmpElementIn = shift(@_); # input string passed on to sub
>    $TmpElementOut = ""; # string to go back to the caller
>    $TmpIndexMax = length($TmpElementIn);
>    $TmpIndexCurr = 0;
>    $TmpIndexNext = 0;
>    while ( $TmpIndexCurr < $TmpIndexMax ) {
>        $TmpIndexNext = index( $TmpElementIn, "\\",
>$TmpIndexCurr);
>        if ( $TmpIndexNext < $TmpIndexCurr ) { # not found
>            $TmpElementOut =
>$TmpElementOut.substr($TmpElementIn, $TmpIndexCurr);
               ^^^^^^^
Funny, this is a cat, but almost looks like a C++ like
member function for the "scalar" class.
Maybe $TmpElementOut is just a CString.

In my opinion, Perl is NOT good for stream parsing of
strings because the only powerful tool in Perl for that
is Regular Expressions (filters/pattern matching). 
Though with RE's you do have mechanism's of
of capturing the non-matching in-stream characters,
but it usually is, if you have multiple paterns,
very slow and itterative as opposed to a very robust
C++ class like CString. You however, are doing 
stream parsing and not pattern matching. And,
given you are keying on a single escape character
(although it could be others combined, as well)
I believe your method is "better" than the regex
suggested by others. The reason being that your 
methid is infinetly expandable which would leave
regex methods far behind when it comes to stream
parsing.

Well done!


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

Date: Fri, 04 Nov 2005 23:35:32 -0800
From: robic0@yahoo.com
Subject: Re: Why my code doesn't look Perl-ish?
Message-Id: <6inom111gd84p7h70biuh1sij4gjrja4oj@4ax.com>

On Fri, 04 Nov 2005 23:09:06 -0800, robic0@yahoo.com wrote:

>On 4 Nov 2005 19:57:36 +0100, "V S Rawat" <VSRawat@Invalid.none>
>wrote:
>
>>
>>I have developed a program that reads one string having several
>>codes in octal, decimal and/or hex; and/or has the characters.
>>
>>say, input: "ab\o081xy\d66z\\x\x81\aqwer";
>>
>>it interprets above as "ab (\o081) xy (\d66) z (\\) x (\x81)
>>(\a) qwer";
>>
>>then, it converts the o, d, h codes to chars, and returns the
>>entire string.
>>
>>\o, \d and \x can be followed by any no. of qualifying
>>digits/chars for that coding. \ bypasses the next char, and the
>>next char could be \ itself.
>>
>>it is working. The main module is the following:
>>========START
>>sub get_chrs {
>>    $TmpElementIn = shift(@_); # input string passed on to sub
>>    $TmpElementOut = ""; # string to go back to the caller
>>    $TmpIndexMax = length($TmpElementIn);
>>    $TmpIndexCurr = 0;
>>    $TmpIndexNext = 0;
>>    while ( $TmpIndexCurr < $TmpIndexMax ) {
>>        $TmpIndexNext = index( $TmpElementIn, "\\",
>>$TmpIndexCurr);
>>        if ( $TmpIndexNext < $TmpIndexCurr ) { # not found
>>            $TmpElementOut =
>>$TmpElementOut.substr($TmpElementIn, $TmpIndexCurr);
>               ^^^^^^^
>Funny, this is a cat, but almost looks like a C++ like
>member function for the "scalar" class.
>Maybe $TmpElementOut is just a CString.
>
>In my opinion, Perl is NOT good for stream parsing of
>strings because the only powerful tool in Perl for that
>is Regular Expressions (filters/pattern matching). 
>Though with RE's you do have mechanism's of
>of capturing the non-matching in-stream characters,
>but it usually is, if you have multiple paterns,
>very slow and itterative as opposed to a very robust
>C++ class like CString. You however, are doing 
>stream parsing and not pattern matching. And,
>given you are keying on a single escape character
>(although it could be others combined, as well)
>I believe your method is "better" than the regex
>suggested by others. The reason being that your 
>methid is infinetly expandable which would leave
>regex methods far behind when it comes to stream
>parsing.
>
>Well done!
Just want to add that sometimes in Perl it would
be nice to be able to index and adress, ie:
change and modify a single character in a string,
known only by its position in the array of 
characters. Or embed a string in a string, or
delete the same. To "index" a character in 
would be heaven. Maybe this can be done without
having to turn a string into an array of characters
then back into a string. I haven't seen it.
It would be nice to have the power to index a
string even if Perl doesen't know pointers.
Makes you wonder if "substr" is an intrinsic.



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

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


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