[16798] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4210 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 2 14:10:36 2000

Date: Sat, 2 Sep 2000 11:10:23 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967918222-v9-i4210@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 2 Sep 2000     Volume: 9 Number: 4210

Today's topics:
    Re: Q. relating to  perlfaq(4) / sort (Keith Calvert Ivey)
    Re: Q. relating to  perlfaq(4) / sort <abe@ztreet.demon.nl>
        Q?: alphabetical search <Gina.Joue@ucd.ie>
    Re: Self-extracting program <gellyfish@gellyfish.com>
        Setup Factory for Linux? <bbollenbach@home.com>
    Re: Setup Factory for Linux? (Abigail)
    Re: Setup Factory for Linux? <admin@salvador.venice.ca.us>
    Re: source code for newsgroups functionality (Colin Keith)
    Re: source code for newsgroups functionality <brian+usenet@smithrenaud.com>
    Re: THE BEST solution to encode Strings after a 3DES cr (Keith Calvert Ivey)
    Re: working out signatures <uri@sysarch.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 02 Sep 2000 14:54:59 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Q. relating to  perlfaq(4) / sort
Message-Id: <39b30fa7.34209343@news.newsguy.com>

Abe Timmerman <abe@ztreet.demon.nl> wrote:

>This might not be the best way, but it does the job.

Not if the data varies in the number of decimal places.  Try it
on (1.1234, 1,234, 1.34, 1.4).

>#!/usr/bin/perl -w
>use strict;
>
>my @data = (
>    '123.342',
>    '-23234',
>    '2347872347878273878984527636598264368234',
>    '1234878234' x 100,
>    '-' . '23423423' x 50,
>);
>
># preprocess to find the max len:
>my($ml, $fl) = (0, 0);
>for (@data) {
>    /^(?:-)?(\d+)(?:\.(\d+))?$/ or die "Invalid number: $_";
>    $ml < length $1 and $ml = length $1;
>    defined $2 and $fl < length $2 and $fl = length $2;
>}
>
># the main map() negates (tens complement?) the abs value of
># negative numbers and prepends a sortable sign
>my @orderd = map substr($_, $ml + $fl + 2) => sort
>    map {
>        /^(-)?(\d+)(?:\.(\d+))?$/;
>
>        my $sign = $1?'0':'1'; # swap for descending order
>        my $frac = $3 || 0;
>		
>        (my $tmp = sprintf "%${ml}s.%${fl}s", $2, $frac) 
>            =~ tr/ /0/;

You need a minus sign in the format:

         (my $tmp = sprintf "%${ml}s.%-${fl}s", $2, $frac) 
             =~ tr/ /0/;

>        $sign . join("", map { /\./?'.':$sign?$_:9-$_ } 
>            split //, $tmp) . $_;

That works, but I'd do it this way:

         $tmp =~ tr/0-9/9876543210/ unless $sign;
         $sign . $tmp . $-;

>    } @data;
>
>print "$_\n\n" for @orderd;

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Sat, 02 Sep 2000 18:43:52 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Q. relating to  perlfaq(4) / sort
Message-Id: <lta2rsk6r0bn51vqnk78lhdtudft4j9kld@4ax.com>

On Sat, 02 Sep 2000 14:54:59 GMT, kcivey@cpcug.org (Keith Calvert Ivey)
wrote:

> Abe Timmerman <abe@ztreet.demon.nl> wrote:
> 
> >This might not be the best way, but it does the job.
> 
> Not if the data varies in the number of decimal places.  Try it
> on (1.1234, 1,234, 1.34, 1.4).

Yep. Not tested very well with the fractions :-(

> >#!/usr/bin/perl -w
> >use strict;
> >
> >my @data = (
> >    '123.342',
> >    '-23234',
> >    '2347872347878273878984527636598264368234',
> >    '1234878234' x 100,
> >    '-' . '23423423' x 50,
> >);
> >
> ># preprocess to find the max len:
> >my($ml, $fl) = (0, 0);

While we're at it:

	my($ml, $fl) = (0, 1);

might be better, in case there are no numbers whith a decimal point.

> >for (@data) {
> >    /^(?:-)?(\d+)(?:\.(\d+))?$/ or die "Invalid number: $_";
> >    $ml < length $1 and $ml = length $1;
> >    defined $2 and $fl < length $2 and $fl = length $2;
> >}
> >
> ># the main map() negates (tens complement?) the abs value of
> ># negative numbers and prepends a sortable sign
> >my @orderd = map substr($_, $ml + $fl + 2) => sort
> >    map {
> >        /^(-)?(\d+)(?:\.(\d+))?$/;
> >
> >        my $sign = $1?'0':'1'; # swap for descending order
> >        my $frac = $3 || 0;
> >		
> >        (my $tmp = sprintf "%${ml}s.%${fl}s", $2, $frac) 
> >            =~ tr/ /0/;
> 
> You need a minus sign in the format:
> 
>          (my $tmp = sprintf "%${ml}s.%-${fl}s", $2, $frac) 
>              =~ tr/ /0/;

Yep.

> >        $sign . join("", map { /\./?'.':$sign?$_:9-$_ } 
> >            split //, $tmp) . $_;
> 
> That works, but I'd do it this way:
> 
>          $tmp =~ tr/0-9/9876543210/ unless $sign;
>          $sign . $tmp . $-;

Which looks much better (and it's probably faster too), thank you.

> 
> >    } @data;
> >
> >print "$_\n\n" for @orderd;

-- 
Good luck,
Abe


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

Date: Sat, 2 Sep 2000 17:42:04 +0100
From: "gina" <Gina.Joue@ucd.ie>
Subject: Q?: alphabetical search
Message-Id: <newscache$8eq90g$ls2$1@weblab.ucd.ie>

Hi,

I'm fairly new to Perl and was wondering whether there is an efficient way
to do repeated searches through a dictionary.

I have a file with words I need to look up in a pronunciation dictionary.
Both files are huge -- the way I have started to do the dictionary lookup
seems way too inefficient:

while ( $entry = <DICT> )
{
   if ( $entry eq $wdToLookup )
   {
    ...
   }
}

The problem also is that the dictionary has multiple entries of the same
word on different lines. I was thinking of dealing with this by pushing the
dictionary info for each entry, of the word to be looked up at the moment,
onto an array and spitting out the array after the while loop above -- but
then that seems to just add to the inefficiency cos it involves going
through the entire dictionary file, with the way I  have it.

Any advice?

Thanks,
Gina




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

Date: 2 Sep 2000 11:41:46 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Self-extracting program
Message-Id: <8oqlha$ulk$1@orpheus.gellyfish.com>

On Fri, 01 Sep 2000 11:40:41 GMT tltt@my-deja.com wrote:
> Hello,
> 
> I am developing a system which when complete will need to be deployed
> on a separate machine from the one used for development/testing. In
> order to make the deployment process more simple I would like to have a
> single program which when ran extracts from itself all the files that
> constitute the system and installs them in the right places after
> performing various checks (e.g. move existing files with the same name
> in a backup area).
> 
> Is there a Perl module that will let me do this? I looked at CPAN and
> the closest thing I found is Archive::Tar, which will allow me to
> deploy two files: a tar archive of the system, and the deployment
> program which can untar it in a temporary location, and then install
> the files in the right places.
> 

You could do it with one file.  The following code was originally presented
to store an image file within a program but it could equally be applied
to a tarball of all the files in your application creating a subroutine that
will return the content of the tarball which could be written out to a
temporary file then untarred and the files installed ...

#!/usr/bin/perl -w

use strict;

my $file = shift || die "$0: No file specified\n";

open(FILE,$file) || die "Couldnt open $file - $!\n";
binmode FILE;

my $imgdata = do { local $/; <FILE>};

my $uustring = pack "u",$imgdata;

my ($subname ) = $file =~ m%([^/.]+)\..+$%;

print <<EOSUB;
sub $subname
{
  return unpack "u", <<'EOIMG';
$uustring
EOIMG
}
EOSUB

Infact using tied filehandles you could do without any temporary files
both in the creation of the archive and the extraction - of course this
all does rather depend on Archive::Tar being available on the target
system.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sat, 02 Sep 2000 16:11:54 GMT
From: Brad B <bbollenbach@home.com>
Subject: Setup Factory for Linux?
Message-Id: <39B12562.5E66029@home.com>

Hello,

    I've just stumbled upon what I think to be an interesting idea for a
project: "Setup Factory" for Linux. At this point my main question is
feasibilty.

    For those of you who haven't seen the Windows version of it, the
short answer is that it's a developer's tool used to combine all the
dependencies necessary for a program into one installation directory and
create the ever-popular setup.exe to install all of those dependencies.
In other words, as a developer or as an end-user of the program, it's
always virtually guaranteed that all the dependencies will be in place.
For a more detailed explanation (well, a review anyways) of SF5 for
Windows, see:


http://the-internet-eye.com/reviews2000/Jan/SetupF5/default.htm

    Now admittedly, ./configure; make; make install, often works quite
dandily. But what about the times that it DOESN'T? =] Unmet
dependencies, you have to hunt through the README to find out what
you're missing, find out where to get it, hope that installing those
packages goes well, and then rerun the ./configure; make; make install
again. I don't have anything against README's but when it comes to
merely installing a new program I want as little of my time wasted on
that aspect as possible.

    So in conclusion, I ask you again: Does this seem like an
interesting project? Is it feasible? Is it worth doing? Would YOU like
to have a program like this as a developer?



</thought_provoking>


Brad Bollenbach



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

Date: 02 Sep 2000 12:45:02 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Setup Factory for Linux?
Message-Id: <slrn8r2bin.8ac.abigail@alexandra.foad.org>

Brad B (bbollenbach@home.com) wrote on MMDLIX September MCMXCIII in
<URL:news:39B12562.5E66029@home.com>:
$$ Hello,
$$ 
$$     I've just stumbled upon what I think to be an interesting idea for a
$$ project: "Setup Factory" for Linux. At this point my main question is
$$ feasibilty.

Well, first of all "... for Linux" makes my toes curl. The Unix world
is already fragmented enough as it is. We can do without tools that
work for just one platform.

$$     For those of you who haven't seen the Windows version of it, the
$$ short answer is that it's a developer's tool used to combine all the
$$ dependencies necessary for a program into one installation directory and
$$ create the ever-popular setup.exe to install all of those dependencies.
$$ In other words, as a developer or as an end-user of the program, it's
$$ always virtually guaranteed that all the dependencies will be in place.
$$ For a more detailed explanation (well, a review anyways) of SF5 for
$$ Windows, see:
$$ 
$$ http://the-internet-eye.com/reviews2000/Jan/SetupF5/default.htm
$$ 
$$     Now admittedly, ./configure; make; make install, often works quite
$$ dandily. But what about the times that it DOESN'T? =] Unmet
$$ dependencies, you have to hunt through the README to find out what
$$ you're missing, find out where to get it, hope that installing those
$$ packages goes well, and then rerun the ./configure; make; make install
$$ again. I don't have anything against README's but when it comes to
$$ merely installing a new program I want as little of my time wasted on
$$ that aspect as possible.

 ./configure; make; make install has some very big advantages. First,
the use of configure is mainly to set up (compilation of) your program
such that is works on a wild range of platforms. It can also deal with
alternatives (well, you don't have this, but you do have that), avoiding
depencies. Not automatically installing dependencies is a feature. It
makes you make a conscious decision what you want to install or not.

I can just see it, after a few runs of setup.exe (sic) you end up with
three mutally incompatible perls, one in /usr, one in /usr/local and
one in /opt. And the next setup is going to fail, it found the perl
in /usr/local, but it thought the libraries were in /usr/local/share,
but, alas, all that's there were libraries from an old version of perl,
which are no longer binary compatible.

The next day, for the new program you install, setup.exe decides that
the perl5.005 you have is too old, installs perl5.6.0 for you, and yo
and behold, your new program runs fine. Never mind 15 of your critical
applications no longer work because they didn't run in perl5.6.0.
Don't say "oh, but that will never happen" - it did with CPAN.pm.

$$     So in conclusion, I ask you again: Does this seem like an
$$ interesting project? Is it feasible? Is it worth doing? Would YOU like
$$ to have a program like this as a developer?

Don't try to invest the Unix world with the Windows paradigm. If Windows
works fine for you, use Windows. If Windows works fine for flocks of
people, let them be happy and let them keep using Windows. The Unix world
has nothing to gain by attracking the sheep. It only leads to frustrated
people, and Unix getting a worse name than it already has.

It's a bad idea. If people want to run a Unix, they should realize that
a Unix box needs to be administrated. You either pay someone to do that
(or have your company do so), or you do so yourself. If you are unable,
or unwilling to do so, well, don't use Unix. Bill Gates has to eat too.



Abigail
-- 
perl -Mstrict -we '$_ = "goto X.print chop;\n=rekcaH lreP rehtona tsuJ";X1:eval'


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

Date: Sat, 02 Sep 2000 10:30:25 -0700
From: Pan <admin@salvador.venice.ca.us>
Subject: Re: Setup Factory for Linux?
Message-Id: <39B13931.D518790@salvador.venice.ca.us>

Ever hear of RPM?

Brad B wrote:
> 
> Unmet dependencies, you have to hunt through the README to find out what
> you're missing, find out where to get it, hope that installing those
> packages goes well, and then rerun the ./configure; make; make install
> again. I don't have anything against README's but when it comes to
> merely installing a new program I want as little of my time wasted on
> that aspect as possible.

-- 
Salvador Peralta
admin@salvador.venice.ca.us
http://www.la-online.com


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

Date: Sat, 02 Sep 2000 15:21:07 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: source code for newsgroups functionality
Message-Id: <BV8s5.3372$%t6.368944@nnrp3.clara.net>

In article <39B0B844.B6601F71@uni-c.dk>, Bo Hedemark Pedersen <bhp@uni-c.dk> wrote:
>Does anyone know if any open source code for Usenet-newsgroups
>functionality (i.e. perl-scripts manipulating an underlying database
>structure thereby obtaining newsgroup functionality with the opportunity
>of adding/removing groups and messages in these and of course threading
>messages) in cgi-perl (it is to be used by a webserver) exists?

Er, there is no 'database structure' as such. Basically you request newsgroups 
from a server and it sends you a list (plain text) of the group name and the 
number of aritcles etc. How you store them is entirely up to you. If you only 
want to play with a small set of groups, say comp.lang.perl.* then you could 
happily ploink it in a flat text file. If you're playing with the entire 47377 
groups that I can see on our servers (yes, we do sell news accounts:-) then 
you'd probably want something a lot quicker, like a DB_File or beefier (I 
can't remember the comparisons of various DB modules). Though its unlikely 
that you'll want to try and handle a full usenet news feed with a perl 
program:)

If you want to get the list then you'll probably want to look at the Net:NNTP 
module. 

If you want to play with servers, there are example TCP/IP servers in the 
perlipc man page, and the camel book (i believe). There are also modules for 
creating daemon processes on CPAN, but the names slip my memory. Have a look 
there though, there may well be modules for NNTP servers.

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sat, 02 Sep 2000 12:22:30 -0400
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: source code for newsgroups functionality
Message-Id: <020920001222300624%brian+usenet@smithrenaud.com>

In article <BV8s5.3372$%t6.368944@nnrp3.clara.net>, Colin Keith
<newsgroups@ckeith.clara.net> wrote:

> In article <39B0B844.B6601F71@uni-c.dk>, Bo Hedemark Pedersen <bhp@uni-c.dk>
> wrote:
> >Does anyone know if any open source code for Usenet-newsgroups
> >functionality

> If you want to play with servers, there are example TCP/IP servers in the 
> perlipc man page, and the camel book (i believe). There are also modules for 
> creating daemon processes on CPAN, but the names slip my memory. Have a look 
> there though, there may well be modules for NNTP servers.

there are modules for NNTP on CPAN.  there's no need to tell someone to 
play with TCP/IP.


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

Date: Sat, 02 Sep 2000 15:16:08 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: THE BEST solution to encode Strings after a 3DES crypt ?
Message-Id: <39b91899.36500149@news.newsguy.com>

"Tong YANG" <tong@quadrupede.com> wrote:

>Context : Perl/CGI/HTML

What's that supposed to accomplish?

>So, I search the perfect solution : I want to transmit the string in
>an numeric form, where each chars are converted to a number (hex or long).
>Each value of chars is separated by ":" for exemple.  So, I cannot
>find a Perl function to translate chars -> ascii value. I tried with
>pack and unpack but without good results...

Why not just use unpack('H*', $original_string) and 
pack('H*', $encoded_string)?  No colons necessary.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Sat, 02 Sep 2000 17:16:04 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: working out signatures
Message-Id: <x7og26ogtn.fsf@home.sysarch.com>

>>>>> "G" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

  G> Mark McCarthy wrote:
  >> Whenever I feel cocky and think I'm gaining a modicum of 
  >> perl mastery, I always take a JAPH reality check to bring
  >> me back down to earth ...


  G> Have any of you ever considered leaving
  G> this Cargo Cult, venturing out on your
  G> own, being different, not simply being
  G> just another sheep in the flock?

have you ever thought about getting back on your meds, leaving this
newsgroup where you are not wanted nor respected, and learning python?

sorry, i presumed you can think. my bad.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4210
**************************************


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