[25817] in Perl-Users-Digest
Perl-Users Digest, Issue: 8054 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 6 00:05:40 2005
Date: Thu, 5 May 2005 21:05: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 Thu, 5 May 2005 Volume: 10 Number: 8054
Today's topics:
Re: Help regarding Perl modules in .pl and .in extensio <djb@global.net.mt>
Re: How do I parse certain "bits" out of bytes? <none@none>
Offline Perl obfusquator ? <jazeker_b_nospamlalala@yahoo.co.uk>
Re: Offline Perl obfusquator ? <someone@example.com>
Re: Offline Perl obfusquator ? <nospam@bigpond.com>
Re: Offline Perl obfusquator ? <tadmc@augustmail.com>
Re: sorting a structure <skuo@mtwhitney.nsc.com>
Re: sorting a structure (Anno Siegel)
Re: sorting a structure <skuo@mtwhitney.nsc.com>
Re: sorting a structure <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 6 May 2005 02:57:40 +0200
From: "David Joseph Bonnici" <djb@global.net.mt>
Subject: Re: Help regarding Perl modules in .pl and .in extension.
Message-Id: <d5efe6$f4f$1@domitilla.aioe.org>
Thanks very much for the info. At least you put me on the right track.
Thanks.
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:d5e1un$i1b$1@mamenchi.zrz.TU-Berlin.DE...
> David Joseph Bonnici <djb@global.net.mt> wrote in comp.lang.perl.misc:
>> Hi I am using ActivePerl (Build 811) on Windows. I am using Komodo as an
>> editor. I am a newbie.
>>
>> I am having problems when referencing to modules that have the extension
>> .pl
>> or .in.
>> I am using downloaded projects from sourceforge to test some features.
>>
>> I usually found myself in the scenario, and I get stuck.
>>
>> in a test123.pl file I find
>>
>> .....
>> use David;
>> .....
>>
>> When I go to search for the modules, (in order to copy these files to
>> c:\perl\lib) I find
>>
>> David.pm.pl and David.pm.in.
>>
>> If I copy them to the lib folder, the interpreter still tells me that he
>> cannot find the module
>>
>> If I try to remame anyone of them, I get cannot compile object.
>>
>> Any help is appreciated.
>
> You haven't installed the module properly. David.pm.pl and David.pm.in
> (why didn't you give a real example?) are a Perl script and a template
> file that together create David.pm. This happens during what is called
> the build process. I don't know the particulars of the build process
> under windows, but it would include thinks like
>
> perl Makefile.PL
> nmake
>
> etc.
>
> If the module you want doesn't come pre-packaged for windows, it may
> be hard to install.
>
> Anno
------------------------------
Date: Fri, 06 May 2005 08:28:19 +1000
From: Paul <none@none>
Subject: Re: How do I parse certain "bits" out of bytes?
Message-Id: <427a9e03$0$4658$afc38c87@news.optusnet.com.au>
Fabian Pilkowski wrote:
> * Mike Heins schrieb:
>
>>Here is a way that doesn't rely on the somewhat impenetrable
>>unpack() function:
>>
>> my $value = 0x65;
>> my $binstring = sprintf '%b', $value;
>> $binstring = '0' . $binstring while length($binstring) < 8;
>
>
> Sure, anyone could understand what you're doing here but it's more
> elegant to insert "08" into the format string
>
> my $binstring = sprintf '%08b', $value;
>
> instead of a while loop.
>
> regards,
> fabian
The idea of "bit bashing" seems to have died from the early days of
computing whhere memory was a real problem and programmers had to
operate down at the lowest levels of the machine.
It is probably still needed in embedded systems for monitoring
industrial control inputs but is most likely supported by "bit bashing"
libraries which hide the underlying data from view.
My suggestion to the person who started this thread is to do a quick bit
of home study on binary numbers and get to understand how they work ( it
aint hard ) !!
Start with the ASCII chart and then work your way up to numerical values
- maybe write your own "bit bashing" library.
------------------------------
Date: Fri, 06 May 2005 00:43:48 GMT
From: Jazeker <jazeker_b_nospamlalala@yahoo.co.uk>
Subject: Offline Perl obfusquator ?
Message-Id: <85zee.82332$RB6.5277755@phobos.telenet-ops.be>
Hello,
As I am making a piece of Perl code that contains some policies
(disallowing people to send spam, etc...) I want to higher the treshold
for people to change those lines of code. (some will... I know).
That would require me to have some script or program that can obfusquate
(even by just playing with the code layout) a few blocks of code. I am
not looking for an obfusquator that would completely change all variable
names, etc... but that would just make a few blocks of code very hard to
read so only Perl wizzards would know what to do (and I expect those
wizards not to be needing my software to annoy the world ;-) )
Any hints, links or other would be appreciated.
PS : not looking for an online obfusquator as well... just an offline
script would be ok.
Thanks,
Jaz
--
print <<EOF;
Just a noobish Perl hacker
EOF
------------------------------
Date: Fri, 06 May 2005 01:00:58 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Offline Perl obfusquator ?
Message-Id: <elzee.42471$HR1.18458@clgrps12>
Jazeker wrote:
>
> As I am making a piece of Perl code that contains some policies
> (disallowing people to send spam, etc...) I want to higher the treshold
> for people to change those lines of code. (some will... I know).
>
> That would require me to have some script or program that can obfusquate
> (even by just playing with the code layout) a few blocks of code. I am
> not looking for an obfusquator that would completely change all variable
> names, etc... but that would just make a few blocks of code very hard to
> read so only Perl wizzards would know what to do (and I expect those
> wizards not to be needing my software to annoy the world ;-) )
>
> Any hints, links or other would be appreciated.
>
> PS : not looking for an online obfusquator as well... just an offline
> script would be ok.
http://search.cpan.org/~dconway/Acme-Bleach-1.12/
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 06 May 2005 11:05:24 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Offline Perl obfusquator ?
Message-Id: <427ac1e8_1@x-privat.org>
Jazeker wrote:
> Hello,
>
> As I am making a piece of Perl code that contains some policies
> (disallowing people to send spam, etc...) I want to higher the treshold
> for people to change those lines of code. (some will... I know).
Don't give your code to anyone & they cant change it. Works for me.
gtoomey
------------------------------
Date: Thu, 5 May 2005 20:31:13 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Offline Perl obfusquator ?
Message-Id: <slrnd7li71.ecc.tadmc@magna.augustmail.com>
Jazeker <jazeker_b_nospamlalala@yahoo.co.uk> wrote:
> As I am making a piece of Perl code that contains some policies
> (disallowing people to send spam, etc...) I want to higher the treshold
> for people to change those lines of code. (some will... I know).
>
> That would require me to have some script or program that can obfusquate
> (even by just playing with the code layout) a few blocks of code. I am
> not looking for an obfusquator that would completely change all variable
> names, etc... but that would just make a few blocks of code very hard to
> read
An all white screen can be hard to read...
> so only Perl wizzards would know what to do (and I expect those
> wizards not to be needing my software to annoy the world ;-) )
>
> Any hints, links or other would be appreciated.
... so Bleach it!
http://search.cpan.org/~dconway/Acme-Bleach-1.12/lib/Acme/Bleach.pm
(make backup copy of your program before you try it!)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 5 May 2005 15:21:57 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: sorting a structure
Message-Id: <Pine.GSO.4.21.0505051506420.5320-100000@mtwhitney.nsc.com>
On Thu, 5 May 2005, Brett wrote:
> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> news:8Tmee.2706$Vu.1954@trnddc07...
> > Brett wrote:
> > > I have two arrays and i wish to sort the first one numerically, but
> > > after sorting, I would like the second array to be in the same
> > > matching order as the first array.
> > >
> > > ie.
> > >
> > > @l1={3,1,2};
> > > @l2={'a','b','c'};
> > >
> > > @l1 = sort {$a <=> $b} (@l1); # sort list @l1 to be {1,2,3}
> > >
> > > # do something to @l2 to make order {'b','c','a'} (preserving the
> > > original mapping with the first list)
> > >
> > > There's probably an easy way to do this that i'm not aware of.
> >
> > Indeed, there is: use a data structure that matches your problem better.
> > Instead of having a pair of unrelated arrays use a single array of pairs.
> > And then sort that single array by the value of the first component of
> each
> > pair.
> >
> > jue
>
>
> I'm new to this, and tried to give it a go.
>
> use Class::Struct;
Haven't seen anything in your description that requires OO-style
programming.
> struct ID =>
> {
> number => '$',
> name => '$',
> };
>
> my @IDs = ID->new();
> #fill data...
The constructor returns a single item (a blessed reference); I'm not
sure why you would want to store it into an array though.
> @IDs = sort {$a->number <=> $b->number} (@IDs); # numeric sort on number
Are your sorting an array containing just a single item?
> but that failed to sort the list as i expected. How can i use sort on a
> structure to do
> what I want?
I think this is more along the lines of what Jürgen suggested:
use strict;
use warnings;
use List::MoreUtils qw(pairwise);
my @l1 = (3, 1, 2);
my @l2 = qw(a b c);
my @numbers_sorted;
my @letters_mapped;
for my $aref (
sort { $a->[0] <=> $b->[0] }
pairwise { [$a, $b] } @l1, @l2
) {
push @numbers_sorted, $aref->[0];
push @letters_mapped, $aref->[1];
}
--
Hope this helps,
Steven
------------------------------
Date: 5 May 2005 22:52:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: sorting a structure
Message-Id: <d5e82g$j6s$4@mamenchi.zrz.TU-Berlin.DE>
Steven Kuo <skuo@mtwhitney.nsc.com> wrote in comp.lang.perl.misc:
> On Thu, 5 May 2005, Brett wrote:
>
> > "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> > news:8Tmee.2706$Vu.1954@trnddc07...
> > > Brett wrote:
> > > > I have two arrays and i wish to sort the first one numerically, but
> > > > after sorting, I would like the second array to be in the same
> > > > matching order as the first array.
[snippage]
> I think this is more along the lines of what Jürgen suggested:
>
> use strict;
> use warnings;
> use List::MoreUtils qw(pairwise);
[presumably correct implementation snipped]
However, regrouping the data structure is not strictly necessary. Indirect
sorting is an age-honored technique of ordering one list according to
another. You first sort a list of indices to the numeric array according
to the values in that array. Then you take the elements of the second
array in sequence of the indices:
my @l1 = qw( 3 1 2);
my @l2 = qw( a b c);
my @l2_sorted = @l2[ sort { $l1[ $a] <=> $l1[ $b] } 0 .. $#l1];
Anno
------------------------------
Date: Thu, 5 May 2005 16:14:15 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: sorting a structure
Message-Id: <Pine.GSO.4.21.0505051610140.5320-100000@mtwhitney.nsc.com>
On 5 May 2005, Anno Siegel wrote:
> Steven Kuo <skuo@mtwhitney.nsc.com> wrote in comp.lang.perl.misc:
>
> > I think this is more along the lines of what Jürgen suggested:
> >
> > use strict;
> > use warnings;
> > use List::MoreUtils qw(pairwise);
>
> [presumably correct implementation snipped]
>
> However, regrouping the data structure is not strictly necessary. Indirect
> sorting is an age-honored technique of ordering one list according to
> another. You first sort a list of indices to the numeric array according
> to the values in that array. Then you take the elements of the second
> array in sequence of the indices:
>
> my @l1 = qw( 3 1 2);
> my @l2 = qw( a b c);
> my @l2_sorted = @l2[ sort { $l1[ $a] <=> $l1[ $b] } 0 .. $#l1];
>
I like it!
To efficiently generate two sorted arrays, one would presumably save the
sorted indices:
my @sorted_idx = sort { $l1[ $a] <=> $l1[ $b] } 0 .. $#l1 ;
my @l1_sorted = @l1[ @sorted_idx ];
my @l2_sorted = @l2[ @sorted_idx ];
Thanks for the tip.
--
Regards,
Steven
------------------------------
Date: Thu, 5 May 2005 18:56:31 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: sorting a structure
Message-Id: <slrnd7lclf.e3q.tadmc@magna.augustmail.com>
Brett <bg1343d@hotmail.com> wrote:
> Subject: sorting a structure
Please get your newsreader configured to generate proper followups.
Missing the "Re: " in the Subject header isn't so bad,
but having no References: header breaks the thread.
> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> news:8Tmee.2706$Vu.1954@trnddc07...
>> Brett wrote:
[snip]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 8054
***************************************