[12748] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 158 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 15 19:07:19 1999

Date: Thu, 15 Jul 1999 16:05:10 -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, 15 Jul 1999     Volume: 9 Number: 158

Today's topics:
    Re: Can I do this? (Anno Siegel)
    Re: deep recursion <tobez@plab.ku.dk>
    Re: Getting the debugger to break at a warning (Ilya Zakharevich)
    Re: Help with a simple socket question... (Anno Siegel)
    Re: how do i convert a integer to string. <dhenders@cpsgroup.com>
        How to combine two images. <zigor@erols.com>
    Re: how to get command line filename argument back? <prlawrence@lehigh.edu>
        Installing Modules Locally Help!!! (Jonathan Chum)
    Re: long explanations wearying (was Re: Top 10 response <mats.pettersson@falukuriren.se>
    Re: My Foot Hurts <ansok@mickey.cptca.trw.com>
    Re: Old database is erased when I add new information (John Stanley)
    Re: Old database is erased when I add new information (John Stanley)
        Perl before Swine? <burton@lucent.com>
    Re: Perl Wrapper (Anno Siegel)
    Re: Perlscript calling VBScript function <jerrad@networkengines.com>
    Re: Perlscript calling VBScript function <jerrad@networkengines.com>
        plist parsing <delft@delftware.nl>
        Tcl-to-Perl translator? (Larry Rosler)
    Re: Tiny error in perlfaq5 <tchrist@mox.perl.com>
    Re: Tiny error in perlfaq5 <thoren@csi.com>
    Re: Tiny error in perlfaq5 (John Stanley)
    Re: Tiny error in perlfaq5 <tchrist@mox.perl.com>
    Re: Tiny error in perlfaq5 (John Stanley)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 15 Jul 1999 22:30:58 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Can I do this?
Message-Id: <7mlnf2$g9v$1@lublin.zrz.tu-berlin.de>

Joan Richards  <richj@home.com> wrote in comp.lang.perl.misc:
>That's cool!!!  Do you happen to know if there is something that will give me
>output similar to the "netstat -in" and "vmstat"?

Look, he mentioned CPAN for a reason.  Why don't you go look for
yourself?

Also, please place your reply below what you're replying to.  The
other way 'round is hard to read and even harder to follow up.

Anno

>Andrew Allen wrote:
>
>> Joan Richards (richj@home.com) wrote:
>> : So, in a nutshell, how can I access (through perl) the data structures
>> : or whatever that keeps the information for the 'df' command and use them
>> : in my own proggie?
>>
>> A cursory glance at the CPAN module list
>>
>>   http://www.perl.com/modules/00modlist.long.html
>>
>> reveals:
>>
>>   File::Df
>>   Filesys::Df
>>   Filesys::DiskFree
>>
>> which appears useful.
>>
>> Andrew
>




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

Date: Thu, 15 Jul 1999 22:27:53 +0200
From: Anton Berezin <tobez@plab.ku.dk>
Subject: Re: deep recursion
Message-Id: <19990715222753.C2302@lion.plab.ku.dk>

On Thu, Jul 15, 1999 at 01:29:31AM -0400, Mark Rogaski wrote:
> How deep does recursion have to go before Perl carps about deep
> recursion?  Is there a hard limit, and can this limit be manipulated?

$ cd src/perl
$ grep -i "deep rec" *.c
$ more pp_hot.c

The answer is 100.

-- 
Anton Berezin <tobez@plab.ku.dk>
The Protein Laboratory, University of Copenhagen


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

Date: 15 Jul 1999 21:59:39 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Getting the debugger to break at a warning
Message-Id: <7mllkb$snn$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Luc St-Louis 
<lucs@cam.org>],
who wrote in article <m3lnci5c8s.fsf@haydn.lucs.org>:
> Some code I'm running (not mine), generates a lot of "Use of
> uninitialized value at ...". How difficult would it be to set up
> things so that the debugger would automatically break when reaching
> the lines that cause those warnings to be emitted?

Why not set up SIG{__WARN__} handler and create a breakpoint there?
Make sure you disable debugger's handler via PERLDB_OPTS.

Ilya


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

Date: 15 Jul 1999 22:13:06 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help with a simple socket question...
Message-Id: <7mlmdi$g7c$1@lublin.zrz.tu-berlin.de>

 <scott@sboss.net> wrote in comp.lang.perl.misc:

>Hello,
>
>I have been looking the Programming Perl, Adv. Programming Perl, & Perl
>Cookbook, and did not find my answer.

So what makes you think your question is simple?
 
>                                      I want to write a simple deamon
>that starts up, opens a unix socket, as it runs, writes to the socket.
>I do not want to wait for a connection to that socket to start writing
>to it.  I want to start processing the data and write to it immediately.

So what's keeping you?  My guess is, you can write to a socket until
you fill all buffer space, then you block.

> Meanwhile I will have multiple other programs at time connecting to
>that socket to read what is comming across it.

With your approach you will probably have no control over which client
gets to read what.  That may be the reason why all the example servers
you found in those books wait until they can accept() a client before
they begin to talk.

>                                                If you could point me in
>the right direction, or some code, it would be great.

My impression is, you will have to analyze your problem some more
before the direction you want to be pointed to becomes clearer.
Offering code at this stage is out of the question.  It is also
not the purpose of this newsgroup.

>Thanks
>Scott
>
>PS>  Here is the description of what I am trying to do.

Oh, a table.  Now things must become clear!

>Server A             Server A              Client B         Client A
>
>PollingD             InfoD                 ClientT          ClientU
>
>pings servers        reads from            connects to      same as
>& writes output      UNIX socket           TCP socket       Client B
>to UNIX Socket       whenever a            on Server A      except it
>                     client connects       to read data     reads the
>                     to it.                from it to       data from a
>                                           parse.           local UNIX
>                                                            socket.

Hmmm... Two columns are headed "Server A".  Does that mean there are
two processes working together to be one server?  But one of them
(additionally marked "InfoD") seems to read what the other (marked
"PollingD") writes.  Looks like Server A (InfoD) is really a client
of Server A (PollingD).  Let's see what the Clients do.  Client B
connects to TCP socket on server A... But wait, none of the two
Servers A writes to a TCP socket.  Client B seems to be out of luck,
but there is still Client A, which reads from a UNIX socket.  But
that's what Server A does too.  Are they using the same socket?
Different ones?

Nahh, the table doesn't do much to clear things up.

More seriously, I think much of the confusion comes from the fact
you are trying to keep local and remote connections apart, more
than they have to be.  Since you seem to need at least one TCP
connection, consider forgetting about UNIX sockets and work with
TCP only.  They connect just fine, at a little cost in overhead,
even if server and client happen to run on the same machine.  That
may help to make the design more manageable.

Anno


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

Date: Thu, 15 Jul 1999 21:21:56 GMT
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: how do i convert a integer to string.
Message-Id: <7mljd7$s1r$1@nnrp1.deja.com>

In article <7mg4kg$scg$1@nnrp1.deja.com>,
  cramey@my-deja.com wrote:
> i want to convert an integer
>
> specifically
>
> 1111111 to a string with
>
> str[0] == 1
> .
> .
> .
> str[6] == 1
>
> is there an easy way to do this ?
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>
(newsfeed is on the fritz, posting from dejanews)
you might try this. It does almost exactly what you ask.


#!/usr/bin/perl
$num=shift;
$len=int((log($num))/ (log (10)));
$str=" "x$len;
while ($num >0){
    $digit=$num%10;
    substr($str, $len,1)=sprintf("%d",$digit);
    $num=int($num/10);
    $len--;
}

print $str;

--
Dale Henderson <mailto:dhenders@cpsgroup.com>

"Imaginary universes are so much more beautiful
than this stupidly- constructed 'real' one..."  --


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 15 Jul 1999 17:57:22 -0400
From: "Igor" <zigor@erols.com>
Subject: How to combine two images.
Message-Id: <378e5946@news.inch.com>

I want using perl or something else to combine two images.

One is a background image and another is an object on one color background
that I want to put on the first image.
Has anybody done that before . thanks in advance. Igor.




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

Date: Thu, 15 Jul 1999 16:11:55 -0400
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Re: how to get command line filename argument back?
Message-Id: <7mlfah$1omk@fidoii.cc.Lehigh.EDU>


Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote:

> The script I'm writing peruses a txt file, extracts the info needed and
> stores them to variables.  I now want to create a new file (same id as
> the txt file, given as argument on command line), with a different
> extension.
If you were able to open the original file, then you must already have the
filename to do this:
  open FILE, "<$filename" or die "screaming";
So why not just reuse $filename?  Tack on another extesion, split on the
period... whatever.

> After this statement I am ready to write the variables to file.  Any
> suggestions?  I have tried
> ($file = shift @ARGV);, but get no results (script freezes, dies)
How about you strip down the actual script so that it is short yet still
demonstrates your problem?  Then I could offer more detailed advice.


--
Phil R Lawrence
Lehigh University
Enterprise Systems Implementation
Programmer / Analyst
prlawrence@lehigh.edu     - work
prlawrence@planetall.com  - personal

--
until (!$self->{'plaid pants'}) { bless $self, $class }




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

Date: Thu, 15 Jul 1999 22:40:51 GMT
From: jchum@jps.net (Jonathan Chum)
Subject: Installing Modules Locally Help!!!
Message-Id: <378e632a.9265932@news.jps.net>

I have telnet access, but the ISP don't let users have access to the
root to install new modules. How can I install modules locally? How
can I setup my CGI scripts to access them?


Techdevelopers
http://www.techdevelopers.com
CGI, ASP, DHTML, FLASH, and more


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

Date: Thu, 15 Jul 1999 23:08:46 +0200
From: Mats Pettersson <mats.pettersson@falukuriren.se>
Subject: Re: long explanations wearying (was Re: Top 10 responses)
Message-Id: <378E4DDE.D2905C11@falukuriren.se>

andy barfoot wrote:

> Of course, if you disagree, you can always start writing those long
> explanations yourself.  Maybe you're right, and the character of the
> group will change for the better.
> 

Why not split perl.misc to three groups like:

perl.newbie
perl.professional
perl.cgi

?

Tom can post the FAQs to perl.newbie & perl.cgi. And perl.professional
is for the gurus (i recon they don't need FAQs :).

Mats


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

Date: 15 Jul 1999 14:06:45 -0700
From: Gary Ansok <ansok@mickey.cptca.trw.com>
Subject: Re: My Foot Hurts
Message-Id: <x57lo1aahm.fsf@mickey.cptca.trw.com>

Don Coyote <Coyote@shambolica.freeserve.co.uk> writes:

> My left foot hurts, I've read the FAQ and tried switches -t & -w but
> nothing seems to work.
> 
> BTW, I did buy a cheap pair of shoes a few days ago and have done a lot
> of walking in them but I can't see how that relates to Perl?

Try the -e (wide width) switch.  If that's not wide enough, use the 
/ee modifier.

If only your left foot needs a wide shoe, try -l and -e together.

(See also mjd's Perl IAQ list, http://www.plover.com/~mjd/perl/IAQ/ ).

-- Gary


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

Date: 15 Jul 1999 21:09:46 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Old database is erased when I add new information
Message-Id: <7mlimq$1mp$1@news.NERO.NET>

In article <7mldgo$t7s$0@216.39.141.200>, Neko <tgy@chocobo.org> wrote:
>On 15 Jul 1999 16:21:51 GMT, stanley@skyking.OCE.ORST.EDU (John Stanley)
>wrote:
>>Yes, perhaps, but unfortunately the person who can do that is much less
>>likely to go around the net announcing his praise for you than the idiot
>>who "fixes" your code and calls you unethical because you won't fix it
>>for him. 
>
>Larry Wall's reputation is not enhanced because porters such as Chip and
>Sarathy go around praising him for writing Perl.  

If you don't understand what "less likely" means, I will be happy to
explain it to you. Yes, some people spend their time passing out praise.
Most users do not talk to you unless there is a problem.

>Imagine where Perl would be today if Larry had hidden the source for fear
>that someone might look under the hood -- edit, edit, edit -- and then rail
>against him because Perl is broken.

Imagine where you would be if the source code for the X-ray machine in
your doctor's office had been modified by the medical transcriptionist
and you had gotten overdosed on your last X-ray.

The argument that everything must be open source because for some things
it worked well is ridiculous. That is exactly what you are arguing when
you use perl as an example of how well open source works.  Nobody is
telling you not to give away whatever source you want to. Grant the
right to make the decision to other people.

>>Ummm, no actually it isn't. It takes me much less time to be told of a
>>bug and fix it myself than to try incorporating changes made by someone
>>else. 
>
>Most bug reports look like this:
>
>  "Your program corrupts my file.  Can you fix it?"

And you start working on the problem with just that pitiful report? I
don't waste time trying to decipher that kind of report, and I suspect
that you really wouldn't, either. 

>Most patches pinpoint the problem.  

And many patches conflict with other patches and the current code.

>Would you rather that these two people had simply sent in feature requests?

In the long run, it would have taken less time. It would mean that I can
properly document the features, and not have to worry that my next
release will lack a feature that they added without bothering to mention
it. 

>  "I want you to add features A, B, C and X, Y Z.  Thank you."
>
>That's pretty much what they've done, except they've also included examples
>of the features actually implemented!  

Which will take longer to put into the master version of the code than
if I had implemented it myself. I don't need examples of the features
actually implemented. In one case I had provided the code examples to
the user. In the other, it is a case of the proper selection of
parameters, which are listed in the documentation.

>If you don't want to merge their code
>with yours, you can still write it all from scratch.  No harm done.  No time
>wasted.

And just how do I verify that my version is compatible with theirs
unless I study what they have done?

>If you have version control, how did you end up with multiple versions?  Oh,
>wait, you only have one version.  

Ummm, I have version control. I guess you missed the part about how THEY
were changing their copy of the code. 

>Your two users have forked off entirely different programs.  

No, not entirely different programs. Not unless you count every
modification to a system as an entirely new system. I don't.

>If you want all the credit, you do all the hard work yourself.  If you're
>lazy, you get other people to do all the hard work for you.  You convince
>them to send you patches.  

And then you get the fun of merging everything back into one. It takes
time either way. Claiming that people who patch their copies of your
code for you saves you time is wrong.

>And when a bug is fixed, everyone can apply the
>patch right there and then.  They don't have to wait for a free update.

This is even more wonderful a situation. Now not only will all your
users need to communicate with each other, they will all have to apply
patches when someone else creates one, even if that patch doesn't effect
them and even if it breaks something they want to use. How much time do
I have to waste doing all this coordination instead of just fixing the
code myself?

>Hiding the source just keeps other programmers from helping you.  

Except it isn't always a help. And it keeps non-programmers from hurting me. 
In the case I am using as an example, the damage is limited because I
have been keeping in contact with them and know what they are doing. If
this were a typical commercial release, I wouldn't know who most of the
users were, much less how good at programming they are, and they would
not have consulted with me about the best way to implement what they
want.

>stop the lusers -- they can just as easily corrupt a compiled program and
>call you names for allowing such a thing to happen.

Most lusers are smart enough to know they can't edit a binary with the
text editor they have. The number of lusers who are not that smart are
not worth worrying about.



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

Date: 15 Jul 1999 21:20:57 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Old database is erased when I add new information
Message-Id: <7mljbp$21r$1@news.NERO.NET>

In article <19990715141346.18215.00000427@ng-fj1.aol.com>,
Perulinks <perulinks@aol.com> wrote:
>If you would just read my first posting, you could see that I spent just two or
>three lines mentioning that the author was unable or unwilling to answer my
>emails.  

And you have yet to prove this claim. He might not know of your email.

>I believe I mentioned too phone calls somewhere.  I spent a lot of
>time talking about the technical aspect of the problem. I just wanted some
>clues, that is why I didn't paste the whole code (which is very long).  

You didn't paste any code. You wanted fixes for code that nobody could
see.

>Some of
>you focused in the negative, non-technical aspect of the problem 

That's how USENET works. Your article brought up an issue that you
didn't directly address, so now we are talking about that. 

>But again, you chose to focus in that narrow, negative aspect of the message
>instead of answering the central, main topic.

Since you didn't post any code to debug, it is hard to tell you what is
wrong with your code. I think someone already mentioned that to you.

>I would challenge you to tell that you your customers that you don't have an
>obligation to sell a code that doesn't work 100% well (that is, some functions
>work perfectly well and some don't).  

Please refer to the licensing on any Microsoft product. In fact, on
almost every piece of software. 

>I would challenge you to call them
>"idiots" just because they can't program.  

Why would I want to do that? What does this have to do with anything?

>I would like to see if they would ever buy from you. 

If you want to conduct this experiment, I suggest you put your money
where your mouth is and do it yourself.

>One small advise, don't get so upset when you answer messages. 

Who was it who just lectured me about jumping to conclusions?



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

Date: Thu, 15 Jul 1999 15:51:58 -0400
From: Burton Kent <burton@lucent.com>
Subject: Perl before Swine?
Message-Id: <378E3BDE.1AA8CE34@lucent.com>

How do I make Perl grab/conserve all the memory it can?	
My program needs a lot more memory for recursion...

Burton


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

Date: 15 Jul 1999 22:46:17 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl Wrapper
Message-Id: <7mlobp$gbp$1@lublin.zrz.tu-berlin.de>

Jeff Pitman <jpitman@novell.com> wrote in comp.lang.perl.misc:
>I'm trying to create a perl wrapper that will execute scripts in different
>directories depending on how and when it is called.  My wrapper initializes
>a dozen variables in a particular namespace that I want called-scripts to
>have access to.  Currently this is how I'm doing it:
>
>{Initialize Namespace}
>$ScriptDir="$ENV{HTTP_HOST}/";
>
>require "$in{SCRIPT}";

The quotes are unnecessary.

>But, require doesn't import the current variables into the subsequent file.

Perl variables you have defined before the require are visible in the
required script.  Variables that are defined in the required script
are visible after the require.  If by "namespace" you mean the variables
are in some package, they will of course also be in that package when
viewed from the other file.  If you want something more sophisticated,
look at perldoc -q 'create a module'.

Anno


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

Date: Thu, 15 Jul 1999 17:18:20 -0400
From: jerrad pierce <jerrad@networkengines.com>
Subject: Re: Perlscript calling VBScript function
Message-Id: <378E501C.334E15CC@networkengines.com>

$ScritpingNamespace->[functionname]();

(the s in space might be cap'd?)
kharimi@my-deja.com wrote:
> 
> gurus, geeks and nerds.....please scratch thy brains on this one.......
> 
> how do I make a call to a VBScript funstion/subroutine from Perlscript
> code??
> 
> - Karimi
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.


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

Date: Thu, 15 Jul 1999 17:18:14 -0400
From: jerrad pierce <jerrad@networkengines.com>
Subject: Re: Perlscript calling VBScript function
Message-Id: <378E5016.B94DDC1A@networkengines.com>

$ScritpingNamespace->[functionname]();

(the s in space might be cap'd?)
kharimi@my-deja.com wrote:
> 
> gurus, geeks and nerds.....please scratch thy brains on this one.......
> 
> how do I make a call to a VBScript funstion/subroutine from Perlscript
> code??
> 
> - Karimi
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.


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

Date: Fri, 16 Jul 1999 00:06:14 +0200
From: Andre van Delft <delft@delftware.nl>
Subject: plist parsing
Message-Id: <378E5B56.204DD310@delftware.nl>

# I need a parser for plists, i.e. lists with nested
# dictionaries (hashes) like
#
#     ( { text = "aString\n" ;
#         quote = "\"";
#         name = file.txt }
#     , { another = dictionary }
#     , { text = "last" }
#     )
#
# ( ... ) mark lists
# { ... } mark dictionaries
#
# Below my perl program to parse such plists, but
# I have a few questions.
#
# QUESTION 1:
# if this is the wheel reinvented, where is the original wheel?
#
# QUESTION 2:
# The functions parseList and parseDictionary
# hopefully return proper references to parsed
# lists and dictionaries (with a nested structure).
# Are they 100% OK?
#
# QUESTION 3:
# The main program attempts to print the parsed
# data structure assuming it is an list of hashes.
# which is the case for the input given above.
# How would a general set of functions look like
# to print the data structure with arbitrary nestings?
#
# Thanks in advance for your help.
# Program code below
# =========================================================
#! /usr/local/bin/perl -sw

use strict;

my $line = "";  # current line at input
my $lineNumber = 0; # currrent line number
my $token;      # one of ( ) { } = , ; name string EOF *unknown*
my $tokenValue; # for name and string

# strings should allow for backslash escapes: "abc" "de\n" "f\"g"

nextToken();
my $tree = parseList();
expectToken("EOF");

# assume $tree is a list of hashes;
# try to print it a bit...
for my $i (0 .. $#$tree)
{
  my $elt = $tree->[$i];
  print "{\n";
  for my $key (sort keys %$$elt)
  {
    print "  $key = $$elt->{$key} \n"
  }
  print "}\n";
}

# read the next line from the input
sub nextLine()
{
   if (!($line = <DATA>)) {return 0;}
   $lineNumber++;
   print "nextLine $lineNumber: $line";
   return $line;
}

# get the next token from the input
# sets $token, and in case of "string" or "name", also $tokenValue
sub nextToken()
{
   unless (defined $line) # needed; but don't know why...
   {
       $token = "EOF";
       return;
   }
   while ($line =~ /^\s*$/)
   {
       if (!nextLine())
       {
           $token = "EOF";
           return;
       }
   }
   my $simpleSymbols = "(){}=,;";
   if ($line =~ /^\s*/)                 {$line = $';}  # eat away
leading whitespace
   if ($line =~ /^([$simpleSymbols])/)  {$token = $1; $line = $';
return;}
   if ($line =~ /(^[^\s;,\}\)\"\']+)/)  {$token = "name"; $tokenValue =
$1; $line = $'; return;}
   if ($line =~ /^\"(([^\\]|\\.)*)\"/)
                                        {$token = "string"; $tokenValue
= $1; $line = $'; return;}
   $token = "*unknown token*";
   $tokenValue = $line;
}

# the given token should match $token; accept it
# else exit with error code
sub expectToken($)
{
   my $expectedToken = $_[0];
   if ($expectedToken ne $token)
   {
    print STDERR "Parse error in line $lineNumber near ${line}Got
\'$token\' expected \'$expectedToken\'\n";
    exit(8);
   }
   acceptToken();
}
# accept the current $token
sub acceptToken()
{
   nextToken();
}

# pars a list of format
# "()" or "( value )" or "( value , value )" etc
sub parseList()
{
   expectToken("(");
   my $retval = [];
   if ($token eq ")") {acceptToken(); return $retval;}

   while(1)
   {
      my $val = parseValue();
      push @$retval, $val;
      if ($token eq ")") {acceptToken(); return $retval;}
      expectToken(",");
   }
}

# parse a dictionary of format
# "{}" or "{ key = value }" or "{ key = value ; key = value }" etc
# $token should be "("
sub parseDictionary()
{
   expectToken("{");
   my $retval = {};
   if ($token eq "}") {acceptToken(); return \$retval;}

   while(1)
   {
      my $key = parseName();
      expectToken("=");
      my $val = parseValue();
      $retval->{$key} = $val;
      if ($token eq "}") {acceptToken(); return \$retval;}
      expectToken(";");
   }
}

# parse a value of format
# list or dictionary or "aString" or aName
# $token should be "{"
sub parseValue()
{
   if ($token eq "(")      {return parseList();}
   if ($token eq "{")      {return parseDictionary();}
   if ($token eq "string") {return parseString();}
   if ($token eq "name")   {return parseName();}
   expectToken("name");
}

# parse a string
# $token should be "string"
sub parseString()
{
   my $retval = $tokenValue;
   expectToken("string");
   return $retval;
}

# parse a name
# $token should be "name"
sub parseName()
{
   my $retval = $tokenValue;
   expectToken("name");
   return $retval;
}

__DATA__
     ( { text = "aString\n" ;
         quote = "\"";
         name = file.txt }
     , { another = dictionaryEntry }
     , { text = "last" }
     )




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

Date: Thu, 15 Jul 1999 14:04:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Tcl-to-Perl translator?
Message-Id: <MPG.11f7ecc1db631784989cdd@nntp.hpl.hp.com>

I am about to inherit a pile of Tcl code, whose primary purpose is to 
produce SQL.  (Tk isn't involved at all.)  Rather than learn Yet Another 
Language, I thought it might be best to translate the stuff into Perl, 
from which I can adapt, maintain and improve it.

I've done some net surfing, and haven't come up with anything.  The Tcl 
FAQ is not interested in such a subject, of course.  :-)

Does anyone have any experience, suggestions or code that they can 
share?
  
-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 15 Jul 1999 15:13:23 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Tiny error in perlfaq5
Message-Id: <378e4ef3@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    jobosw@unx.sas.com writes:
:Here's some information about my version of Perl.
:
:ksh> perl -V:randbits             
:randbits='15';

I think we've tracked it down:

    tchrist% perl -V:randbits
    randbits='48';

--tom
-- 
> (It's sorta like sed, but not.  It's sorta like awk, but not.  etc.)
  Guilty as charged.  Perl is happily ugly, and happily derivative.
		--Larry Wall in <1992Aug26.184221.29627@netlabs.com>


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

Date: Thu, 15 Jul 1999 23:21:15 +0200
From: "Thoren Johne" <thoren@csi.com>
Subject: Re: Tiny error in perlfaq5
Message-Id: <#idMSgwz#GA.247@nih2naad.prod2.compuserve.com>

Tom Christiansen <tchrist@mox.perl.com> wrote in message
news:378e3c4a@cs.colorado.edu...
> Sounds like you don't have enough randbits in the function you
> had perl use for its rand function.  I can't reproduce that.

for (0..5) {
 my $i = 0;
 for (0..100000) {
  my $test = rand(1000);
  ($i += 1) if $test == 0;
 }
 print "$i times ZERO within 100_001 iterations with rand... woops\n";
}

gives:
2 times ZERO within 100_001 iterations with rand... woops
1 times ZERO within 100_001 iterations with rand... woops
5 times ZERO within 100_001 iterations with rand... woops
3 times ZERO within 100_001 iterations with rand... woops
3 times ZERO within 100_001 iterations with rand... woops
2 times ZERO within 100_001 iterations with rand... woops

 ...
perl -v
This is perl, version 5.005_03 built for MSWin32-x86-object
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-1999, Larry Wall

Binary build 518 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 13:14:00 Jun 24 1999
 ...

so... activestate feature or bug? ;)

gruß
thoren

--
8#X










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

Date: 15 Jul 1999 21:38:55 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Tiny error in perlfaq5
Message-Id: <7mlkdf$2mt$1@news.NERO.NET>

In article <378e4ef3@cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> wrote:
>:ksh> perl -V:randbits             
>:randbits='15';
>
>I think we've tracked it down:
>
>    tchrist% perl -V:randbits
>    randbits='48';

Although pp.c will allow the use of a function other than the system
rand() function, Configure does not consider this. It tells the user
what it thinks the answer to "randbits" is based on using rand(). I'm
sure there must be a way to procide the appropriate -D option to the
build, but perhaps Configure should look for drand48 and use it if it
is there by default.



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

Date: 15 Jul 1999 15:39:59 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Tiny error in perlfaq5
Message-Id: <378e552f@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    "Thoren Johne" <thoren@csi.com> writes:
:perl -v
:This is perl, version 5.005_03 built for MSWin32-x86-object
:(with 1 registered patch, see perl -V for more detail)
:
:Binary build 518 provided by ActiveState Tool Corp.
:http://www.ActiveState.com
:Built 13:14:00 Jun 24 1999
:
:so... activestate feature or bug? ;)

Yes.

How many randbits?

--tom
-- 
You are the sponsor for the account andrew (Andrew Hume).


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

Date: 15 Jul 1999 21:42:44 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Tiny error in perlfaq5
Message-Id: <7mlkkk$2nr$1@news.NERO.NET>

In article <378e3c4a@cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> wrote:
>In comp.lang.perl.misc, 
>    jobosw@unx.sas.com writes:
>:So, what could be done to ensure that rand(1000) never returns 0?
>
>    rand(1000)||1

If the problem does not appear with a 48 bit "randbits", would you
achieve the same thing without doubling the likelyhood of getting 1
for the answer by doing:

	rand(1000) || rand(1000) || rand(1000); 

>Sounds like you don't have enough randbits in the function you
>had perl use for its rand function.  I can't reproduce that.

Yes, just let perl use the default rand funtion for a system with a 15
bit rand. If the default is a bad choice, then the default probably
ought to be changed.



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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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


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