[17585] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5005 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 1 03:10:29 2000

Date: Fri, 1 Dec 2000 00:10:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975658214-v9-i5005@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 1 Dec 2000     Volume: 9 Number: 5005

Today's topics:
    Re: Perl Illiterate (Craig Berry)
        Perl string converter designpixs@my-deja.com
    Re: Perl string converter <bwalton@rochester.rr.com>
    Re: Perl string converter lightfoote@my-deja.com
    Re: proc::daemon question (David Efflandt)
        Random password generator fallenang3l@my-deja.com
    Re: reformat time output <tony_curtis32@yahoo.com>
    Re: reformat time output <krahnj@acm.org>
        regex not matching (Wyzelli)
        Using Curses <wombat@virtualdan.com>
    Re: Using Curses (Chris Fedde)
        Using goto (Shawn Smith)
    Re: What is a Junior Perl Programmer? (Craig Berry)
    Re: Why? <johngros@Spam.bigpond.net.au>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 01 Dec 2000 08:02:20 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl Illiterate
Message-Id: <t2emoc8eginc13@corp.supernews.com>

Tad McClellan (tadmc@metronet.com) wrote:
: >What is perl?
: 
: What would you expect for a newsgroup with "comp.lang" in its name?

Comprehensive discussions on the life of the singer k.d. lang.  From the
'perl.misc' portion, I have been eagerly anticipating discussion of all
facets of her little-known interest in knitting.

I'm still waiting, folks.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "There is no dark side of the moon really.  Matter
   |   of fact, it's all dark."  - Pink Floyd


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

Date: Fri, 01 Dec 2000 04:03:27 GMT
From: designpixs@my-deja.com
Subject: Perl string converter
Message-Id: <9077uc$bp5$1@nnrp1.deja.com>

I want to be able to pass in a string of any size
and return an integer.  The return value is
always unique to the string passed in.  (i.e.
pass in TEST returns 3452, pass in TESTS returns
234532) The return value MUST be a unique value
to the value passed in.  If I pass in TEST and
get 1234 and the later pass in TEST I should get
1234.

Hope someone can help.

Thanks,
Drew


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 01 Dec 2000 04:34:52 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl string converter
Message-Id: <3A272B18.56A2F095@rochester.rr.com>

designpixs@my-deja.com wrote:
> 
> I want to be able to pass in a string of any size
> and return an integer.  The return value is
> always unique to the string passed in.  (i.e.
> pass in TEST returns 3452, pass in TESTS returns
> 234532) The return value MUST be a unique value
> to the value passed in.  If I pass in TEST and
> get 1234 and the later pass in TEST I should get
> 1234.
 ...
> Drew
 ...
What you're asking for is technically infeasible.  There are a *lot* of
strings "of any size" out there, and only a relative handful of integer
values.  For example, a 100000-character string has 2**800000 possible
values (which is probably more than the number of electrons in the
universe), while a standard integer has only 2**32 possible values.  I
suppose you could use the Math::BigInt package to represent a unique
number for each such string, but then why not just use the string
itself, since there would be a 1:1 relationship anyway?

The thing you probably actually want is called a hash function -- but a
hash function does not meet your stated criterion of uniqueness.  If you
would like to see the hash function Perl uses for its hashes, take a
read through:

    perldoc perlguts

-- 
Bob Walton


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

Date: Fri, 01 Dec 2000 05:46:57 GMT
From: lightfoote@my-deja.com
Subject: Re: Perl string converter
Message-Id: <907e0h$gcd$1@nnrp1.deja.com>

hi perl family...

ah you may want to try writing a hash function based on
the strings length and the first 20 characters of the string...
there are many hash functions out there that you could use...
hash functions drove a lot of the old databases... 20
30 years ago...

foote



In article <9077uc$bp5$1@nnrp1.deja.com>,
  designpixs@my-deja.com wrote:
> I want to be able to pass in a string of any size
> and return an integer.  The return value is
> always unique to the string passed in.  (i.e.
> pass in TEST returns 3452, pass in TESTS returns
> 234532) The return value MUST be a unique value
> to the value passed in.  If I pass in TEST and
> get 1234 and the later pass in TEST I should get
> 1234.
>
> Hope someone can help.
>
> Thanks,
> Drew
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 1 Dec 2000 04:21:48 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: proc::daemon question
Message-Id: <slrn92e9qn.fnk.efflandt@efflandt.xnet.com>

On Thu, 30 Nov 2000 11:43:54 +0000, Hilkiah Lavinier <hl198@doc.ic.ac.uk> wrote:
>Hi, I'm trying to get the following program to work while running as a
>daemon.  It's quite silly but I need to figure this out in order to get
>the real program running.  It works fine if i comment the line with
>Proc::Daemon::Init; but when I leave this line uncommented (so the
>programs runs in the background as a Daemon, the files don't get
>created.
>
>Here is the source code:
>
>#!/usr/bin/perl -w
>#daemon.plx
>
>#use warnings;
>use strict;
>use Proc::Daemon;
>use Carp;
>
>Proc::Daemon::Init;
>
>print "hi";
>system("touch newfile");
>`touch file`;

What happens if you comment out the 'print "hi"'?  Where do you expect
that to print to when running as a daemon?  It likely hangs or dies at
that point.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Fri, 01 Dec 2000 04:12:51 GMT
From: fallenang3l@my-deja.com
Subject: Random password generator
Message-Id: <9078fv$c6h$1@nnrp1.deja.com>

I am looking for a random password generator (don't bother with
Crypt::RandPasswd because sometimes it can be painstainklingly [sp?]
slow). It doesn't have to be really complicated, just pretty random.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 30 Nov 2000 20:05:16 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: reformat time output
Message-Id: <87r93s99r7.fsf@limey.hpcc.uh.edu>

>> On Fri, 01 Dec 2000 01:48:46 GMT,
>> "EM" <me@privacy.net> said:

> How do i turn Fri Dec 1 01:44:30 2000 (outputted by
> localtime) into 01-Dec-2000 01:44

perldoc POSIX -> strftime

    use POSIX 'strftime';
    my $now = strftime('%d-%b-%Y %H:%M', localtime);

Use localtime() in list context not in scalar.

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Fri, 01 Dec 2000 04:03:21 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: reformat time output
Message-Id: <3A2723A5.94D6D7F1@acm.org>

EM wrote:
> 
> How do i turn
> Fri Dec  1 01:44:30 2000 (outputted by localtime)
> into
> 01-Dec-2000 01:44

my @today = localtime;
printf "%02d-%s-%4d %02d:%02d\n", $today[3],

('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[$today[4]],
	$today[5] + 1900, $today[2], $today[1];

John


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

Date: Fri, 01 Dec 2000 07:23:02 GMT
From: wyzelli@yahoo.com (Wyzelli)
Subject: regex not matching
Message-Id: <Xns8FFDAA69Fwyzelliyahoocom@203.39.3.131>

Had an interesting situation recently where a regex failed to match, when I 
thought it should.

The data being matched is like so:

C     Around to it                       aroundto       $22.23

and occasionally the amount is $0.00 so I get 

C     Around to it                       aroundto       $0.00

I wrote a short script to parse this and not print the $0.00 lines,

and sum all the others.

The regex to skip the $0.00 lines was /\$0\.00$/  Which failed to match.

To get it to work, I had to use m/\$0\.00$/.

I thought the m was optional when the regex delimiter was a slash.

This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2000, Larry Wall

Binary build 617 provided by ActiveState Tool Corp. 
http://www.ActiveState.com
Built 20:32:54 Aug 31 2000

Wyzelli

-- 
#beer v2
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it 
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";


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

Date: Fri, 01 Dec 2000 04:17:35 GMT
From: Dan Cardamore <wombat@virtualdan.com>
Subject: Using Curses
Message-Id: <zDFV5.30114$3u1.7441945@news3.rdc1.on.home.com>

Hi all,
I'm trying to use Curses to make a perl shell which can execute
system commands as well.  I'd like to use Curses because I can 
do some cool GUI stuff if I use it.  The problem is that I can't
use it to execute things like "ls --color" since that will return
some special terminal color codes.  

Is there a way to have curses display the screen in two:  top part
being non-curses, and the bottom half being curses?  Or is there a
better way to execute commands like this and get them to display
nicely.

Thanks for any help,

Dan

________________________________________________________________
 Dan Cardamore      wombat@proudly.ca     http://www.proudly.ca
 GnuPGP Key:        mailto:wombat@proudly.ca?subject=sendpgpkey
 Mail Filter:       mailto:wombat@proudly.ca?subject=mailfilter
 My current project can be found at http://www.collaboffice.com
________________________________________________________________


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

Date: Fri, 01 Dec 2000 06:45:40 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Using Curses
Message-Id: <oOHV5.41$_g6.171803648@news.frii.net>

In article <zDFV5.30114$3u1.7441945@news3.rdc1.on.home.com>,
Dan Cardamore  <wombat@virtualdan.com> wrote:
>Hi all,
>I'm trying to use Curses to make a perl shell which can execute
>system commands as well.  I'd like to use Curses because I can 
>do some cool GUI stuff if I use it.  The problem is that I can't
>use it to execute things like "ls --color" since that will return
>some special terminal color codes.  
>
>Is there a way to have curses display the screen in two:  top part
>being non-curses, and the bottom half being curses?  Or is there a
>better way to execute commands like this and get them to display
>nicely.
>

One way to do this is to just do the colorization yourself.  That
is when someone asks for a directory you just opendir and do the
colorization directly as you loop through the display.  The other
method would be to build a parsing tree indexed by the ANSI escape
sequences using TERM::ANSIColor and match what 'ls --color' returns
to what is in the parse tree.
-- 
    This space intentionally left blank


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

Date: Fri, 01 Dec 2000 08:00:52 GMT
From: SPAM_loginprompt@yahoo.com (Shawn Smith)
Subject: Using goto
Message-Id: <3a275831.1941907@netnews.worldnet.att.net>

Hello all,

I am fresh out of school w/ a dream job. I am to improve some perl
code. I am very new to perl too, but love it a lot. I have the camel
and the cook book.

Some of the scripts have goto statements. What I have read is that
goto's slow down the scripts because goto's cause Perl to compile the
scripts on every run. I thought that the scripts got interpreted. Can
someone explain this or direct me to the proper docs?

Also, to justify removing the goto's I must show that it will improve
the efficiency of the scripts. I can't just say hey these are not
cool. The goto's are (so far, I have only read 3 of a dozen scripts)
being used when an error occurs. Thus, only on rare occasions do the
goto's get used.

TIA,

__

Shawn Smith 
My freeware: http://sites.netscape.net/shawnspad 




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

Date: Fri, 01 Dec 2000 07:52:37 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: What is a Junior Perl Programmer?
Message-Id: <t2em65q3uhk3e7@corp.supernews.com>

bowman (bowman@montana.com) wrote:
: Terrence Brannon <brannon@lnc.usc.edu> wrote in message
: news:lbofzbeer2.fsf_-
: > In my opinion you are either a mid-level to senior programmer, or you
: > should stick to a simpler language.
: 
: And you sprung from the womb as a mid-level Perl programmer?

No, I came out as a senior programmer.  It's only been downhill from
there. :)

But as in his use of 'you' in the first clause, I think the intent here is
to say 'become mid-to-senior in other languages, and then tackle Perl'.
Which you can actually make a case for, I think.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "There is no dark side of the moon really.  Matter
   |   of fact, it's all dark."  - Pink Floyd


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

Date: Fri, 01 Dec 2000 05:50:48 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: Why?
Message-Id: <Y_GV5.216$xW4.1504@news-server.bigpond.net.au>

> Please learn to place your reply after the quoted material you are
> commenting on.  What the hell is "it" in "I read it here" referring
> to?  This is no way to have a dialog.
>
> Anno
Sorry Anno




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

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


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