[10730] in Perl-Users-Digest
Perl-Users Digest, Issue: 4329 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 1 03:07:50 1998
Date: Tue, 1 Dec 98 00:00:32 -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 Tue, 1 Dec 1998 Volume: 8 Number: 4329
Today's topics:
Re: Access Database <kohsuan@psychosphere.net>
browsing or paging jbeck@dolsun.dol.state.nj.us
Re: browsing or paging <ebohlman@netcom.com>
cgi permission <jjpark@home.com>
Re: Flushing <> <rra@stanford.edu>
Re: Help - cgi button to call browser's email program <adrian@PERLinternetxs.com>
Re: localtime () - perl's bug ? <crn@itga.com.au>
Re: localtime () - perl's bug ? <rra@stanford.edu>
Re: localtime () - perl's bug ? (Ethan H. Poole)
Re: localtime () - perl's bug ? (Larry Rosler)
MIME::LITE <beekmans@iae.nl>
post to perl using javascript <ours@casema.net>
Re: RegExp and Authentication Help. <ccyr@home.com>
seek, tell, offset question asheik@my-dejanews.com
Strip and add, perl style (Mark D.)
Re: Strip and add, perl style <ebohlman@netcom.com>
Re: Strip and add, perl style (Martien Verbruggen)
Re: Strip and add, perl style (Larry Rosler)
Re: target help <adrian@PERLinternetxs.com>
Weirdness with CPAN v1.40 and perl 5.005_2 on Linux <mschube@earthlink.net>
Weirdness with CPAN.pm v1.40, perl 5.005_2 and Linux <mschube@earthlink.net>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 30 Nov 1998 22:06:32 -0800
From: "Matthew Phillips" <kohsuan@psychosphere.net>
Subject: Re: Access Database
Message-Id: <740134$sc1$1@holly.prod.itd.earthlink.net>
To set up for Win32::ODBC web database connectivity:
Make skeleton database with dummy data
1. Set up ODBC driver (Access Driver in this case)
(check ODBC control panel,
under ODBC Drivers tab and see if it is there:
if it isn't add it by installing Access 97)
2. Copy your database file onto server or somewhere accessible
3. Make System DSN (that's Data Source Name) point to ODBC driver (if this
isn't done here is how to do it:
Go into ODBC control panel,
Select System DSN tab,
Click 'add' for a new System DSN,
Select the appropriate ODBC driver (MS Access in our case),
Press 'Finish',
Name the driver (press 'select' in the Database section,
and browse to the actual database file)
Press 'OK'
Here is a test script to see if your database and web server are talking
(they should be after all that!):
print "HTTP/1.0 200 OK\n";
print "Content-type: text/html\n\n";
# In order to access the database you must include the ODBC library file
that you just added.
#
use Win32::ODBC;
require "CGI.pm";
# Now you need to actually run a Query on the database and return any
records that match.
# It's nicer to do this in a little sub-routine, called 'searchDatabase',
which we'll define next.
# For now, just call it here.
#
&searchDatabase;
# The sub-routine handles the searching AND displaying of matching records,
so once it's done we can quit.
#
exit(0);
# This is where we will declare our sub-routine. It uses a SQL statement to
query the database and you'll have to
# modify this to suit your own database.
#
sub searchDatabase
{
$sql = "SELECT * FROM Table1";
$dsn = "name_of_your database";
$db = new Win32::ODBC($dsn);
$db->Sql($sql);
while ($db->FetchRow())
{
($rec1, $rec2, $rec3) = $db->Data("Field Name1", "Field
Name2", "Field Name3");
print "Record 1 = $rec1\n";
print "Record 2 = $rec2\n";
print "Record 3 = $rec3\n";
}
$db->Close();
}
NOW, will someone show me some code tht will do INSERT's?
matthew phillips
web developer
psychosphere hypermedia, inc.
http://www.psychosphere.net
----------
In article <3660216f.623476@news.netspace.net.au>, stus@netspace.net.au
(Stuart Summerville) wrote:
>On Wed, 18 Nov 1998 20:09:29 +0800, "Ho Seng Yip"
><hsengyip@(nospam)singnet.com.sg> wrote:
>
>>I am wondering if Perl can actually read and write data into / from a
>>Microsoft Access database.
>
>You can talk to Access databases using OLE. I'm currently trying to
>figure out how to do so. The examples directory in the ActiveState
>Perl distribution has some sample Excel perl scripts. MSAccess OLE is
>accessed in samee manner, just different method (??).
>
>Not sure what (if any) support the standard Perl5 has for OLE.
>
>I had a look through the DBC:: section of CPAN & didn't find much.
>
>As for myself - I'm relatively new to Perl, OLE, & Access - might as
>well jump in at (near??) the deep end. Any help appreciated.
>
>Stu.
>
>
------------------------------
Date: Tue, 01 Dec 1998 07:28:53 GMT
From: jbeck@dolsun.dol.state.nj.us
Subject: browsing or paging
Message-Id: <7405rc$qgc$1@nnrp1.dejanews.com>
In shell scripting, i'd use more (or less) if i wanted to read a long file
one screen at a time i'm finally making the commitment to learn perl and have
been using it quite a bit over the past month or so. i thought the answer
would be with he format command, but was unable to find it. anyone?
thanks,
joe
--
J Beck ext. 2-5785
jbeck@dolsun.dol.state.nj.us
Unix Administrator
Tax Redesign Project
(609)292-578
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 1 Dec 1998 07:50:58 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: browsing or paging
Message-Id: <ebohlmanF3A0Gy.91n@netcom.com>
jbeck@dolsun.dol.state.nj.us wrote:
: In shell scripting, i'd use more (or less) if i wanted to read a long file
: one screen at a time i'm finally making the commitment to learn perl and have
: been using it quite a bit over the past month or so. i thought the answer
: would be with he format command, but was unable to find it. anyone?
format is really for things like printing reports with headers and
footers, though it can be used anywhere you're generating output.
You can still use more and its relatives from Perl if you don't object to
forking off a new process for paged reading. If you haven't already done
so, read up on opening pipes for output. It's usually courteous to check
if $ENV{PAGER} exists and use its value as the name of the paging program
to pipe to. Use more if $ENV{PAGER} doesn't exist. Win32 systems
support more, albeit with some limitations due to the primitive pipe
system, at least in Win95 (far end doesn't start getting output until
near end closes pipe).
You could, of course, write your own paging code, but it seems to be
something that few people want to do.
------------------------------
Date: Tue, 01 Dec 1998 05:15:11 GMT
From: SilverCane <jjpark@home.com>
Subject: cgi permission
Message-Id: <36637B21.7FAE0216@home.com>
i have a *.db file on unix server and want to make the permission so
that the script can read, write, excute but people can't download the
database file using web browser. so what should the permission be?
or is there alternatives to protect the database from seeing by
strangers?
------------------------------
Date: 30 Nov 1998 21:07:58 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Flushing <>
Message-Id: <yl4srgo3f5.fsf@windlord.stanford.edu>
Morgan Curley <mcurley@newscorp.com> writes:
> I am in the process of writing a module that reads templates and uses
> the magical <>. Unfortuneately, I am finding that I get file overflow -
> if there is any data in the last file read with <> it comes across
> first. My question is, is there any way to flush <>, I am localizing
> @ARGV each time but that doesn't seem to help.
Er... this really doesn't make any sense to me. You mean you have a list
of files to read in @ARGV and you're reading from <> and you're getting
the data from the last file in the list before the other files? That
should not be possible; that isn't just a buffering problem. Something
very odd is going on there.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 1 Dec 1998 06:32:45 GMT
From: adrian <adrian@PERLinternetxs.com>
Subject: Re: Help - cgi button to call browser's email program
Message-Id: <36638DA6.74DD748F@PERLinternetxs.com>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Have you tried the idea of a script generated button with as anchor "<A HREF="mailto:me@work.com">mailto:me@work.com</A>",
or won't that work for you?
<br>
<p>-- remove the language from my domainname to email me --
<br>adrian@PERLinternetxs.com
<p>Dale Sutcliffe wrote:
<blockquote TYPE=CITE>I have a script that contains several different buttons,
one button I would like users to be able to click on and their browser's
email program
<br>appears for them to be able to email anyone a web page.
<br>For various reasons, it must be activated from a cgi script created
button and must not use formmail.
<br>Any ideas?
<br> Thanks.</blockquote>
</html>
------------------------------
Date: 01 Dec 1998 16:00:02 +1100
From: Clive Newall <crn@itga.com.au>
Subject: Re: localtime () - perl's bug ?
Message-Id: <v590gs78z1.fsf@itga.com.au>
Jarkko Hietaniemi <jhi@alpha.hut.fi> writes:
> Gareth Rees <garethr@cre.canon.co.uk> writes:
>
> > (*) Poor design decisions are bugs too.
>
> Definitely. I hope whoever designed the contents of struct tm feels
> really ashamed. There are at least three bad decisions. (1) The year
> has no good reason [1] to be -1900'ed. (2) The month has no good
> reason to be -1'ed [2]. (3) If the month is -1'ed, why not the day of the
> month?
>
> [1] "the seconds since 1900-01-01 fit better into a X-bit integer
> than the seconds since 1-01-01" is not a good reason. The library
> should worry about such details, the user shouldn't be punished
> for poor library implementation.
> [2] Neither is "it's so handy to access 0-based array month_name[month]".
> Shaving off the time/space required to do the -1 is silly.
New at this game, aren't you? When these decisions were made, every
clock cycle saved made significant difference. As did every byte of
precious memory saved. Often forgotten in these days of software bloat
and 100+MHz processors.
>
> But I am wasting my breath. We all know this and the stupid interface
> isn't going to change.
With good reason. Backwards compatibility.
Of course, you are (and always have been) free to implement your own
suite of calls (eg. my_better_localtime()) and return a nicer struct
in your code.
> Well, there's hope, though...the upcoming C9X
> standard has struct tmx which has extension mechanism,
> "The implementation or a future version of this International Standard
> may include further members in a separate object."
>
--
Clive Newall <crn@itga.com.au> / ITG Australia Ltd, Melbourne Australia
"I think Casper is the ghost of Richie Rich. I wonder how Richie died?"
"Perhaps he realized how hollow the pursuit of money is and took his own life"
--Bart and Lisa Simpson
------------------------------
Date: 30 Nov 1998 21:15:34 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: localtime () - perl's bug ?
Message-Id: <ylu2zgmoi1.fsf@windlord.stanford.edu>
Clive Newall <crn@itga.com.au> writes:
> New at this game, aren't you? When these decisions were made, every
> clock cycle saved made significant difference. As did every byte of
> precious memory saved. Often forgotten in these days of software bloat
> and 100+MHz processors.
I disbelieve this. struct tm was cast into its current form in the 1970s,
yes? I find it hard to believe the cost of an extra few bytes of memory
to offset the array by one element, or the cost of a subtraction, was that
overriding of a concern for machines even in the 1970s.
The 1960s, maybe.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Tue, 01 Dec 1998 06:23:44 GMT
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: localtime () - perl's bug ?
Message-Id: <QXL82.2508$td3.9747@news12.ispnews.com>
In article <ylu2zgmoi1.fsf@windlord.stanford.edu>, rra@stanford.edu says...
>
>Clive Newall <crn@itga.com.au> writes:
>
>> New at this game, aren't you? When these decisions were made, every
>> clock cycle saved made significant difference. As did every byte of
>> precious memory saved. Often forgotten in these days of software bloat
>> and 100+MHz processors.
>
>I disbelieve this. struct tm was cast into its current form in the 1970s,
>yes? I find it hard to believe the cost of an extra few bytes of memory
>to offset the array by one element, or the cost of a subtraction, was that
>overriding of a concern for machines even in the 1970s.
>
>The 1960s, maybe.
I would disagree, machines of the '70s were still *very* slow by the
standards most of us are familiar with. They also tended to have *very*
limited RAM (many office computer systems of the time had, for instance, 8KB
RAM or less), some still used magnetic memory cores, and any storage device
was almost universally dreadfully slow. Even a 1980 Commodore VIC-20 could
run circles around much larger '70s computers and yet we *still* had to
conserve memory and CPU cycles when writing programs for those early
hobby/home computers. When was the last time you can remember having to be
*seriously* concerned during design, implementation, and execution of an
application whether or not a singular 100 byte data structure (e.g. a
name, address, and a few dates) was likely to cause a memory overflow
condition? Oh, the 1980's were a wonderful decade for the developer - faster
CPUs, almost unimaginable (for the time) memory, so much nicer to work with!
- and then Windows came along and taught everyone that there was no such
thing as enough RAM (What did Gate's say about 640K?)!
Don't forget to take into consideration the tendency of business and
government (and individuals) to hold onto substantial investments. Many of
the mainframe computers of the 1970's *were* from the 1960's or earlier. You
should still be able to find a good many 1980's mainframes still in use by
businesses and lesser endowed universities and colleges *today*. In fact, at
this very moment I have a 1987 386DX20 running right next to a 1998 PII400,
so long as any computer can continue to fulfill a useful function, it has a
habit of sticking around to fill that need <g>.
And if you happen to work for the FAA, well...you'd probably give your first
born for a 1960's computer, especially if it used transistors rather
than tubes <eg>.
--
Ethan H. Poole | Website Design and Hosting,
| CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day--
| http://www.interact2day.com/
------------------------------
Date: Mon, 30 Nov 1998 22:39:57 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: localtime () - perl's bug ?
Message-Id: <MPG.10cd2f1529a32643989937@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <ylu2zgmoi1.fsf@windlord.stanford.edu> on 30 Nov 1998
21:15:34 -0800, Russ Allbery <rra@stanford.edu> says...
> Clive Newall <crn@itga.com.au> writes:
> > New at this game, aren't you? When these decisions were made, every
> > clock cycle saved made significant difference. As did every byte of
> > precious memory saved. Often forgotten in these days of software bloat
> > and 100+MHz processors.
> I disbelieve this. struct tm was cast into its current form in the 1970s,
> yes? I find it hard to believe the cost of an extra few bytes of memory
> to offset the array by one element, or the cost of a subtraction, was that
> overriding of a concern for machines even in the 1970s.
>
> The 1960s, maybe.
Mindsets about programming methodologies to conserve scarce machine
resources -- styles that may have been formed in the 1960s -- are hard
to overcome, even in the 1970s -- or perhaps in the 1990s, for that
matter.
Remember the 'Small is Beautiful' Unix mantra? Small was Beautiful
because Small was all there was. (Unix didn't run on Big Iron then.)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 01 Dec 1998 08:56:21 +0100
From: Marcel Beekmans <beekmans@iae.nl>
Subject: MIME::LITE
Message-Id: <3663A125.C10C7E64@iae.nl>
Hello,
I'm using the Mime::Lite module an came up with the following problem:
All the attachments I make are converted to text, so a image (where I
use type => 'image/gif') is at the reciepient no image anymore, it
becomes something like:
///////?#?#?#?/3#?/3?@!@#?$??$?$?
?#?#?$?$??#?#?$??$?$?#??#?$??@
and so on.
I'm working on a Windows NT system. Does anyone know what I did wrong or
how I can make it work correctly?
Greetings,
Marcel Beekmans
Http://www.effector.nl
------------------------------
Date: Mon, 30 Nov 1998 20:25:15 +0100
From: "Casema" <ours@casema.net>
Subject: post to perl using javascript
Message-Id: <74044s$ru7$2@sun4000.casema.net>
I am posting this question to the three relevant newsgroups and hope to get
an answer....
How do you post to a perl proggie using javascript?
so,
<FORM ACTION="http:www.test.com/cgi-bin/test.pl" METHOD="POST">
has to become
function posting() {
###statements to post to same address as in form action###
}
so that the result would be exactly thesame when read by the perl proggie.
Thanks,
Michel
------------------------------
Date: Tue, 01 Dec 1998 06:31:28 GMT
From: Colin Cyr <ccyr@home.com>
Subject: Re: RegExp and Authentication Help.
Message-Id: <36638DC2.3E1DAA36@home.com>
Tad McClellan wrote:
>
> Colin Cyr (ccyr@home.com) wrote:
>
> : $data = "243";
> : $data =~ /^\d$/; # How'd I add the additional condition that
> : # it is a Real number (Nothing less than 1)?
>
> You seem to be using a non-standard meaning of "real number".
>
Okay, so maybe I have to stop writing my messages at 3AM... This isn't
the first time people have had trouble understanding them. ;) The other
thing I wasn't expecting was the degree in which you wanted me to
specify _ever_ detail, however I can see the requirement if you want to
help me use a precise regexp.
Let's start with the RegExp.
Format:
- Each section must be separated with a period (".").
- An identifier, composed of sections and section separators ("."), can
not start or end with a section separator.
Section Definition:
- Each section must be composed of a Rational (Q) number (see this is
where I errored in the first message).
- Being a rational number, it must be a positive, non-zero, integer (by
definition).
- Each section must be stated in its most minimal form. This means that
there can be absolutely no padding of any form.
> Your regex above will match one of only ten strings. Did
> you mean to allow more than one digit? /^\d+$/;
And it looks like the above will almost wirk, but it fails on the cannot
be zero or have non-signifigant zeros.
> $data = '243.3.2.1.4'; # single quotes
Thanks for the tip, it's a habit from those other languages. I still
have the knee-jerk reaction to believing apostrophies mean characters.
>
> : $data =~ /????/; # Nothing I've tried will allow me to verify
> : # this. Each section must be a Real, and the
> : # string cannot start or end with a period.
>
> To verify that each "section" consists of only digit characters:
>
> print "$data is OK\n" if $data =~ /^\d+(:?\.\d+)*$/;
I will need to further digest the above.
> You need to be more rigorous in describing what you want if
> you want to get a directly usable answer...
And now you have it. ;) See above.
I don't think finding the regexps for converting the globs to regexps
should be all that difficult. Once I have something working for the
above the rest shouldn't be a problem.
Now just to figure out RPC Authentication.
If anyone else would like me to clearify what I think I was saying for
Authentication... I can rephrase/clearify it for you.
Thanks again for all the help.
--
Colin Cyr (ccyr at home dot com)
------------------------------
Date: Tue, 01 Dec 1998 06:54:31 GMT
From: asheik@my-dejanews.com
Subject: seek, tell, offset question
Message-Id: <7403r4$ot2$1@nnrp1.dejanews.com>
hi, help with the following will be greatly appreciated. maybe this issue has
been addressed before, but i couldnt find related info.
i have a monthly log
file in which some data follows the date.i want to seek to a particular date
and print everything "after" that date.this is what i've tried:
open the
fileif (/^1130) { $filePosition = tell;}
print $filePosition;
seek($filename, $filePosition,0);print the rest of the file
#here 1130 is
the date i am looking for, and $. (dollar dot) can be used in place of tell.
tell returns a long number which seek() never finds. If i print $filePosition
and extract a reasonable $filePosition value from it and pass that static
value to seek(), then seek finds it and starts printing the line following
the date line in an infinite loop.
i think my usage of tell is wrong since
the value passed to $filePosition is the actual value repeated many times.
But using a static value for seek works around it, but then the usage of seek
might be wrong too since it keeps printing only one line in a loop.any
suggestions, help ??sincerely,
atif
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 01 Dec 1998 05:30:32 GMT
From: mark@doddx.com (Mark D.)
Subject: Strip and add, perl style
Message-Id: <36647ed7.24576685@news.supernews.com>
Hello;
I havent been able to figure this one out and I was hoping someone
could help me along- I want to simplify the string below and then have
it append a 5 digit random number to the string. How is this possible?
$cgi_client{'foo'} =~ s/\s+//g;
$cgi_client{'foo'} =~ s/\&//;
$cgi_client{'foo'} =~ s/\.html//;
$cgi_client{'foo'} =~ s/\)//;
$cgi_client{'foo'} =~ s/\(//;
The code above strips the string of all spaces, ampersands, .html,
and brackets. It is used in an upload routine and I want to ensure the
file name is truly unique as well.
srand( time() ^ ($$ + ($$ << 15)) );
$cgi_client{'foo'} = $cgi_client{'foo'} . (int(rand(100000)) + 1);
This adds a random number to the end of a string. how do I add it to
the beginning instead?
Sorry if this is not up to speed, I'm a newbie.
Thank you,
Mark
(remove x to reply via email)
------------------------------
Date: Tue, 1 Dec 1998 05:47:59 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Strip and add, perl style
Message-Id: <ebohlmanF39urz.2Lr@netcom.com>
Mark D. <mark@doddx.com> wrote:
: I havent been able to figure this one out and I was hoping someone
: could help me along- I want to simplify the string below and then have
: it append a 5 digit random number to the string. How is this possible?
: $cgi_client{'foo'} =~ s/\s+//g;
: $cgi_client{'foo'} =~ s/\&//;
: $cgi_client{'foo'} =~ s/\.html//;
: $cgi_client{'foo'} =~ s/\)//;
: $cgi_client{'foo'} =~ s/\(//;
: The code above strips the string of all spaces, ampersands, .html,
No it doesn't. It will strip all spaces, but will only strip the first
occurrence of any of the other junk.
$cgi_client{foo} =~ s/[&()\s]|\.html//gi;
1) Literal hash keys don't need to be quoted.
2) I assume you want '.HTML', '.HtMl', etc. to be stripped as well, thus
the 'i' modifier.
: and brackets. It is used in an upload routine and I want to ensure the
: file name is truly unique as well.
:
: srand( time() ^ ($$ + ($$ << 15)) );
: $cgi_client{'foo'} = $cgi_client{'foo'} . (int(rand(100000)) + 1);
: This adds a random number to the end of a string. how do I add it to
: the beginning instead?
Just reverse the order of the operands to '.'
: Sorry if this is not up to speed, I'm a newbie.
Taking a look at the perlre and perlop (man pages || POD || HTML) will
speed up your denewbification.
------------------------------
Date: Tue, 01 Dec 1998 05:49:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Strip and add, perl style
Message-Id: <2sL82.250$5g3.698@nsw.nnrp.telstra.net>
In article <36647ed7.24576685@news.supernews.com>,
mark@doddx.com (Mark D.) writes:
> srand( time() ^ ($$ + ($$ << 15)) );
> $cgi_client{'foo'} = $cgi_client{'foo'} . (int(rand(100000)) + 1);
>
> This adds a random number to the end of a string. how do I add it to
> the beginning instead?
$cgi_client{'foo'} = (int(rand(100000)) + 1) . $cgi_client{'foo'};
Did you try anything before posting?
this doesn't guarantee uniqueness though, and neither does your
attempt. It just makes it very likely that it is unique.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd. | network - Mitchell Kapor
NSW, Australia |
------------------------------
Date: Mon, 30 Nov 1998 22:58:45 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Strip and add, perl style
Message-Id: <MPG.10cd33846ec690e0989938@nntp.hpl.hp.com>
In article <36647ed7.24576685@news.supernews.com> on Tue, 01 Dec 1998
05:30:32 GMT, Mark D. <mark@doddx.com> says...
> ... I want to simplify the string below and then have
> it append a 5 digit random number to the string.
...
> srand( time() ^ ($$ + ($$ << 15)) );
srand( time() ^ ($$ + ($$ << 15)) )
if $] < 5.004;
> $cgi_client{'foo'} = $cgi_client{'foo'} . (int(rand(100000)) + 1);
This produces a random number between 1 (one digit) and 100000 (six
digits) -- but 90% of them *are* five digits :-). To produce a five-
digit number always, either:
int(rand(90000)) + 10000
or, if leading zeros are acceptable:
sprintf '%.5d', int(rand(99999)) + 1
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 1 Dec 1998 06:56:29 GMT
From: adrian <adrian@PERLinternetxs.com>
Subject: Re: target help
Message-Id: <36639336.9D943CFF@PERLinternetxs.com>
I don't know how you've made your script and pages, I'd probably use Javascript to "put" the cgi script in either a new frame
or a new page.
The output of the script would then only need to have [ print "Content-type: text/html", "\n\n" ] at the start.
-- remove the language from my domainname to email me --
adrian@PERLinternetxs.com
Dale Sutcliffe wrote:
> I would like the option to display results in either a separate frame or a new window, depending upon the users' selection.
> I've tried:
> print "Location: ".$str."\n\ntarget=\"Display\"\n\n";
>
> (display is the name of the second frame)
> and for the new window:
>
> print "Content-type: text/html\ntarget=\"_blank\"\n\n";
>
> Neither seem to work.
------------------------------
Date: Tue, 1 Dec 1998 01:23:55 -0500
From: Max Schubert <mschube@earthlink.net>
Subject: Weirdness with CPAN v1.40 and perl 5.005_2 on Linux
Message-Id: <Pine.LNX.4.05.9812010058250.1521-100000@mschube.earthlink.net>
Hi all,
I am experiencing an interesting problem when running the CPAN shell
under perl 5.005_2 on Caldera OpenLinux 1.1 ... using the install command
calls Net::FTP properly and source files are downloaded to the local host,
but then weird things happen and the whole thing hangs ... the process is
something like this ...
tar.gz file is retrieved ...
I see the output as it is gunzipped and untarred ...
Then I see the usual message about "going to build nnn.pm ... "
Then I get
make *** No targets specified and no makefile found. Stop.
Then messages from CPAN about make failing:
THEN I see the output from perl Makefile.PL:
Checking to see if your kit is complete ...
Looks good ...
Then the perl Makefile.PL process hangs till I SIGINT my way out.
So it appears that make is being called before the perl Makefile.PL is
done running to create the Makefile ...
Now, I could look at the source, but I thought some of you may have
experienced this before and know a fix. I know how to download and install
modules manually, but being a "good" programmer I am being lazy about it :).
Thanks for the help,
-- Max
------------------------------
Date: Tue, 1 Dec 1998 01:34:55 -0500
From: Max Schubert <mschube@earthlink.net>
Subject: Weirdness with CPAN.pm v1.40, perl 5.005_2 and Linux
Message-Id: <Pine.LNX.4.05.9812010127350.11545-100000@mschube.earthlink.net>
Hi all,
I am experiencing an interesting problem when running the CPAN shell
under perl 5.005_2 on Caldera OpenLinux 1.1 ... using the install command
calls Net::FTP properly and source files are downloaded to the local host,
but then weird things happen and the whole thing hangs ... the process is
something like this ...
tar.gz file is retrieved ...
I see the output as it is gunzipped and untarred ...
Then I see the usual message about "going to build nnn.pm ... "
Then I get
make *** No targets specified and no makefile found. Stop.
Then messages from CPAN about make failing:
THEN I see the output from perl Makefile.PL:
Checking to see if your kit is complete ...
Looks good ...
Then the perl Makefile.PL process hangs till I SIGINT my way out.
So it appears that make is being called before the perl Makefile.PL is
done running to create the Makefile ...
Now, I could look at the source, but I thought some of you may have
experienced this before and know a fix. I know how to download and install
modules manually, but being a "good" programmer I am being lazy about it :).
Thanks for the help,
-- Max
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4329
**************************************