[6316] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 938 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 13 08:07:18 1997

Date: Thu, 13 Feb 97 05:00:37 -0800
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, 13 Feb 1997     Volume: 7 Number: 938

Today's topics:
     Re: 'Programming perl'? Will it damage my health? (Mike Stok)
     1 + 1 = 3 ??? <chr@mediascape.de>
     Re: 1 + 1 = 3 ??? (Mike Stok)
     Re: [Q:] whitespace <roychri@total.net>
     Re: Appending to the top of a document... (Tad McClellan)
     Calling C from perl: help needed <frishman@mips.biochem.mpg.de>
     Re: Calling C from perl: help needed (Mike Stok)
     Re: DBfile verses no DBfile (Tad McClellan)
     Re: get a string from a line <flg@vhojd.skovde.se>
     Re: getting STDERR from `backtick_exec` <roychri@total.net>
     MAKE MONEY <ghennessy@greenapple.com>
     Re: Need help - just starting perl <robert@tnet.es>
     Perl instalation <robert@tnet.es>
     Perl NT DerosM@aramis.be
     Re: Perl rand() function on solaris SPARC <hammen@gothamcity.jsc.nasa.gov>
     Re: perl ulimit -c 0 ? <steveg@metrosol.demon.co.uk>
     Perl5 : Calling Parent Method <roychri@total.net>
     Re: read and write +> at the same time - HOW? <lnussat.mavila@eds.com>
     Re: read and write +> at the same time - HOW? <lnussat.mavila@eds.com>
     Re: REQ: Getting the amount of files in a certain direc (Tad McClellan)
     Solaris2.5 Perl 5 instalation robert@tnet.es
     Re: subtle (to me) RE problem <dbenhur@emarket.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 13 Feb 1997 11:44:36 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: 'Programming perl'? Will it damage my health?
Message-Id: <5duur4$il6@news-central.tiac.net>

In article <5dsko8$41g@mikemc.demon.co.uk>,
Michael A. McLennan <mike@mikemc.demon.co.uk> wrote:

>Having only the first edition of 'Pp' what does it contain, re 4.0x, that I
>should not learn, ignore, be wary of etc.  The FAQ details all the differences
>in detail but... I suppose what I would like is -

Pretty much everything about perl 4 is still applicable to perl 5, the
perltrap man or pod page has a "Perl4 to Perl5 Traps" section which
classifies the differences that might affect a programmer used to perl4.

>       Q.        "Perl 4 to Perl5. Child to Adult"
>                              Discuss.

Maybe teenager to middle aged soul would be better, some historical things
have been re-evaluated, it's a little slower to launch out of its
armchair, some internal stuff has turned into a paunch which hangs around
perl's middle and you are free not to use if you really dont't want to.
Maybe that's a tad unfair, on balance perl 5 is a huge step forward from
perl 4 beacuse of little things like mechanisms that allow OO technoiques
to be used and the ability to extend the language relatively easily.

>I imagine something like this is in the early part of the 2nd ed. Correct?

There is an up to date Overview of Perl at the beginning of the second
edition.  The book assumes perl 5 is the "normal" perl, an doesn';t dwell
much on 4, 3, 2 etc.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Thu, 13 Feb 1997 10:16:49 +0100
From: Christian Bruegmann <chr@mediascape.de>
Subject: 1 + 1 = 3 ???
Message-Id: <3302DC01.2963@mediascape.de>

this is the way my perl solves a small addition

[$g = 0; $p = 6.50;] <== Coming from a database - Doing a print makes me
sure of the content....

$g = $g + $p;

==> $g = 6.5000000005215406418

It just don't work only with this numbers....

Pleaese help my box to do a 1+1=2 !!!!

Christian


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

Date: 13 Feb 1997 12:10:57 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: 1 + 1 = 3 ???
Message-Id: <5dv0ch$keb@news-central.tiac.net>

In article <3302DC01.2963@mediascape.de>,
Christian Bruegmann  <chr@mediascape.de> wrote:
>this is the way my perl solves a small addition
>
>[$g = 0; $p = 6.50;] <== Coming from a database - Doing a print makes me
>sure of the content....
>
>$g = $g + $p;
>
>==> $g = 6.5000000005215406418

Which version of perl are you using?  You're seeing a manifestation of
the inaccuracies of converting a number stored in a binary floating point
format to a decimal format.  Perl's default output format is more
"reasonable" in perl 5.003_26 (which is, I hope, close to perl 5.004) so:

  DB<1> $g = 0; $p = 6.50;

  DB<2> $g = $g + $p;

  DB<3> print $g
6.5

If your perl prints 6.5000000005215406418 then you might want to look at
using sprintf to format your output explicitly which gives you more
control over the output format - altering $# is probably a bad idea as.

  DB<4> $g = sprintf '%.2f', $g

  DB<5> print $g
6.50

>Pleaese help my box to do a 1+1=2 !!!!

But remember, inside your computer is really thinking 1 + 1 = 10.

Using www.hotbot.com to search on

  floating point representation of real numbers

turned up (off one of the pages returned) this link
http://www.geog.ubc.ca/numeric/labs/lab2/lab2/node23.html#lab2apfloatingpoint
which might be interesting reading...

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 11 Feb 1997 18:25:18 -0500
From: Christian Roy <roychri@total.net>
Subject: Re: [Q:] whitespace
Message-Id: <3300FFDE.10EA@total.net>

> I was wondering if anyone here could tell me how to strip out the
> whitespace out of a string like the one below:
> $string1 = "  floor         : {1,2,3,4,5};" or
> $string2 = "reset     : 0;"
> A property worth noting is that the whitespace occurs before the colon.
> 

Hi,
	I would use Reg Expressions. 
After executing those 2 lines :

$string1 =~ s/^[ ]*//g;
$string1 =~ s/[ ]* : / : /g;

$string 1 is "floor : {1,2,3,4,5};".

If I do the same with string2, it becomes "reset : 0;".

Good luck!


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

Date: Wed, 12 Feb 1997 20:31:34 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Appending to the top of a document...
Message-Id: <6eutd5.jr6.ln@localhost>

ubiquitous (Jonathan Eisenman) (ubiquitous@beachside.com) wrote:
: ....is it possible?  I once saw it done (I think it is what they were doing)
: with a for statement, but I like to be original, and after all, quoting
: Programming Perl, "There's More Than One Way To Do It".  In case you are
: wondering why, it is for a guestbook script I wrote.  I would say all in
: all it works pretty well...except for the fact that until I figure this out
: it does NOTHING!  Thanks for all you guys' help in the past!  Email replies
: appreciated.  Thanks again.


Well, could you just append to the end of the file, but use reverse()
when processing that file?

Just another TIMTOWTDI suggestion ;-)


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Thu, 13 Feb 1997 09:47:24 +0100
From: Dmitrij Frishman <frishman@mips.biochem.mpg.de>
Subject: Calling C from perl: help needed
Message-Id: <3302D51B.41C6@mips.biochem.mpg.de>

I am trying to reproduce the first example Test1 in the perlxstut man
page in order to understand how to connect C subroutines to my perl
code. I follow exactly the instructions in the example:

1. h2xs -A -n Test1
2. Append C code to the end of Test1.xs: 
        void
        hello()
        
                CODE:
                printf("Hello, world!\n");
3. perl Makefile.PL
4. make

Here is what I get on a DEC ALpha machine after running make:

> make
cp Test1.pm ./blib/lib/Test1.pm
/usr/local/bin/perl -I/usr/local/lib/perl5/alpha-dec_osf/5.003
-I/usr/local/lib/perl5 /usr/local/lib/perl5/ExtUtils/xsubpp  -typemac
Code is not inside a function in Test1.xs, line 13
*** Exit 1
Stop.

Here's how my Test1.xs actually looks:

------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif


MODULE = Test1		PACKAGE = Test1

        void
        hello()
        
                CODE:
                printf("Hello, world!\n");

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

I checked everything many times and could not find any difference
between what I am doing and the example in the man page.

You help will be greatly appreciated.

-- 
Dmitrij Frishman, PhD				| Tel. +49-(0)89-8578-2664
Max-Plank-Institute for Biochemistry		| Fax. +49-(0)89-8578-2655
Martinsried Institute for Protein Sequences	| e-mail:
frishman@mips.biochem.mpg.de
Am Klopferspitz 18a, 82152 Martinsried, Germany	| WWW:
http://www.mips.biochem.mpg.de/~frishman/


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

Date: 13 Feb 1997 11:58:21 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Calling C from perl: help needed
Message-Id: <5duvkt$jh3@news-central.tiac.net>

In article <3302D51B.41C6@mips.biochem.mpg.de>,
Dmitrij Frishman  <frishman@mips.biochem.mpg.de> wrote:
>I am trying to reproduce the first example Test1 in the perlxstut man
>page in order to understand how to connect C subroutines to my perl
>code. I follow exactly the instructions in the example:
>
>1. h2xs -A -n Test1
>2. Append C code to the end of Test1.xs: 
>        void
>        hello()
>        
>                CODE:
>                printf("Hello, world!\n");

It looks like you have too much whitespace on the left, I get the same
error if I use

[...]

MODULE = Test1          PACKAGE = Test1

        void
        hello ()

                CODE:
                printf ("Hello, world\n");

but not if I use:

[...]

MODULE = Test1          PACKAGE = Test1

void
hello ()

        CODE:
        printf ("Hello, world\n");

the perlxs man page says:

  The function body may be indented or left-adjusted.  The following example
  shows a function with its body left-adjusted.  Most examples in this
  document will indent the body.

but I think the return type and function name need to be against the left
margin and it's just the man page formatting that's indenting the blocks
of example code.  A cursory scan of the man pages hasn't found the
explicit text, but that could be lack of coffee...

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Thu, 13 Feb 1997 06:06:19 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: DBfile verses no DBfile
Message-Id: <r30vd5.ro.ln@localhost>

Geoffrey Hebert (soccer@microserve.net) wrote:
: Proplem:  50 online internet users using an application.  Count each
: application access by user.  Each user has a user-id.

: Everyone uses DBfile.  But why?  

What if a user has _two_ instances of the app running? Multi-tasking
brings concurrency control problems as does Multi-user.

That may be disallowed by your access control, but you haven't said so...


: Why not - Have an individual file for each user id with a count to
: increment.  Here I have a simple directory lookup, increment without
: lock, open file, increment counter, write, and close.  Simple with
: minimal system resources.

: I can see no reason not to do it this way, of course, I am new to
: UNIX.

: Now, how does it change as the volume goes up.  Say, I have 30,000
: users.   Looks to me, that the individual file solution becomes even
: more favorable.  What do you think?
  ^^^^^^^^^^^^^^

I don't think so. Can you have 30,000 filehandles all open at the same
time on your system?

Want to have 30,000 files in the same directory? If not, then add in
some more time for figuring what directory to look in.



: email please  heberts@microserve.net

How come?


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 13 Feb 1997 07:42:17 GMT
From: "Fredrik Lindberg" <flg@vhojd.skovde.se>
Subject: Re: get a string from a line
Message-Id: <01bc1981$9c54a5c0$e20f10c2@odens.di.vhojd.skovde.se>

>>>> Stefan Wimmer wrote
> I tried to work with regular expressions like that:
> 
> $buffer =~ m/\<h2\>string\<\\h2\>/is;
> 
> but there is no way.

You need to surround the text you want to catch with
paranthesis, like this:

$buffer =~ m/\<h2\>(string)\<\\h2\>/i;
$string = $1;  # $1 contains first paranthesized expression

Of course "string" would be an regexp and not a literal.

Check out the man page perlre for more information on 
regular expressions in perl. 

/Fredrik


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

Date: Tue, 11 Feb 1997 18:16:40 -0500
From: Christian Roy <roychri@total.net>
Subject: Re: getting STDERR from `backtick_exec`
Message-Id: <3300FDD8.35F3@total.net>

Daniel M. DiPasquo wrote:
> 
> Is there a way to grab the STERR of a command exec'd in backticks?  For
> example:
> 
> $output = `touch /some/place/i/dont/have/permissions/file`
> 
> $output should be "touch: ... cannot create", which is usually sent
> along STDERR and seemingly not captured
> 

It may be possible but that is what I suggest if you want to check for
permissions:

$file = "/some/place/i/dont/have/permissions/file";
if(-w $file)
  {
  $output = `touch $file`
  }


>From my book :

# Operator	Description
#----------------------------------------------
# -w		Is filename a writable file?
# -W		Is filename writable only if the real user ID can write?
#

Good luck!


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

Date: Thu, 13 Feb 1997 00:56:46 -0500
From: Gene Hennessy <ghennessy@greenapple.com>
Subject: MAKE MONEY
Message-Id: <3302AD1E.47DC@greenapple.com>

$$$$$ $50,000 for the New Year $$$$$
    
    Take five minutes to read this and it WILL change your life!!
    
    The internet has grown tremendously.  It doubles in size every 4
months, think about it.  You see those
    "Make Mony Fast" posts more and more.  That's because . . . IT
WORKS!  So I thought, all those new
    users might make it work.  And I decided to try it out, a few months
ago.  Besides, what's $5.00?  I spend
    more than that on food and drink at the vending machines at work. 
So I send in my money and posted. 
    Everyone was calling it a scam, but there are SO many new users from
AOL, Netcom, etc., they will join
    in and make it work for you.
    
    Well, two weeks later, I began receiving bucks in the mail!  I
couldn't believe it!  Not just a little, I     mean big bucks!  At first
only a few hundred dollars, then a week later, a couple of thousand,
then BOOM.     By then end of the fourth week, I had received nearly
$47,000.00.  It came from all over the world.  And
    every bit if it perfectly legal and on the up and up.  I've been
able to pay off all my bills and still       had enough left over for a
nice vacation for me and my family.
    
    Not only does it work for me, it works for others as well.  Markus
Valppu says he made $57,883 in four
    weeks.  Dave Manning claims he made $53,664 in the same amount of
time.  Dan Shepstone says it was
    only $17,000 for him.  Do I know these folks?  No, but when I read
how they say they did it, it made
    sensse to me.  Enough sense that I'm taking a similar chance with $5
bucks of my own.  Not a big chance,
    I admit, but one with incredible potential, because $5 is all anyone
ever invests in this system.  Period. 
    That's all Markus, Dave or Dan invested, yet their $5 netted them
tens of thousands of dollars each, in a
    safe, legal, completely legitimate way.  Here's how it works in 3
easy steps:
    
    STEP 1
    
    Invest your $5 by writing your name and address on five separate
pieces of paper along with the words: 
    "PLEASE ADD ME TO YOUR MAILING LIST."  (In this way, you're not just
sending a dollar bill to
    someone, you're paying for a legitimate service.)  Fold a $1 bill
inside each paper and mail them by
    standard mail to the following five addresses:
    
          1.Karen Lundgren
           3889 Kencrest Ave.
           Halifax, NS    CANADA
           B3K  3L4
    
          2.David Wilson
           7967 Shoals Dr  Apt C
           Orlando, FL  32817
    
          3.Sylvain Huot
           157 Comeau
           Sept-Iles, Qc, CANADA
           G4R 1J6
    
          4.Martin Boucher
           690 Allard
           Sept-Iles, Qc, CANADA
           G4R  1S8
    
          5.Gene Hennessy
           1604 W Fair Ave
           Lancaster, OH  43130
    
    
    
    STEP 2
    
    Now remove the top name from the list and move the other names up. 
This way, #5 becomes #4 and so
    on.  Put your name in as the fifth one on the list.
    
    STEP 3
    
    Post the article to at least 250 newsgroups.  There are at least
19,000 newsgroups at any given moment in
    time.  Try posting to as many newsgroups as you can.  Remember the
more groups you post to, the more
    people who will see your article and send you cash!  (There is
always help available from your online
    service if you do not know how to post to newsgroups, but it's
pretty simple.)  Once you modify your         letter . . . 250
newsgroups shouldn't take more than to 30 to 60 minutes.  Then just sit
back and wait.
    
    Your are now in business for yourself, and should start seeing
returns within 7 to 14 days !  Remember,
    the internet is new and huge.  There is no way you can lose.
    
    Now here is how and why this systems works:
    
    Out of every block of 250 posts I made, I got back 5 responses. 
Yes, that's right, only 5.   You make $5
    cash, not checks or money orders, but real cash with your name at
#5.
    
    Each additional person who sent you $1 now also makes 250 additional
postings with your name at #4,
    1000 postings.  On average then, 50 people will send you $1 with
your name at #4 .... $50 in your pocket.
    
    Now these 50 new people will make 250 postings each with your name
at #3 or 10,000 postings.  Average
    return, 500 people=$500.  They make 250 postings each with your name
at #2 or 100,000 postings which
    averages 5000 returns  for $5,000 in cash!
    
    Finally, 5,000 people make 250 postings each with your name at #1
and you get a return of 60,000 before
    your name drops off the list.  And that's only if everyone down the
line makes only 250 postings each! 
    Your total income for this one cycle is $55,000.
    
    From time to time when you see your name is no longer on the list,
you take the lastest posting you can
    find and start all over again.
    
         The end result depends on you.  You must follow through and
repost this article everywhere you 
         can think of.  The more postings you make, the more cash ends
up in your mailbox.  It's too easy 
         and too cheap to pass up!
    
    So that's it. Pretty simple sounding stuff, huh?  But believe me, it
works!  There are millions of people
    surfing the net every day, all day, all over the world.  And 100,000
new people get on the net every day. 
    You know that, you've seen the stories in the paper.  So, my friend,
read and follow the simple
    instructions and play fair.  That's the key, and that's all there is
to it.  Print this out right now so     you can refer back to this
article easily.  Try to keep an eye on all the postings you made to make
sure     everyone is playing fairly.  You know where your name should
be.
    
    If you're really not sure or still think this can't be for real,
then don't do it.  But please pass this      article on to someone you
know who really needs the extra money, and see what happens.
    
    REMEMBER....HONESTY IS THE BESTS POLICY.  YOU DON'T NEET TO CHEAT
THE BASIC
    IDEA TO MAKE THE BUCKS!  GOOD LUCK TO ALL, AND PLEASE PLAY FAIR AND
YOU WILL
    WIN AND MAKE SOME REAL INSTANT FREE CASH!
    
    *** By the way, if you try to deceive people by posting the messages
with your name in the list and not
    sending the money to the people already included, you will not get
much.  I know someone who did this
    and only got $150 (and that's after 2 months).  Then he sent the 5
bills, peopled added him to their lists
    and in 4-5 weeks he had over $10,000!
    
    
         TRY IT AND YOU'LL BE HAPPE !!!!!!


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

Date: 13 Feb 1997 09:56:33 GMT
From: "robert@tnet.es" <robert@tnet.es>
To: djk490s@nic.smsu.edu
Subject: Re: Need help - just starting perl
Message-Id: <5duogh$sq8$2@diana.ibernet.es>

I am trying to get perl 5 running on a Sparc 5 with solaris 2.5 .I get the
following error in the configure and make 

make: Warning: Both `makefile' and `Makefile' exist


and


	  CCCMD =  gcc -c  -O   
`sh  cflags libperl.a taint.o`  taint.c
	  CCCMD =  gcc -c  -O   
`sh  cflags libperl.a deb.o`  deb.c
	  CCCMD =  gcc -c  -O   
`sh  cflags libperl.a globals.o`  globals.c
	  CCCMD =  gcc -c  -O   
rm -f libperl.a
ar rcu libperl.a perl.o malloc.o gv.o toke.o perly.o op.o regcomp.o dump.o
util.o mg.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o
doio.o regexec.o taint.o deb.o globals.o 
sh: ar: not found
*** Error code 1
make: Fatal error: Command failed for target `libperl.a'

Thank you for any help you could offer,

Robert:-)



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

Date: 13 Feb 1997 09:50:34 GMT
From: "robert@tnet.es" <robert@tnet.es>
To: djk490s@nic.smsu.edu
Subject: Perl instalation
Message-Id: <5duo5a$sq8$1@diana.ibernet.es>

When I try to install perl 5 on my Sparc 5 solaris 2.5 I get the following
errors during make.(The error comes up during configure but I figured that if
keeps going great)

make: Warning: Both `makefile' and `Makefile' exist


and then at the end I get...

	  CCCMD =  gcc -c  -O   
`sh  cflags libperl.a taint.o`  taint.c
	  CCCMD =  gcc -c  -O   
`sh  cflags libperl.a deb.o`  deb.c
	  CCCMD =  gcc -c  -O   
`sh  cflags libperl.a globals.o`  globals.c
	  CCCMD =  gcc -c  -O   
rm -f libperl.a
ar rcu libperl.a perl.o malloc.o gv.o toke.o perly.o op.o regcomp.o dump.o
util.o mg.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o
doio.o regexec.o taint.o deb.o globals.o 
sh: ar: not found
*** Error code 1
make: Fatal error: Command failed for target `libperl.a'



If you could suggest what I should do it would be greatly appreciated.


Regards,

Robert:-)



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

Date: Thu, 13 Feb 1997 11:05:34 GMT
From: DerosM@aramis.be
Subject: Perl NT
Message-Id: <5duskj$kgq@pluto.interpac.be>

Hi,

Newbie's question...

Is it possible to test Unix perl script on a NT machine. I have Perl 5
for NT, but have not yet installed it.

Thanks


Manu

DerosM@aramis.be
Manu De Ros
DerosM@aramis.be
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Have you ever surfed on http://www.aramissoft.com?
Enjoy this new experience... but don't let us go gently...
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<



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

Date: 13 Feb 1997 08:24:39 GMT
From: Dave Hammen <hammen@gothamcity.jsc.nasa.gov>
Subject: Re: Perl rand() function on solaris SPARC
Message-Id: <5duj47$a1s@cisu2.jsc.nasa.gov>

Kevin Gardner, gardner@redfield.med.utoronto.ca writes:
>Paul Austin (paustin@gw.ford.com) wrote:
>: I am trying to use the rand() function to obtain a random number between
>: 0 and 39. This works fine on a HP UX system but when I run it on
>: solaris the numbers being returned are in the order of 100,000's
>: any ideas why this occurs?
>:
>: The command I am using is:
>:
>: $index = int(rand(39));
>
>Hmmm --- works fine on my setup (Perl 5.003; Solaris 2.5.1 / Sparc 2).
>My initial guess is that your Solaris perl executable may have been
>compiled with the incorrect value set for the number of bits produced
>by the random number generator.  Any other ideas?

Other ideas:

(1) The SunOS perl build was copied to Solaris rather than being
rebuilt on Solaris because "Solaris can run SunOS binaries".
However, I would expect this to generate very small random numbers.

(2) (Amplification on Paul's guess) The config.sh script generated
by the perl Configure script was edited manually to make perl link
with the the BSD-compatibility library, and the number of bits
produced by the random number was not reset accordingly. I would
expect this to generate very large random numbers. (The BSD version
of rand() produces 31 bit random numbers. The System V version
whacks off the top and bottom bytes, producing 16 bit numbers.)

The postings regarding calling srand were a red herring.
The call to srand is not mandatory.

Solution: Rebuild perl, and then do a 'make test' before
installing it.

-- 
Dave Hammen / LinCom Corporation


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

Date: Thu, 13 Feb 1997 11:24:42 +0000
From: Steve Gailey <steveg@metrosol.demon.co.uk>
Subject: Re: perl ulimit -c 0 ?
Message-Id: <3302F9FA.13CD@metrosol.demon.co.uk>

David K. Drum wrote:
> 
> Steve Gailey <steveg@metrosol.demon.co.uk> wrote:
> > I have a perl script which is a wrapper for an application. Unfortunatly
> > the application is quite buggy and keeps dropping core leaving large
> > (10MB) core files around the place.
> 
> > Is there a way to set the ulimit from perl which will carry forward to
> > the program I run with exec()? I tried `ulimit -c 0` prior to the exec,
> > but of course this had no effect.
> 
> I use the following on my Solaris 2.5 systems:
> 
> # no core files!
> require 'sys/syscall.ph';
> $RLIMIT_CORE = 4;
> $rlimit = pack ("I2", 0, 0);
> syscall (&SYS_setrlimit, $RLIMIT_CORE, $rlimit);
> 
> Regards,
> 
> David
> --
> "That man has a rare gift for obfuscation." -- ST:DS9 * "It's hard to be
> bored when you're as stupid as a line." -- Vernor Vinge * "Reality has a
> tendency to be so uncomfortably real." -- Neil Peart * "[The building was] of
> no particular style of architecture except to use as much lumber as possible."

Thanks, it worked a treat!

Steve


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

Date: Tue, 11 Feb 1997 17:44:04 -0500
From: Christian Roy <roychri@total.net>
Subject: Perl5 : Calling Parent Method
Message-Id: <3300F634.3E2E@total.net>

Hi,
	This Article is intended to get help from anyone out there who can.
This message is a bit BIG because I wanted to give as much information
that I can. The error message I get is located at the end of this
article. If anyone got that error message or know where is the problem
(Most likely in my programming), then please take time to read and if
you can, answer my question... Thank you!

	it's now 6 days I do Perl Object Oriented Programming. I've done 7 or 8
Objects (Packages) so far. It's pretty cool. But I ran into a problem :

Perl Version :
  This is perl, version 5.001
        Unofficial patchlevel 1m.
  + suidperl security patch


OS Version :
	BSDI BSD/OS 2.1

Computer :
	Pentium 166. 64 M RAM

Files used :
	WebUser.pm    #Done by me
	EasyDate.pm   #Done by me
	LinkedList.pm #Done by me
	Email.pm      #Done by me
	Test.pl       #Done by me
	

Head of WebUsage.pm :
	package WebUsage;
	use LinkedList;
	use Email;

	sub new
	  {
	...

Test.pl : 

#!/usr/local/bin/perl5

package main;

$n = new WebUsageReport("Email" => "roychri\@total.net");
$c = $n->CalculPeriodTotal();
$c = $c / 1024;
print "Total = $c\n";

$n->SetParameter("Email" => "landryc\@total.net");
$c = $n->CalculPeriodTotal();
$c = $c / 1024;
print "Total = $c\n";

exit;

#
# Test Package WebUsageReport, Inherited from WebUsage
#
package WebUsageReport;
use WebUsage;
use EasyDate;
@ISA = (WebUsage);
@PARENT::ISA = @ISA;


sub new
  {
 ...

sub SetParameter
  {
  my($self) = shift;
  my(%param) = @_;

  $self->GetParameterSettings();
           __OR__
  $self->PARENT::GetParameterSettings();
  }
 ...

The Method "GetParameterSettings" is in the WebUsage.pm.

When I try to run Test.pl, I get :
********************
Can't locate object method "GetParameterSettings" via package
"WebUsageReport" at ./Test.pl line 59, <USAGE> line 17.
        or (See __OR__)
Can't locate object method "PARENT::GetParameterSettings" via package
"WebUsageReport" at ./Test.pl line 59, <USAGE> line 17.
********************

What am I missing. I tryed mutltiple thing.
I looked into some Module Library file in the @INC directory.
I can't find the problem.

If anyone can help me, it would be apreciated.

If someone can help but I didn't put enough information, please send me
an email.

Thank you very Much!


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

Date: 13 Feb 1997 12:16:01 GMT
From: "Michael Avila" <lnussat.mavila@eds.com>
Subject: Re: read and write +> at the same time - HOW?
Message-Id: <01bc19a7$e5de1160$e672b182@j00524176.try.sat.gmeds.com>

Thanks for your help.  I've done that in C and I think Perl kinda functions
the same way.  I don't use Perl a lot but when I do it usually is one of
those gotta have it yesterday deals!

Thanks.

Mike


> It doesn't exactly mean "at the same time". The way you're using it
> means, "first I want to write the file, later I want to read it". I
> haven't done this for a while, but as I recall, you need to do a seek
> between the writing and reading.
> 



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

Date: 13 Feb 1997 12:17:27 GMT
From: "Michael Avila" <lnussat.mavila@eds.com>
Subject: Re: read and write +> at the same time - HOW?
Message-Id: <01bc19a8$195da960$e672b182@j00524176.try.sat.gmeds.com>

I will look up that use as that is one of my concerns.  That is why I did
not want to write a temp file and rename it and go thru all of that
process.

Thanks for the help.

Mike


> Well, I think you could use the methods in Randal's fourth Web Techniques
> column, which (among other things) explains how to use flock() to avoid
> problems when multiple processes need to modify one file. Hope this
helps!



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

Date: Wed, 12 Feb 1997 20:46:48 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: REQ: Getting the amount of files in a certain directory.
Message-Id: <oavtd5.vv6.ln@localhost>

Nathan D Richards (nathanr@k2.ashpool.com) wrote:
: I need to know how many *.D files there are in a certain directory.
: Is there anyway to do this in a CGI script?
                                  ^^^^^^^^^^

I dunno about CGI scripting. Of course you didn't expect me to,
since I am not reading a CGI newsgroup...

I know how to do it with a Perl script though. 

Would that be good enough?


: Where the output woul be something like:
: There are xxx files.

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

# one way
@files = <*.D>;
print "There are ", scalar(@files), " files.\n";

# another way
opendir(DIR, ".") || die "could not open current directory $!";
print "There are ", scalar(grep /\.D$/, readdir(DIR)), " files.\n";
closedir(DIR);
---------------


But these count everything (dirs, sym links, etc...) not just files.

see the perlfunc man page for file tests to adjust the above to only
report for _files_ (search for '-X').

see the perlop man page for that <*.D> stuff above (search for 'globb')

see the perlfunc man page again for the opendir/readdir stuff above.



: Thank you very much.

You are welcome.

--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Thu, 13 Feb 1997 04:01:17 -0600
From: robert@tnet.es
Subject: Solaris2.5 Perl 5 instalation
Message-Id: <855827120.27586@dejanews.com>

I need help installing perl 5 on my sparc 5 with solaris 2.5
After typing configure I get an error, after many default answers ,
that I have two makefiles.

I then get an error 1 after typing make.

Does someone have perl for solaris 2.5 ready or what should I do with
the one I have?I am new to the whole Idea of programing Perl but would
like to give it a try.I also would like to try out some of Matt's and
Solena Sol's scripts.

Anyone willing to help please let me know,

Thank you,

Robert:-)

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Wed, 12 Feb 1997 23:25:14 -0800
From: Devin Ben-Hur <dbenhur@emarket.com>
To: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: subtle (to me) RE problem
Message-Id: <3302C1DA.C50@emarket.com>

Eli the Bearded wrote:
> In a script which is scoring spam, I want to be able to
> detect N or more occurances of any one of these characters:
>         ()!%*_+=|\/,<>:~-
> For N=7, I have
> /([\(\)!%*_+=|\\\/,<>:~-]).*${1}.*${1}.*${1}.*${1}.*${1}.*${1}/
> And that gives me a "nested *?+ in regexp" error. Why?

$ and {number} has a meaning in RE's so those '${1}'s
may not be parsed as a variable interpolation as you seemed 
to intend.  That could be what's causing the error msg, but 
I'm not sure.

Regardless, this is how you really wanted to write that RE
(because $1 doesn't hold a meaningful result until after the
match):

/([\(\)!%*_+=|\\\/,<>:~-]).*\1.*\1.*\1.*\1.*\1.*\1/

And here's a more compact way to say it:

/([\(\)!%*_+=|\\\/,<>:~-])(.*?\1){6}/

which if you have your N in $N allows you to adjust your
RE to N on the fly:

$N_1 = $N - 1;
/([\(\)!%*_+=|\\\/,<>:~-])(.*?\1){$N_1}/

HTH
--
Devin Ben-Hur      <dbenhur@emarket.com>
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-



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

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

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 V7 Issue 938
*************************************

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