[10461] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4053 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 23 10:04:12 1998

Date: Fri, 23 Oct 98 07:00:27 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 23 Oct 1998     Volume: 8 Number: 4053

Today's topics:
    Re: "Document Contains no data"? <emills@harris.com>
        *Why* does clpm attract non-perl posts? (David Alan Black)
    Re: *Why* does clpm attract non-perl posts? <jhoglund@mirage.skypoint.net>
    Re: Backgrounding long processes? (M.J.T. Guy)
        bhtpasswd and database file (G Brehm)
    Re: Guides <ibelgaufts@gfc-net.de>
    Re: help shorten one-liner (Joergen W. Lang)
    Re: how do  you add three variables <rick.delaney@shaw.wave.ca>
        How do I check input to CGI? c960901@student.dtu.dk
    Re: How do I check input to CGI? <zenin@bawdycaste.org>
    Re: how to use CGI to download <weekesd@logica.com>
    Re: How to yield processor time? (Walter Tice USG)
        i just find a whatsnew cgi script cutebaby@my-dejanews.com
    Re: Info on crypt() (Peter Holzer)
    Re: IO::Socket error - solution - solved again! <marius@odin.funcom.com>
    Re: IO::Socket error - solution! <marius@odin.funcom.com>
        looking for a perl interpreter for NT <lammie_pie@hotmail.com>
    Re: looking for a perl interpreter for NT <weekesd@logica.com>
    Re: making a variable variable? (Mark-Jason Dominus)
    Re: PERL & simple flat file database??? (Joergen W. Lang)
    Re: Perl & Y2K - booby trap code <ljz@asfast.com>
        programing fun: nested array... <xah@best.com>
    Re: programing fun: nested array... (David Alan Black)
    Re: Rounding Problem (M.J.T. Guy)
        Using percent (%) in printf issue <toml@synnet.com>
    Re: Using percent (%) in printf issue (David Alan Black)
    Re: Using percent (%) in printf issue <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Using percent (%) in printf issue (Allan Hawdon)
    Re: VCS::CVS code announcement (provisional name) <l.brocard@elsevier.nl>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 23 Oct 1998 07:40:05 -0400
From: "PERL ROCKS!" <emills@harris.com>
Subject: Re: "Document Contains no data"?
Message-Id: <36306B15.C17FA6D5@harris.com>

"Document contains no data" is a common result of not having proper HTML returned
by the script. Make sure you have the Content line, and the proper <html> <body>
tags returned. The message is returned when the browser can't interpret the text
into an HTML document.

E

piercew@netscape.net wrote:

>  I've got a question, hopefully someone here can help with.  I'm working on a
> CGI script to take one field of input and compare that to a DBM file.  It
> works fine until I get to the part of the script where I want to compare the
> hmclose(%miramar);
> ayne
>



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

Date: 23 Oct 1998 06:01:59 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: *Why* does clpm attract non-perl posts?
Message-Id: <70pk6n$6b$1@pilot.njin.net>

What I don't get is.......

If someone is interested in CGI programming and/or Web administration
and/or the vagaries of Micros**t IE, etc., why wouldn't that person
actually WANT to participate in the appropriate newsgroups?

It's as if there's a premium on posting to comp.lang.perl.misc, and
that, therefore, one's goal (whatever one's topic) should be to make a
case for the appropriateness of one's posting there.  Or - failing such
a case - simply to post there, as if to say: "I'll be damned if I'll
allow myself to be excluded from posting to the Great Newsgroup."

This comes out particularly in people who, having had it pointed out to
them that they are off-topic, repeat the behavior or even defend it (on
the grounds that Perl is used for CGI programming, or whatever).

Is there something going on I don't know about?  Is everyone but me
receiving, say, one dollar for every post to clpm?  Raffle tickets?
Reduced time in purgatory?

Above and beyond these questions, I do have one practical suggestion.
To wit:  there are an awful lot of *answers* being provided on clpm to
these off-topic questions, usually prefaced with, "Your question isn't
really about Perl, but anyway..." or words to that effect.  It may well
be kind-hearted and good to field these questions - but I wonder whether
perhaps such fielding could be confined to email.  Otherwise, once past
the hurdle of parenthetically mentioning the inappropriateness of the
topic, we've got a thread on our hands.


David Black
dblack@pilot.njin.net


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

Date: 23 Oct 1998 13:31:37 GMT
From: Jamie Hoglund <jhoglund@mirage.skypoint.net>
Subject: Re: *Why* does clpm attract non-perl posts?
Message-Id: <70q0fp$otq$1@shadow.skypoint.net>

David Alan Black <dblack@pilot.njin.net> wrote:
: What I don't get is.......

: If someone is interested in CGI programming and/or Web administration
: and/or the vagaries of Micros**t IE, etc., why wouldn't that person
: actually WANT to participate in the appropriate newsgroups?

One thing I've noticed is that as perl programs become available some
people are actually perl *users* who really don't care about how to
program perl, they want to know how to install it or why program xxx 
doesn't work because I need zzz module. 

That might explain some of it. Well, just a guess anyway. The .misc on the
end of the newsgroup name indicates that it isn't about perl programming,
it's about miscelaneous aspects of the perl language. 

Perl is popular, used everywhere, so naturally it is going to extend to a
lot of areas. If it were comp.programming.perl it might be different.

Jamie


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

Date: 23 Oct 1998 13:28:50 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Backgrounding long processes?
Message-Id: <70q0ai$bpa$1@pegasus.csx.cam.ac.uk>

David Huggins-Daines  <bn711@freenet.carleton.ca> wrote:
>Here's how you can make sure the child won't ever die:
>
># fork once
>unless (fork()) {
>  # defensive programming
>  die "Can't fork: $!" if $!;
>
>  # in child process, fork again
>  exit 0 if fork();
>  die "Can't fork: $!" if $!;
>
>  # in child of child process - won't die when parent exits
>  exec ('/usr/bin/yes', "You can't kill rock 'n roll");
>}

Wrong.   $! is not set to 0 by a successful fork() (or any other system call).
It may be left unchanged, or set to an arbitrary value, depending on the
platform.   So you need to write that as

unless (my $pid = fork()) {
    die "Can't fork: $!" unless defined $pid;
[etc]


Mike Guy


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

Date: Fri, 23 Oct 1998 11:24:53 GMT
From: gbbrehm@erols.com (G Brehm)
Subject: bhtpasswd and database file
Message-Id: <36306191.2645780@news.erols.com>

I am making first attempt to utilize modules, HTTPD-Tools-0.55
specifically.

I have text file  w/ 3000+ (usernames,passwd) I need to get into
 .htaccess usable format.

perl bhtpasswd -t Text users
My hangup seems to be in "users" format, error:
add_user: no user name! at bhtpasswd line 29, <>chunk 1.

I have tried various schemes in setup of  "users" file with same
error.  I will overcome, but any tips might make less painful.

I'm sure there is something simple I am missing.  I am new to perl,
please be nice.

have a nice day...


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

Date: Fri, 23 Oct 1998 13:16:43 +0200
From: "J|rgen Ibelgaufts" <ibelgaufts@gfc-net.de>
Subject: Re: Guides
Message-Id: <3630659B.989328EA@gfc-net.de>

I recently found

http://www.codebits.com/p5be/ch20.cfm

it seems to contain almost everything of interest except Tk.

Hope this helps

juergen ibelgaufts

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

nrf@mailcity.com schrieb:
> 
> Where can I find a good beginners guide to perl in the internet?
> One that explains the several commands?
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own


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

Date: Fri, 23 Oct 1998 12:55:55 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: help shorten one-liner
Message-Id: <1dhcpyy.12hfg9s1vzuz0kN@host007-210.seicom.net>

Michael J Gebis <gebis@fee.ecn.purdue.edu> wrote:

> mjd@op.net (Mark-Jason Dominus) writes:
> 
> }In article <70nhrg$vsc$1@nnrp1.dejanews.com>,  <jkane@my-dejanews.com> wrote:
> }>> #!/usr/bin/perl -w
> }>> print "Something ";
> }>> =for nobody
> }>> Here is some POD style commenting, which
> }>> can throw your whole concept of commenting way over...
> }>> =cut
> }>> print "under the bed is drooling.";
> }>> __END__
> }>>
> }>I didn't realize you could comment in the middle of a statement.  
> 
> }You can't.  That's not in the middle of a statement.
> 
> Sure it is.  It's in the middle of a statement about the monster under
> the bed. ;)

Since I posted that snippet I feel sort of responsible for it.
It was meant as an example for other ways of commenting, the original
poster did not take into account. 
I posted an example for # - like comments within a /x - regex and that
POD style thing. It was not meant as an example for comments within any
kind of statement ;-)

Still, I feel the urge to post a slighly modified version of my example.
See below...

#!/usr/bin/perl -w

print "Something ";

=for nobody
Here is some POD style commenting, which
can throw the subject of this thread way over...
=cut

print "in this thread is trolling ;-)";
__END__

HANW,

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: Fri, 23 Oct 1998 12:53:35 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: how do  you add three variables
Message-Id: <36307A65.E6657156@shaw.wave.ca>

[posted & mailed]

Tad McClellan wrote:
> 
> Scratchie (upsetter@ziplink.net) wrote:
>
> : What happened when you tried it?
> 
>    WHWYTI
> 
>    I'd seen that occasionally in the past.
> 
>    Someone (who was that anyway?) suggested that it be an
>    "official acronym" within the last ten days or so.

That would be me, Mr. Someone.
 
>    I've seen occasions for its use more frequently since then.
> 
>    I vote for official status too (and fame for the coiner).

While I can't take credit for the phrase (indeed, I believe I have seen
it in posts of yours many times), I will not turn down accreditation as
the Official WHWYTI Acronym Coiner (OWHWYTIAC).
 
Perhaps I should add it to my .sig?

-- 
Rick Delaney, OWHWYTIAC (just trying it out--not official yet)
rick.delaney@shaw.wave.ca


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

Date: Fri, 23 Oct 1998 12:31:22 GMT
From: c960901@student.dtu.dk
Subject: How do I check input to CGI?
Message-Id: <70psuq$7v3$1@nnrp1.dejanews.com>

Hi

I've written a small CGI script, but for some reason it doesn't behave
like it should. It recieves info from an applet and is supposed to
write that to a file. How do I check if it get's the info it's
supposed to? If I print the $buffer to a file just after the read(STDIN...
I get some text like

Pragma: no-cache
Host: www.capec.kt.dtu.dk
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
Accept-Language: en
Accept-Charset: iso-8859-1,*,utf-8

f-8

And that's it. To me (a -novice-) it seems that the connection from the
applet to the CGI was broken, or am I wrong in assuming this? Am I
missing a flush or something? Any help would be greatly appreciated.

Morten

The script is as follows:

#!/opt/internet/bin/perl
#!/usr/bin/perl -w

$write_base = "sys:/novonyx/suitespot/docs/capec/docs/capecnews/structure/";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/~!/ ~!/g;
    $FORM{$name} = $value;
}

$out_file = $write_base.$FORM{'directory'}.$FORM{'filename'}.".html";

open(OUT,">>$out_file") || die "Error: $out_file $1";
print OUT $FORM{'string'};
close(OUT);
exit 0;

For those who are interested, a snippet of the applet code is below:

URL homeURL = new URL("http://popeye.kt.dtu.dk/perl/write_entry.pl");
URLConnection connectDTU = homeURL.openConnection();
connectDTU.setDoOutput(true);

PrintWriter out = new PrintWriter(connectDTU.getOutputStream());

out.println("directory="+currPath+"&filename="+currDate+"&string="+myMsg);
out.flush();
out.close();

BufferedReader in = new BufferedReader(
     new InputStreamReader(connectDTU.getInputStream())
     );

while (in.readLine() != null);
in.close();

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 23 Oct 1998 13:00:09 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: How do I check input to CGI?
Message-Id: <909147530.81698@thrush.omix.com>

c960901@student.dtu.dk wrote:
: I've written a small CGI script, but for some reason it doesn't behave
: like it should. It recieves info from an applet and is supposed to
: write that to a file. How do I check if it get's the info it's
: supposed to? If I print the $buffer to a file just after the read(STDIN...
	>snip<
:     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	>snip<

	Don't do this.

	Run, don't walk to the CGI.pm module.  If you really want to
	get fancy, you might even want to take a look at my CGI::Validate
	module.

	Good luck!

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Fri, 23 Oct 1998 11:09:25 +0100
From: "Derren Weekes" <weekesd@logica.com>
Subject: Re: how to use CGI to download
Message-Id: <70pkkh$dma@romeo.logica.co.uk>

How about sending the following:

<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="1; URL=file.zip">
<title>Download Page</title>
</head>
<body bgcolor="#FFFFFF">
If the file does not download automatically then click <a
href="file.zip">here</a>
</body>
</html>

This should start the download 1 second after the page has loaded, if the
"refresh" meta tag is not supported by the browser, then it still has the
old manual "click here" method to fall back on.


>Ucalegon <eyebeam@unexpected.com> writes:
>
>>Is there any way within a perl program running on the web to download a
>>file to the user's machine?  If not, is there any way more
>>straightforward than generating html that asks the user to click on a
>>link to do the download?






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

Date: 23 Oct 1998 13:05:08 GMT
From: tice@hunch.zk3.dec.com (Walter Tice USG)
Subject: Re: How to yield processor time?
Message-Id: <70puu4$n2r@zk2nws.zko.dec.com>

In article <362FFB22.43E22C84@att.net> Bernie <bfb@att.net> writes:
>Is there a way in perl to limit the amout of CPU usage
>a script uses?  I'm aware I can use nice, but was wondering
>if perl itself was capable of this.

>-Thanks

I don't recall ever reading that there is. Personally I'm always
trying to maximize the amount of server CPU I use! Although on
my own mangy box, nice -20 really does bog things down.

W
-- 
JAIPH (just another intermediate perl hacker)

"Do you want to go back to where I found you?
Friendless! Brainless! and unemployed,  in Greenland?" - Princess Bride


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

Date: Fri, 23 Oct 1998 12:29:35 GMT
From: cutebaby@my-dejanews.com
Subject: i just find a whatsnew cgi script
Message-Id: <70psrf$7l3$1@nnrp1.dejanews.com>

someboby have the whatsnew(new) perl cgi script

plz tell me whhere to get

, because my homepage need it

need your help ~

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 23 Oct 98 09:57:55 GMT
From: hjp@wsr.ac.at (Peter Holzer)
Subject: Re: Info on crypt()
Message-Id: <hjp.909136675@titan.wsr.ac.at>

bart.mediamind@ping.be (Bart Lateur) writes:

>I've tested it on the server of my ISP, and this is what I get:

>	print crypt("Hello, world!","aa");
>>>
>	$1$aa$vCNvcZW/VEIq04KqtIeQn1

>Uh-oh. Not too portable.

What is the result of

print crypt("Hello, world!", '$1$aa$vCNvcZW/VEIq04KqtIeQn1');

If it is $1$aa$vCNvcZW/VEIq04KqtIeQn1, you can still use crypt in the 
standard way:

    $cleartextpasswd = generate_random_passwd_or_ask_user();
    $encryptedpasswd = crypt($cleartextpasswd, random_2_char_salt());
    store_in_passwd_file($encryptedpasswd);


    $cleartextpasswd = get_passwd_from_user();
    $encryptedpasswd = read_passwd_from_passwd_file();
    $user_ok = ($encryptedpasswd eq crypt(cleartextpasswd, $encryptedpasswd));

>CRC-32 looks just as decent as crypt() 

Not really. CRC-32 is very easy to fake. For crypt (whether it uses DES
or MD5) you still need a lot of CPU power.

	hp


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

Date: 23 Oct 1998 14:14:27 +0200
From: Marius Kjeldahl <marius@odin.funcom.com>
Subject: Re: IO::Socket error - solution - solved again!
Message-Id: <52d87jo4po.fsf_-_@odin.funcom.com>

Marius Kjeldahl <marius@odin.funcom.com> writes:

> There is one minor issue, however. Even if I catch the error, I can
> still not get rid of the warning messages. An example from my log
> file:
> 
> Use of uninitialized value at /rdist/concept/usr/lib/perl5/
> 	5.00502/i686-linux/Socket.pm line 275, <GEN2> chunk 5.
> Fri Oct 23 11:53:16 1998| (peerhost error)| disconnect| forcing logout
> Use of uninitialized value at /rdist/concept/usr/lib/perl5/
> 	5.00502/i686-linux/Socket.pm line 275, <GEN2> chunk 5.
> Fri Oct 23 11:53:16 1998| (peerhost error)| logout| marius
> 
> I _only_ thing I really want to see in my log is:
> 
> Fri Oct 23 11:53:16 1998| (peerhost error)| disconnect| forcing logout
> Fri Oct 23 11:53:16 1998| (peerhost error)| logout| marius
> 
> Does anybody know how I can get rid of the warnings about the
> uninitialized value for this piece of code (I do not want to turn of
> -w and strict because they are very helpful in other places)?

I jumped the gun a bit too quickly. From man perlvar:

Certain internal hooks can be also set using the %SIG hash.  The
routine indicated by $SIG{__WARN__} is called when a warning message
is about to be printed.  The warning message is passed as the first
argument.  The presence of a __WARN__ hook causes the ordinary
printing of warnings to STDERR to be suppressed.  You can use this to
save warnings in a variable, or turn warnings into fatal errors, like
this:

	local $SIG{__WARN__} = sub { die $_[0] };
	eval $proggie;

This should solve the minor issue I had about the warnings.

Marius


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

Date: 23 Oct 1998 14:07:42 +0200
From: Marius Kjeldahl <marius@odin.funcom.com>
Subject: Re: IO::Socket error - solution!
Message-Id: <52g1cfo50x.fsf@odin.funcom.com>

(original posting included at the end of this posting)

Through the help of a couple of people, I've been able to isolate the
bug. The bug is triggered through a call to the IO::Socket::peerhost
method. However, the difficult part was to isolate exactly _when_ this 
happens.

Some guesswork and a lot of trial and error showed me that the error
was triggered when a Windows client (the application in question has
both windows and linux clients) disconnected abnormally (like if you
force it to exit abnormally by selecting End task in the task
manager), but not if the application was shut down in a "normal" way
(selecting quit or closing the main window).

The solution was to isolate the call in an eval {} block (perl
exception handling), and I can now catch these errors and ignore them
instead of having my server process exiting.

There is one minor issue, however. Even if I catch the error, I can
still not get rid of the warning messages. An example from my log
file:

Use of uninitialized value at /rdist/concept/usr/lib/perl5/
	5.00502/i686-linux/Socket.pm line 275, <GEN2> chunk 5.
Fri Oct 23 11:53:16 1998| (peerhost error)| disconnect| forcing logout
Use of uninitialized value at /rdist/concept/usr/lib/perl5/
	5.00502/i686-linux/Socket.pm line 275, <GEN2> chunk 5.
Fri Oct 23 11:53:16 1998| (peerhost error)| logout| marius

I _only_ thing I really want to see in my log is:

Fri Oct 23 11:53:16 1998| (peerhost error)| disconnect| forcing logout
Fri Oct 23 11:53:16 1998| (peerhost error)| logout| marius

Does anybody know how I can get rid of the warnings about the
uninitialized value for this piece of code (I do not want to turn of
-w and strict because they are very helpful in other places)?

Thanks in advance,

Marius

Marius Kjeldahl <marius@odin.funcom.com> writes:

> I've got a perl based server process which accepts connection from
> clients. However, in some cases the server process dies (I have not
> been able to get this to happen when I control the clients, but when
> some of my external users connect/disconnect it triggers the error). From the log, the following error message is generated.
> 
> Does anybody have a clue on what is going on, and how I can avoid the
> error from being triggered?
> 
> Sun Oct 18 05:48:16 1998| xxxxxxxxxxxxxx| new connection
> Sun Oct 18 05:48:18 1998| xxxxxxxxxxxxxx| disconnect| forcing logout
> Use of uninitialized value at /usr/lib/perl5/i386-linux/5.00404/Socket.pm line 249, <GEN11> chunk 1.
> Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16 at /usr/lib/perl5/i386-linux/5.00404/Socket.pm line 249, <GEN11> chunk 1.
> 
> Marius


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

Date: Fri, 23 Oct 1998 11:02:50 +0100
From: "Chris Lee" <lammie_pie@hotmail.com>
Subject: looking for a perl interpreter for NT
Message-Id: <909137877.23817.0.nnrp-10.c2de0366@news.demon.co.uk>

I need I perl interpreter for NT
does anyone one know where I can down load this??

chris




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

Date: Fri, 23 Oct 1998 13:26:19 +0100
From: "Derren Weekes" <weekesd@logica.com>
Subject: Re: looking for a perl interpreter for NT
Message-Id: <70psle$gqq@romeo.logica.co.uk>

http://www.activestate.com/ is a good place to try. Had a few problems
getting it to work with IIS4.0, but its working now.
---
Derren Weekes - weekesd@logica.com
Logica UK Ltd
Opinions expressed within this post are my own

Chris Lee wrote in message
<909137877.23817.0.nnrp-10.c2de0366@news.demon.co.uk>...
>I need I perl interpreter for NT
>does anyone one know where I can down load this??
>
>chris
>
>




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

Date: 23 Oct 1998 09:00:13 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: making a variable variable?
Message-Id: <70pukt$7a7$1@monet.op.net>

In article <362F24C7.30308F@harris.com>, PERL ROCKS! <emills@harris.com> wrote:
>Anyhow, it works pretty well, but I wouldn't apreciate having to debug
>this if someone else wrote it. I'd appreciate any comments on this
>approach, and would also appreciate any other approaches to this
>problem.

It looks to me like the most straightforward way to do it I don't see
how the problem I described in `varvarname' applies here.

If you wanted to get a little fancier, then perhaps copy the input
items into an array; this will be more efficient and may be easier to
understand:

	for ($i=1; $i <= $in{recs}; $i++) {
	  $sel[$i] = $in{"sel$i"};
	}

>I'm just curious about how other handle this problem., and if anyone
>figured out a practical way to derive a list from a table.

That's what I'd have done.



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

Date: Fri, 23 Oct 1998 12:55:57 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: PERL & simple flat file database???
Message-Id: <1dhcqq0.3r9qlc15b9p8gN@host007-210.seicom.net>

Mark Hurley <mph@pcola.gulf.net> wrote:

> I've attached the file for viewing purposes.

Save yourself a lot of flames and the other readers bandwidth and time,
by _not_ attaching files to newsgroup posts.
If you have code to post, please do that in _plaintext_, not UUencoded.

Thanks,

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: 23 Oct 1998 09:40:14 -400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <ltpvbjcs75.fsf@asfast.com>

Randal Schwartz <merlyn@stonehenge.com> writes:

> >>>>> "finsol" == finsol  <finsol@ts.co.nz> writes:
> 
> finsol> In your expert opinion: Would you recommend that Perl
> finsol> applications be checked for Year 2000 problems?
> 
> Only in the same sense that *all* applications be check for such
> problems.  Do not single out "Perl" being the fault.  There is *no*
> language that is immune from potential Y2K problems.

I think that you are mis-interpreting Jocelyn Amon's (finsol's)
statement.  I don't see anywhere in her quoted statement, nor in any
of the other statements she made in the post you are quoting or any of
her other previous posts, where she is trying to single out Perl, or
even trying to assign fault or blame.

I believe that a fair and accurate rephrasing of her question that you
quoted here would be this: "In your expert opinion, are Perl programs
*less* prone to Y2K problems than programs written in other languages,
and would you therefore recommend that people spend any *less* time
and effort checking their Perl applications for Y2K problems than 
applications in any other languages?"

I trust that your answer would be "No" to both of these questions, and
in giving this answer, I believe that you would be in no way trying to
single out Perl or to assign any kind of fault or blame ... no more
than Jocelyn Amon appears to be doing in her posts.

> So, delete the word "Perl" there, and I'll agree with you.

Given your apparent mis-interpretation of Jocelyn Anon's intent, it
looks to me like you and she are already in agreement, without her
having to change any of her wording.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'


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

Date: Fri, 23 Oct 1998 04:44:06 +0000
From: "Xah" <xah@best.com>
Subject: programing fun: nested array...
Message-Id: <36306aa1$0$6380@nntp1.ba.best.com>

I just finished writing a cool function. This problem has an academic taste, so I thought someone here would enjoy seeing it. I'd be delighted to see comments or codes from Perl gurus.

Problem explanation and code attached below.

 Xah, xah@best.com
 http://www.best.com/~xah/PageTwo_dir/more.html
 perl5 -e'print"%^*(\@#! just another very ^}@&(!% obfuscated hacker\n"'


#_____ Dimensions _____ _____ _____ _____

=pod

B<Dimensions>

Dimensions(tree) returns a reference to a list [n_1, n_2, ..., n_i, ...] where every node at ith level of the given tree has n_(i+1) children. For example, [[['a'],['b'],['c']],[[1],[2],[3]]] has dimensions [2,3,1]. In other words, Dimensions returns a list of m items if the argument is an m-dimentional (rectangular) array.

Related: Depth, NonleafCount, LeafCount, NodeCount.

Example:

 Dimensions([]); # returns [].
 
 Dimensions([5,98,'x']); # returns [3].

 Dimensions([['a','b','c'],[1,2,3]]); # returns [2,3].

 Dimensions([[['a'],['b'],['c']],[[1],[2],[3]]]); # returns [2,3,1].

 Dimensions([['a','b','c'],[1,2]]); # returns [2].

=cut

# implementation note:
# general plan: set up three variables and have a recursor subroutine to do a loop, for each loop travel all nodes at a level. If successful, then reset the variables , then loop the next level, so on until one of the node contain atoms or one of the nodes fails to have the same number of children as other nodes. (dimensions essentially means every node at the same level must have the same number of children.)
# @result is the result dimensions.
# @nodesOfSameLevel is the nodes of a level. At the beginning, it is level 0 consisting of just the root.
# $numberOfChild = is the number of child of a node. Whenever the number of child of a node differ from this, then the loop is aborted.;

# Dependent functions: (none).

push (@EXPORT, q(Dimensions));
push (@EXPORT_OK, q(Dimensions));

sub Dimensions ($) {
if (ref $_[0] and (scalar @{$_[0]} == 0)) {return [];};
# do other input arg check here...
return _dimensions($_[0]);
};

sub _dimensions ($) {
my @indexList = @{$_[0]};

my @result = ();
my @nodesOfSameLevel = (\@indexList);
my $numberOfChild = scalar @{$nodesOfSameLevel[0]};

# $recurser is a subroutine that does not take arguments. It updates three variables outside of it, and calls itself until it abort itself when appropriate.
my $ref_recursor;
 $ref_recursor = sub {
  my $failed = 0;
  EQUALCHILDCHECK: foreach my $ref_child (@nodesOfSameLevel)
  {if ((not ref $ref_child) or $numberOfChild != scalar @{$ref_child})
  {$failed = 1; last EQUALCHILDCHECK;};};
 
  if ($failed) {return;} else {
  #set a slot of the result
  push( @result, $numberOfChild);
  
  # reset new @nodesOfSameLevel for next level recurse.
  for (my $i = $#nodesOfSameLevel; $i >= 0; $i--)
  {splice(@nodesOfSameLevel, $i, 1, @{$nodesOfSameLevel[$i]});};
  
  # reset numberOfChild for next level recurse
  if (not ref $nodesOfSameLevel[0]) {return;};
  $numberOfChild = scalar @{$nodesOfSameLevel[0]};
  
  &$ref_recursor;
  };
 };

&$ref_recursor;
return \@result;
};


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

Date: 23 Oct 1998 09:50:25 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: programing fun: nested array...
Message-Id: <70q1j1$1gp$1@pilot.njin.net>

Hello -

"Xah" <xah@best.com> writes:

>I just finished writing a cool function. This problem has an academic taste, so I thought someone here would enjoy seeing it. I'd be delighted to see comments or codes from Perl gurus.

Assuming that sub-guru comments are also welcome - here's a somewhat terser
rewrite (yes, I do enjoy seeing things like this and playing around with
them :-)

#!/usr/local/bin/perl -w

use strict;

print map { @$_ && "@$_\n" || "[null]\n" }
   dimens([]),                                  # returns [].
   dimens([5,98,'x']),                          # returns [3].
   dimens([['a','b','c'],[1,2,3]]),             # returns [2,3].
   dimens([[['a'],['b'],['c']],[[1],[2],[3]]]), # returns [2,3,1].
   dimens([['a','b','c'],[1,2]]);               # returns [2].

sub dimens {
   my @result = ();
   my $dsub;
   $dsub = sub {
      my ($f, @sibs) = @_;
      return unless ref $f eq 'ARRAY' && scalar @$f;
      &$dsub(@$f);
      unshift @result, scalar @$f
         unless grep { scalar @$_ != scalar @$f } @sibs;
   };
   &$dsub;
   return \@result;
}


David Black
dblack@pilot.njin.net


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

Date: 23 Oct 1998 11:31:33 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Rounding Problem
Message-Id: <70ppel$770$1@pegasus.csx.cam.ac.uk>

Drew <andrew.simpson@matcomcorp.com> wrote:
>
>I am having trouble rounding certain numbers.
>Originally I used sprintf to do the rounding, but
>when
>
>$var = 0.325;
>$rslt = sprintf("%.3f",$var);
>
>resulted in 0.324, I delved into all the FAQs,
>Perl sites, etc. and discovered that 0.325
>is stored as 0.32499999 --> to 20 places?
>When rounded it obviously becomes 0.324.

Nope.   When rounded it's 0.325.   And a correctly functioning sprintf()
rounds, not truncates.    When I try

    % perl -e '$x = 0.3249999; printf "%.3f\n", $x'

I get the result 0.325.    If you get something different, your Perl is
broken.


Mike Guy


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

Date: Fri, 23 Oct 1998 07:51:00 -0400
From: Tom Lynch <toml@synnet.com>
Subject: Using percent (%) in printf issue
Message-Id: <36306DA4.24B3E72@synnet.com>

Greetings:

I have run into a problem here when trying to
use "%" in a printf statement. When I have the "-w"
switch I get:

Invalid conversion in printf: "%" at ./foo line 28.

Here's the offending code:

printf "%s occured %d which is %3.2f\%\n", $key, $hash{$key},
$percentage;

I don't understand this because I'm escaping the % sign.
I already have a couple of work arounds, but was curious
why this is happening even when I escape the %.

Thanks
  Tom

-- 
#--------------------------------------------------------------+
# Tom Lynch                 |  Email: toml@synnet.com          |
# Switching Division        |  Phone: (978)-264-1443           |
# 3COM Corporation          |  Fax  : (978)-264-1418           |
# 80 Central Street         |  MS   : MA#35                    |
# Boxborough, Massachusetts |  Zip  : 01719                    |
#--------------------------------------------------------------+


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

Date: 23 Oct 1998 08:23:36 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Using percent (%) in printf issue
Message-Id: <70psg8$n2$1@pilot.njin.net>

Hello -

Tom Lynch <toml@synnet.com> writes:

>Greetings:

>I have run into a problem here when trying to
>use "%" in a printf statement. When I have the "-w"
>switch I get:

>Invalid conversion in printf: "%" at ./foo line 28.

Use %% to indicate a literal % in the format string.  (See
perldoc -f sprintf.)


David Black
dblack@pilot.njin.net



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

Date: 23 Oct 1998 14:24:11 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Using percent (%) in printf issue
Message-Id: <837lxrlb4k.fsf@vcpc.univie.ac.at>

Re: Using percent (%) in printf issue, Tom <toml@synnet.com>
said:

Tom> printf "%s occured %d which is %3.2f\%\n", $key,

(occurred)

Tom> $hash{$key}, $percentage;

Tom> I don't understand this because I'm escaping the %
Tom> sign.  I already have a couple of work arounds, but was
Tom> curious why this is happening even when I escape the %.

perldoc -f sprintf
    ...
    Perl's sprintf() permits the following universally-known conversions:
 
       %%   a percent sign

tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: 23 Oct 1998 12:26:29 GMT
From: udaa460@newt.kcl.ac.uk (Allan Hawdon)
Subject: Re: Using percent (%) in printf issue
Message-Id: <70psll$82$1@willow.cc.kcl.ac.uk>

Tom Lynch (toml@synnet.com) wrote:
: Greetings:

: I have run into a problem here when trying to
: use "%" in a printf statement. When I have the "-w"
: switch I get:

: Invalid conversion in printf: "%" at ./foo line 28.

: Here's the offending code:

: printf "%s occured %d which is %3.2f\%\n", $key, $hash{$key},
: $percentage;

"Escape" the % with itself, like so ...
 
printf "%s occured %d which is %3.2f%%\n", $key, $hash{$key},
$percentage;

Admittedly, the man page for printf is rather vague about this.

Allan


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

Date: Fri, 23 Oct 1998 14:37:49 +0100
From: Leon Brocard <l.brocard@elsevier.nl>
Subject: Re: VCS::CVS code announcement (provisional name)
Message-Id: <363086AD.E3197488@elsevier.nl>

Brad Appleton wrote:
> In article <362F6C97.33564823@elsevier.nl>,
>  Leon Brocard <l.brocard@elsevier.nl> writes:
> >NAME?
> >
> >There is currently another module named VCS::CVS, however it
> >is not in CPAN.
> It may not be on CPAN yet, but its a more mature version (meaning
> its been around longer and been tested longer). That doesn't
> mean yours is any worse, but it does seem horridly undesirable
> to have such duplicate effort. Why do you feel you need to replace
> the existing module rather than modify/patch it?

Software engineering (at least, good software engineering) is about
meaningful abstraction. An OO interface that does not do this is not
worth using.

One also wonders why the (mature?) pre-existing VCS::CVS hasn't 
made it into CPAN...

> >This module is intended to provide a superset of
> >the methods provided by that, and be much more userfriendly and
> >OO and shield the user from nasty low-level CVS stuff.
> Being O-O isn't necessarily better (though I certainly like O-O).
> There was a rampant debate on this at the 2nd Perl conference.
> In Perl, all those method calls via references can be a large
> drag on performance. Are you quite certain it truly benefits from
> being O-O? Is it possible to have both a non-OO and OO interface
> to the same functionality??

This comes down to the tradeoff between using perl (high-level) and
assembler (low-level, but greater possible performance). If ease of
programming is gained, then the price is worth it.

> [snip]
> >I'd like to cooperate with VCS::RCS and VCS::PVCS ppl to see if we
> >can use similar APIs...
> Why is the existing VCS::CVS author(s) not included in the above?
> Is there are REALLY GOOD reason why you can't work together? I for
> one would rather see you both working together on added functionality
> rather than competing with each other.
> 
> Not that I'm against your module, but I'm inclined to look *very* long
> and *very* hard before being convinced that supplanting existing
> implementation is truly called for. I just want to be sure you've
> done the same.

This is in fact the case. There is definitely scope for using the ideas
of the older module, filling in the gaps in functionality in the newer
one, specifically, the adding and removing functionality. These gaps
would be filled with two new methods in the three classes: "create_new"
and "remove".

Please take a look at both APIs, Brad, and see which one you think is
more idiomatic. I feel that the existing wheel is square :-)

Leon
-- 
Leon Brocard...............................................Perl Hacker
l.brocard@elsevier.nl...........................http://www.astray.com/

 ... Tilt your chair back, your breath is effecting my RAM!


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4053
**************************************

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