[15484] in Perl-Users-Digest
Perl-Users Digest, Issue: 2894 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 28 14:15:40 2000
Date: Fri, 28 Apr 2000 11:15:26 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <956945725-v9-i2894@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 28 Apr 2000 Volume: 9 Number: 2894
Today's topics:
Random number bis (more difficult IMO - with database) <stephane@siw.ch>
Re: Random number bis (more difficult IMO - with databa <rootbeer@redcat.com>
Re: Random number bis (more difficult IMO - with databa <stephane@siw.ch>
Re: Random number bis (more difficult IMO - with databa nobull@mail.com
Re: Random number bis (more difficult IMO - with databa <stephane@siw.ch>
Re: Random number bis (more difficult IMO - with databa <rootbeer@redcat.com>
Re: Random number bis (more difficult IMO - with databa <red_orc@my-deja.com>
Re: Random number bis (more difficult IMO - with databa <stephane@siw.ch>
Re: Random number <ppi@searchy.net>
Re: Random number <rootbeer@redcat.com>
Re: Random number <gellyfish@gellyfish.com>
Re: Random number <godzilla@stomp.stomp.tokyo>
Re: Random number <andrew.mcguire@walgreens.com>
Re: Random number <godzilla@stomp.stomp.tokyo>
Re: Random number <andrew.mcguire@walgreens.com>
Re: Random number <lr@hpl.hp.com>
Re: Random number <jonny@jonnysoft.co.uk>
Re: Random number <lr@hpl.hp.com>
Re: reading .ost files amarodeeps@my-deja.com
Re: reading .ost files <rootbeer@redcat.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 28 Apr 2000 16:00:17 GMT
From: "Chello" <stephane@siw.ch>
Subject: Random number bis (more difficult IMO - with database)
Message-Id: <lAiO4.55891$6X3.1351555@news.chello.at>
Hi again....
That time I have another problem...
I request some data from a database in fact (I hope) there are multiple
row... After that I'd like to choose randomly only one record. Here is the
code (it doesn't work:-( ):
#!/usr/bin/perl -w
use CGI;
use Win32::ODBC;
$Data = new Win32::ODBC("Connect=ODBC;DSN=moonkey");
$Data->Connection();
my $location="hi";
$Data->Sql("SELECT id FROM table WHERE target_location='$location');
my($err) = $Data->Error;
my ($nb_al)= $Data->RowCount(Data);
my $random = int(rand($nb_al)+1);
while ($Data->FetchRow($Random)) {
($id) = $Data->Data();
}
print "$id\n";
I don't know why.....
Thanks in advance.
See ya
Stéphane
------------------------------
Date: Fri, 28 Apr 2000 09:16:48 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Random number bis (more difficult IMO - with database)
Message-Id: <Pine.GSO.4.10.10004280913020.21722-100000@user2.teleport.com>
On Fri, 28 Apr 2000, Chello wrote:
> Here is the code (it doesn't work:-( ):
What diagnostic messages did perl give you when you tried it?
> #!/usr/bin/perl -w
That's good; it's even better to use 'use strict', so that perl can help
you catch more errors.
> $Data->Sql("SELECT id FROM table WHERE target_location='$location');
Didn't perl complain that your missing double-quote mark caused a
run-away string?
> my $random = int(rand($nb_al)+1);
>
> while ($Data->FetchRow($Random)) {
Didn't it warn you that $Random was used only once? (Perl variable names
are case-sensitive.)
Well, that's enough to get you started....
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 28 Apr 2000 16:21:52 GMT
From: "Chello" <stephane@siw.ch>
Subject: Re: Random number bis (more difficult IMO - with database)
Message-Id: <AUiO4.55921$6X3.1354247@news.chello.at>
Hi,
I just corrected the code but it doesn't work better... HELPPPPPPPP.....
#!/usr/bin/perl -w
# :-(
use CGI;
use Win32::ODBC;
$Data = new Win32::ODBC("Connect=ODBC;DSN=moonkey");
$Data->Connection();
my $location="hi";
$Data->Sql("SELECT id FROM table WHERE target_location='$location'");
my($err) = $Data->Error;
my ($nb_al)= $Data->RowCount(Data);
my $random = int(rand($nb_al)+1);
while ($Data->FetchRow($random)) {
($id) = $Data->Data();
}
print "$id\n";
"Tom Phoenix" <rootbeer@redcat.com> wrote in message
news:Pine.GSO.4.10.10004280913020.21722-100000@user2.teleport.com...
> On Fri, 28 Apr 2000, Chello wrote:
>
> > Here is the code (it doesn't work:-( ):
>
> What diagnostic messages did perl give you when you tried it?
>
> > #!/usr/bin/perl -w
>
> That's good; it's even better to use 'use strict', so that perl can help
> you catch more errors.
>
> > $Data->Sql("SELECT id FROM table WHERE target_location='$location');
>
> Didn't perl complain that your missing double-quote mark caused a
> run-away string?
>
> > my $random = int(rand($nb_al)+1);
> >
> > while ($Data->FetchRow($Random)) {
>
> Didn't it warn you that $Random was used only once? (Perl variable names
> are case-sensitive.)
>
> Well, that's enough to get you started....
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
------------------------------
Date: 28 Apr 2000 17:20:13 +0100
From: nobull@mail.com
Subject: Re: Random number bis (more difficult IMO - with database)
Message-Id: <u9itx219ky.fsf@wcl-l.bham.ac.uk>
"Chello" <stephane@siw.ch> writes:
> I request some data from a database in fact (I hope) there are multiple
> row... After that I'd like to choose randomly only one record. Here is the
> code (it doesn't work:-( ):
It doesn't even pass syntax check. Please post real code so that we
are not sent off on wild goose chases.
Consider also using "strict".
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 28 Apr 2000 16:48:37 GMT
From: "Chello" <stephane@siw.ch>
Subject: Re: Random number bis (more difficult IMO - with database)
Message-Id: <FhjO4.55955$6X3.1357297@news.chello.at>
Here is the real code:
#!/usr/bin/perl -w
use CGI;
use Win32::ODBC;
# use strict;
$q = new CGI;
$id = $q->param('id');
$Data = new Win32::ODBC("Connect=ODBC;DSN=moonkey");
$Data->Connection();
$Data->Sql("SELECT nb_hit,location,last_banner FROM exchange WHERE
id='$id'");
my($err) = $Data->Error;
while ($Data->FetchRow())
{
($nb_hit,$location,$last_banner) = $Data->Data();
}
my $nb_hit=$nb_hit + 1;
$Data->Sql("SELECT banner,id FROM exchange WHERE target_location='$location'
AND id NOT LIKE '$last_banner' AND id NOT LIKE '$id'");
my($err) = $Data->Error;
my ($nb_al)= $Data->RowCount(Data);
my $random = int(rand($nb_al)+1);
while ($Data->FetchRow($random))
{
($banner,$newid,$nb_hit) = $Data->Data();
}
$Data->Sql("SELECT banner_view,nb_hit FROM exchange WHERE id='$newid'");
my($err) = $Data->Error;
while ($Data->FetchRow())
{
($banner_view,$nb_hit) = $Data->Data();
}
my $nb_hit=$nb_hit - 1;
my $banner_view=banner_view + 1;
$Data -> Sql("UPDATE exchange SET banner_view='$banner_view' WHERE
id='$newid'");
$Data -> Sql("UPDATE exchange SET nb_hit='$nb_hit' WHERE id='$newid'");
$Data -> Sql("UPDATE exchange SET last_banner='$newid' WHERE id='$id'");
$Data -> Sql("UPDATE exchange SET nb_hit='$nb_hit' WHERE id='$id'");
$Data->Close();
binmode STDOUT;
print "Content-type: image/gif\n";
print "Pragma: no-cache\n";
print "Expires: now\n\n";
my $banner="e:/inetpub/wwwroot/graphics/$banner";
open( GIF, $banner) || die(" ??? $!");
binmode GIF;
while( $img = <GIF>) {
print stdout $img;
}
close(GIF);
Thanks in advance for your help....
Stéphane
<nobull@mail.com> wrote in message news:u9itx219ky.fsf@wcl-l.bham.ac.uk...
> "Chello" <stephane@siw.ch> writes:
>
> > I request some data from a database in fact (I hope) there are multiple
> > row... After that I'd like to choose randomly only one record. Here is
the
> > code (it doesn't work:-( ):
>
> It doesn't even pass syntax check. Please post real code so that we
> are not sent off on wild goose chases.
>
> Consider also using "strict".
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: Fri, 28 Apr 2000 09:54:08 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Random number bis (more difficult IMO - with database)
Message-Id: <Pine.GSO.4.10.10004280953080.21722-100000@user2.teleport.com>
On Fri, 28 Apr 2000, Chello wrote:
> I just corrected the code but it doesn't work better...
> HELPPPPPPPP.....
Well, clean it up so that 'use strict' will work, then step through it in
the debugger. Does that get you any closer to a solution? (Even if it
doesn't, it'll probably be educational. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 28 Apr 2000 17:04:29 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Random number bis (more difficult IMO - with database)
Message-Id: <8ecgai$8bq$1@nnrp1.deja.com>
In article <AUiO4.55921$6X3.1354247@news.chello.at>,
"Chello" <stephane@siw.ch> wrote:
> Hi,
>
> I just corrected the code but it doesn't work better...
HELPPPPPPPP.....
just what does "it doesn't work better" mean in practical terms?
does it do anything? does it do more than you wanted? less?
>
> #!/usr/bin/perl -w
> # :-(
>
> use CGI;
> use Win32::ODBC;
>
> $Data = new Win32::ODBC("Connect=ODBC;DSN=moonkey");
> $Data->Connection();
>
> my $location="hi";
> $Data->Sql("SELECT id FROM table WHERE target_location='$location'");
> my($err) = $Data->Error;
>
> my ($nb_al)= $Data->RowCount(Data);
is $nb_al non-zero? (did any rows match target_location = "hi")
> my $random = int(rand($nb_al)+1);
>
> while ($Data->FetchRow($random)) {
> ($id) = $Data->Data();
> }
> print "$id\n";
>
> "Tom Phoenix" <rootbeer@redcat.com> wrote in message
> news:Pine.GSO.4.10.10004280913020.21722-100000@user2.teleport.com...
> > On Fri, 28 Apr 2000, Chello wrote:
> >
> > > Here is the code (it doesn't work:-( ):
> >
> > What diagnostic messages did perl give you when you tried it?
> >
> > > #!/usr/bin/perl -w
> >
> > That's good; it's even better to use 'use strict', so that perl can
help
> > you catch more errors.
> >
> > > $Data->Sql("SELECT id FROM table WHERE
target_location='$location');
> >
> > Didn't perl complain that your missing double-quote mark caused a
> > run-away string?
> >
> > > my $random = int(rand($nb_al)+1);
> > >
> > > while ($Data->FetchRow($Random)) {
> >
> > Didn't it warn you that $Random was used only once? (Perl variable
names
> > are case-sensitive.)
> >
> > Well, that's enough to get you started....
> >
> > --
> > Tom Phoenix Perl Training and Hacking Esperanto
> > Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
> >
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 28 Apr 2000 17:48:03 GMT
From: "Chello" <stephane@siw.ch>
Subject: Re: Random number bis (more difficult IMO - with database)
Message-Id: <n9kO4.56006$6X3.1362696@news.chello.at>
Really less... In fact it display only one picture like if the random
function didn't exist...
"Rodney Engdahl" <red_orc@my-deja.com> wrote in message
news:8ecgai$8bq$1@nnrp1.deja.com...
> In article <AUiO4.55921$6X3.1354247@news.chello.at>,
> "Chello" <stephane@siw.ch> wrote:
> > Hi,
> >
> > I just corrected the code but it doesn't work better...
> HELPPPPPPPP.....
>
> just what does "it doesn't work better" mean in practical terms?
> does it do anything? does it do more than you wanted? less?
>
> >
> > #!/usr/bin/perl -w
> > # :-(
> >
> > use CGI;
> > use Win32::ODBC;
> >
> > $Data = new Win32::ODBC("Connect=ODBC;DSN=moonkey");
> > $Data->Connection();
> >
> > my $location="hi";
> > $Data->Sql("SELECT id FROM table WHERE target_location='$location'");
> > my($err) = $Data->Error;
> >
> > my ($nb_al)= $Data->RowCount(Data);
>
> is $nb_al non-zero? (did any rows match target_location = "hi")
>
> > my $random = int(rand($nb_al)+1);
> >
> > while ($Data->FetchRow($random)) {
> > ($id) = $Data->Data();
> > }
> > print "$id\n";
> >
> > "Tom Phoenix" <rootbeer@redcat.com> wrote in message
> > news:Pine.GSO.4.10.10004280913020.21722-100000@user2.teleport.com...
> > > On Fri, 28 Apr 2000, Chello wrote:
> > >
> > > > Here is the code (it doesn't work:-( ):
> > >
> > > What diagnostic messages did perl give you when you tried it?
> > >
> > > > #!/usr/bin/perl -w
> > >
> > > That's good; it's even better to use 'use strict', so that perl can
> help
> > > you catch more errors.
> > >
> > > > $Data->Sql("SELECT id FROM table WHERE
> target_location='$location');
> > >
> > > Didn't perl complain that your missing double-quote mark caused a
> > > run-away string?
> > >
> > > > my $random = int(rand($nb_al)+1);
> > > >
> > > > while ($Data->FetchRow($Random)) {
> > >
> > > Didn't it warn you that $Random was used only once? (Perl variable
> names
> > > are case-sensitive.)
> > >
> > > Well, that's enough to get you started....
> > >
> > > --
> > > Tom Phoenix Perl Training and Hacking Esperanto
> > > Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
> > >
> >
> >
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Fri, 28 Apr 2000 17:07:26 +0200
From: Penpal International <ppi@searchy.net>
Subject: Re: Random number
Message-Id: <3909A92E.7B562F04@searchy.net>
Don't you forget srand? Without it doesn't work. Here is an working
script:
srand;
$rand = int(rand(10))+1; # Random number ranging from 1 to 10
Marco Natoni wrote:
>
> Hi Chello,
>
> Chello wrote:
> > I have a little problem I have to generate a random number with
> > two limits (upper limit and down limit) for example 1 and 4. When
> > I call the script this script would have to display "1" or "2" or
> > "3" or "4". Does somebody knows how to do it? Do you have an
> > example?
>
> Try with '$my_random=(int rand 4)+1'. Hope it helps you.
>
> Best regards,
> Marco
--
Penpal International
http://ppi.searchy.net/
ppi@searchy.net
------------------------------
Date: Fri, 28 Apr 2000 08:15:42 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Random number
Message-Id: <Pine.GSO.4.10.10004280814260.21722-100000@user2.teleport.com>
On Fri, 28 Apr 2000, Penpal International wrote:
> Don't you forget srand? Without it doesn't work.
I think you're mistaken. Have you seen the entry on 'rand' in perlfunc?
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 28 Apr 2000 15:18:37 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Random number
Message-Id: <hZhO4.1510$fT4.151660@news.dircon.co.uk>
[ Post rearranged ]
On Fri, 28 Apr 2000 17:07:26 +0200, Penpal International Wrote:
> Marco Natoni wrote:
>>
>> Hi Chello,
>>
>> Chello wrote:
>> > I have a little problem I have to generate a random number with
>> > two limits (upper limit and down limit) for example 1 and 4. When
>> > I call the script this script would have to display "1" or "2" or
>> > "3" or "4". Does somebody knows how to do it? Do you have an
>> > example?
>>
>> Try with '$my_random=(int rand 4)+1'. Hope it helps you.
>
> Don't you forget srand? Without it doesn't work. Here is an working
> script:
>
From 'perldoc -f srand' :
In fact, it's usually not necessary to call
`srand' at all, because if it is not called
explicitly, it is called implicitly at the first
use of the `rand' operator. However, this was not
the case in version of Perl before 5.004, so if
your script will run under older Perl versions, it
should call `srand'.
And generally if you have a version of Perl older than 5.004 you should
upgrade ;-}
/J\
------------------------------
Date: Fri, 28 Apr 2000 09:27:43 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Random number
Message-Id: <3909BBFF.3FAF7DDE@stomp.stomp.tokyo>
Penpal International wrote:
> Don't you forget srand? Without it doesn't work. Here is an working
> script:
> srand;
> $rand = int(rand(10))+1; # Random number ranging from 1 to 10
> Marco Natoni wrote:
> > Hi Chello,
> > Try with '$my_random=(int rand 4)+1'. Hope it helps you.
(snipped with a random number generator)
Yes and no, Penpal. Use of srand is needed for
many versions of Perl but no longer required
under more recent versions of Perl 5 except when
you are using creative programming. However, it
is good advice to suggest using or testing srand
first, if you are uncertain what version of Perl
a given server is using. This is also prudent
to visually verify a random number generator
actually does operate as expected.
Use of srand does ensure a high degree of
portability for your script and, clearly,
those who say to never use srand are not
in tune with portability issues. These
would be people who do not write programs
or have little experience in writing
programs for common wide usage.
My suggestion to people is to first test a
program with srand to verify operation, then
remove srand and test again to verify there
is no need for its use. There are still enough
older versions of Perl 4 and Perl 5 in use to
validate testing srand in all cases. Even when
you check and know what version of Perl is in
use, it is exceptionally wise to verify a random
number generator actually works.
An analogy is your motor vehicle petro gauge
may display a full tank of petro. This is no
guarantee there is actually petro in its tank,
it's just a safe indicator but not a guarantee.
Ever have a motor vehicle which runs out of
petro at quarter of tank indicated? I sure have!
Your advice on srand is very often correct and,
to a lesser degree, not quite correct. Continue
to suggest 'testing' with srand just in case
and remove it when not needed.
For fun, here are some creative uses of
random numbers you don't see very often,
you might like to play with during your
leisure time, which as hard working people,
we all have plenty. Should you someday have
access to older versions of Perl and newer
versions of Perl, test these with and
without 'srand' and discover what happens,
depending on the version of Perl in use.
This one will randomly lowercase and
uppercase letters for a textual input
string, $in{InlaHolisso} for my program.
Silly stuff, gives that "K-rad kEwL DudZ"
type of look to posted text:
srand(time() ^ ($$ + ($$ << 15)));
sub randcase
{
rand(40) < 20 ? "\u$1" : "\l$1" ;
}
$in{InlaHolisso} =~ s/([a-z])/randcase($1)/gie;
This weird example is part of a sub-routine
for generating a 'fortune' for users. It is
actually based on an array containing mystic
and vague adjectives you would expect from
a Gypsy Fortune Teller. It's final output
is a series of two digit numbers, obviously
winning numbers for any lottery. My variable
$adjective_one is pulled elsewhere:
srand;
$_ = (rand(@Adjectives)) * 100000000000;
s/\..+//g;
s/(\d\d?)/\1, /g;
chop($_);
chop($_);
$fortune = "you are a $adjective_one person. <BR>
Your lucky numbers are: $_.";
Sometimes srand is needed, sometimes not.
There is no right nor wrong answer on this.
Safe to say though, those who say you _never_
need srand, are dead wrong.
Godzilla!
------------------------------
Date: Fri, 28 Apr 2000 11:54:30 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Random number
Message-Id: <3909C246.8E31B4B@walgreens.com>
"Godzilla!" wrote:
[ snip ]
> My suggestion to people is to first test a
> program with srand to verify operation, then
> remove srand and test again to verify there
> is no need for its use. There are still enough
> older versions of Perl 4 and Perl 5 in use to
> validate testing srand in all cases. Even when
> you check and know what version of Perl is in
> use, it is exceptionally wise to verify a random
> number generator actually works.
Mmm. No need for this, is there.
srand if $] < 5.004;
Mmmm, portable it is.
[ snip ]
> Sometimes srand is needed, sometimes not.
> There is no right nor wrong answer on this.
> Safe to say though, those who say you _never_
> need srand, are dead wrong.
True this is.
> Godzilla!
Cheers,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: Fri, 28 Apr 2000 10:14:40 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Random number
Message-Id: <3909C700.3C41BC23@stomp.stomp.tokyo>
"Andrew N. McGuire" wrote:
> "Godzilla!" wrote:
> [ snip ]
> Mmm. No need for this, is there.
> srand if $] < 5.004;
> Mmmm, portable it is.
" Even when you check and know what version of Perl
is in use, it is exceptionally wise to verify a
random number generator actually works."
Godzilla!
------------------------------
Date: Fri, 28 Apr 2000 12:24:31 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Random number
Message-Id: <3909C94F.5F983155@walgreens.com>
"Godzilla!" wrote:
>
> "Andrew N. McGuire" wrote:
>
> > "Godzilla!" wrote:
>
> > [ snip ]
>
>
> > Mmm. No need for this, is there.
>
> > srand if $] < 5.004;
>
> > Mmmm, portable it is.
>
> " Even when you check and know what version of Perl
> is in use, it is exceptionally wise to verify a
> random number generator actually works."
<yoda>
Dispute that statement I did not...
"Exceptionally wise" I would not say, Mmm.
Wise, yes.
perl -we 'srand if $] < 5.004; print rand'
</yoda>
[ aside: sorry, Star Wars on the brain ]
Cheers,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: Fri, 28 Apr 2000 10:35:18 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Random number
Message-Id: <MPG.13736bb09652b6f298a9a3@nntp.hpl.hp.com>
In article <3909C246.8E31B4B@walgreens.com> on Fri, 28 Apr 2000 11:54:30
-0500, Andrew N. McGuire <andrew.mcguire@walgreens.com> says...
...
> srand if $] < 5.004;
>
> Mmmm, portable it is.
That really isn't good enough for archaic versions of perl, which still
need initialization of the srand function (as shown in the original
post). Some of my code still runs using 5.002 on servers over which I
have no control. Sigh...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 28 Apr 2000 18:47:27 +0100
From: Jonathan Barker <jonny@jonnysoft.co.uk>
Subject: Re: Random number
Message-Id: <3909CEAF.D670DE3F@jonnysoft.co.uk>
Does it really matter?!?
Andrew N. McGuire wrote:
> "Godzilla!" wrote:
> >
> > "Andrew N. McGuire" wrote:
> >
> > > "Godzilla!" wrote:
> >
> > > [ snip ]
> >
> >
> > > Mmm. No need for this, is there.
> >
> > > srand if $] < 5.004;
> >
> > > Mmmm, portable it is.
> >
> > " Even when you check and know what version of Perl
> > is in use, it is exceptionally wise to verify a
> > random number generator actually works."
>
> <yoda>
>
> Dispute that statement I did not...
> "Exceptionally wise" I would not say, Mmm.
> Wise, yes.
>
> perl -we 'srand if $] < 5.004; print rand'
>
> </yoda>
>
> [ aside: sorry, Star Wars on the brain ]
>
> Cheers,
>
> anm
> --
> Andrew N. McGuire
> andrew.mcguire@walgreens.com
------------------------------
Date: Fri, 28 Apr 2000 10:55:19 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Random number
Message-Id: <MPG.1373706359f4df5098a9a4@nntp.hpl.hp.com>
In article <3909BBFF.3FAF7DDE@stomp.stomp.tokyo> on Fri, 28 Apr 2000
09:27:43 -0700, Godzilla! <godzilla@stomp.stomp.tokyo> says...
...
Good of Godzilla! to post some Perl code, in addition to the usual
verbiage (which happens in this case to be reasonably cogent!).
> srand(time() ^ ($$ + ($$ << 15)));
> sub randcase
> {
> rand(40) < 20 ? "\u$1" : "\l$1" ;
40 and 20 are interesting (idiosyncratic :-) choices. Other choices:
rand < 0.5
int rand 2
> }
> $in{InlaHolisso} =~ s/([a-z])/randcase($1)/gie;
Either pass $1 to randcase and use it as an argument ($_[0]), or don't
pass it and use it as a global variable. What you show is schizoid.
...
> srand;
> $_ = (rand(@Adjectives)) * 100000000000;
> s/\..+//g;
How many decimal points do you expect (else why the /g modifier)? And
what about using the int() function, which is intended for this purpose?
> s/(\d\d?)/\1, /g;
The backreference should be written as $1, not \1. The '-w' flag would
warn about this archaic grandparented usage.
> chop($_);
> chop($_);
The above three lines might be written more compactly as:
$_ = join ', ' => /\d\d?/g;
...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 28 Apr 2000 15:55:07 GMT
From: amarodeeps@my-deja.com
Subject: Re: reading .ost files
Message-Id: <8ecc8i$3lt$1@nnrp1.deja.com>
"If there's a module which does what you want, it should be
listed in the module list on CPAN."
I'm sure that's true, and in fact, I've heard of CPAN!
However, I am at a loss as to what category this type
of module would fall under. I am also using activestate's
perl, and after I searched through all of the modules
that they package with their dist., I didn't find anything.
SO, a pointer in the direction of what category this module
would fall under, whether one might be written, who might
have written anything similar, what sites have this type
of information, etc. would be what I'm looking for. I'd
be glad to RTFM if I knew which FM to R.
"If you don't find one to your liking, you're
welcome and encouraged to submit one!"
I would love to, I just need some info to get me
on my way, like, where can I find a file specification
for an .ost file? (Microsoft's site yielded nothing
but support information telling you to back the file up.
They wouldn't actually tell you what the specification is)
That's really what I need, and if I had that, I would be
on my way to submitting a module to CPAN. Hmmm...though
upon consideration I guess that that specific question might
be somewhat off topic. I will post in some Microsoft
ng, I guess, but I'd appreciate any more info that
anyone might have on this.
Thanks again,
Dave
In article
<Pine.GSO.4.10.10004270847510.21722-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@redcat.com> wrote:
> On Thu, 27 Apr 2000 amarodeeps@my-deja.com wrote:
>
> > Does anyone know about reading .ost files with Perl?
>
> If there's a module which does what you want, it should be listed in
> the module list on CPAN. If you don't find one to your liking, you're
> welcome and encouraged to submit one! :-) Hope this helps!
>
> http://www.cpan.org/
> http://search.cpan.org/
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 28 Apr 2000 09:39:28 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: reading .ost files
Message-Id: <Pine.GSO.4.10.10004280936050.21722-100000@user2.teleport.com>
On Fri, 28 Apr 2000 amarodeeps@my-deja.com wrote:
> "If there's a module which does what you want, it should be
> listed in the module list on CPAN."
>
> I'm sure that's true, and in fact, I've heard of CPAN!
> However, I am at a loss as to what category this type
> of module would fall under.
Well, you can search CPAN.
http://search.cpan.org/
> "If you don't find one to your liking, you're
> welcome and encouraged to submit one!"
>
> I would love to, I just need some info to get me
> on my way, like, where can I find a file specification
> for an .ost file?
That sounds like you want to search for the docs, FAQs, and newsgroups
about programs which use .ost files.
> (Microsoft's site yielded nothing but support information telling you
> to back the file up. They wouldn't actually tell you what the
> specification is)
Maybe this is the time to go Open Source. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 2894
**************************************