[13999] in Perl-Users-Digest
Perl-Users Digest, Issue: 1409 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 17 18:12:58 1999
Date: Wed, 17 Nov 1999 15:05:27 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942879926-v9-i1409@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 17 Nov 1999 Volume: 9 Number: 1409
Today's topics:
Re: "if" statement not working correctly <rootbeer@redcat.com>
Re: backticks or system() (Brett W. McCoy)
Re: backticks or system() <mosheh@post.net>
Call C function from perl weiq@cs.dal.ca
Re: Call C function from perl (Kragen Sitaker)
Re: Call for Programs: the "phonecode" benchmark <lr@hpl.hp.com>
Re: Call for Programs: the "phonecode" benchmark <cassell@mail.cor.epa.gov>
Re: Call for Programs: the "phonecode" benchmark <sariq@texas.net>
Re: Call for Programs: the "phonecode" benchmark <gellyfish@gellyfish.com>
Can't find manpage for getkey func. mentioned in map ma <sigurd.schioth@ilf.uio.no>
Re: Can't find manpage for getkey func. mentioned in ma (Kragen Sitaker)
Re: Can't find manpage for getkey func. mentioned in ma <lr@hpl.hp.com>
Re: CGI Error... (Kragen Sitaker)
compiling module pgsql_perl5-1.8.1 on redhat 6.1 rknaak@my-deja.com
Re: cron filehandle <cassell@mail.cor.epa.gov>
Re: cron filehandle (Kragen Sitaker)
Re: Date & Time <cassell@mail.cor.epa.gov>
Date localtime help...Newbie crackbaby1@my-deja.com
Re: Date localtime help...Newbie <tyndiuk@ftls.org>
Re: Date localtime help...Newbie <lr@hpl.hp.com>
Re: Date localtime help...Newbie (Kragen Sitaker)
Re: Date localtime help...Newbie <lr@hpl.hp.com>
Re: Date localtime help...Newbie <sariq@texas.net>
Re: Date localtime help...Newbie (Kragen Sitaker)
Re: Date localtime help...Newbie <lr@hpl.hp.com>
Re: Date localtime help...Newbie <lr@hpl.hp.com>
Re: Date localtime help...Newbie <gellyfish@gellyfish.com>
Re: Date localtime help...Newbie <sariq@texas.net>
Re: Date Of Birth from TODAY (John G Dobnick)
Re: DBD::Oracle <aschmied@earthlink.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 17 Nov 1999 09:06:42 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: "if" statement not working correctly
Message-Id: <Pine.GSO.4.10.9911170854110.15797-100000@user2.teleport.com>
On Wed, 17 Nov 1999, Stuart Pedler wrote:
> What I am trying to achieve is to load a directory tree into an array,
> change into each of those directories and test for the presence of another
> directory with a name beginning "lib_" . If this directory exists, change
> back to the root and remove the directory as held in the array.
It sounds as if you want to have an array of names of directories which
don't contain a lib_* subdirectory. But maybe I've misunderstood.
> chdir $pkgbase ;
Just as with opening a file, you should _always_ check the return value
after changing directories. After all, if you're not in the expeted
directory, whatever you're about to do isn't going to work correctly.
> @packages = sort glob("$pkgbase\\ESCOM_*");
You shouldn't need to sort the return value from that glob. It should
already be sorted, unless you have something strange and misleading in
$pkgbase.
> for ($index=0; $index <=$#packages; $index++)
Probably this should be a foreach loop on @packages. But that's not
_wrong_, just more like C than Perl.
> if (glob("LIB_*"))
You're using glob() in a scalar context. I don't think it's doing what you
think it's doing. Generally, if you use glob() in a scalar context, it
should be inside the conditional of a 'while' loop.
> use File::Path;
It's generally best to put a 'use' like this at the top of your source
file, for a variety of reasons.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 17 Nov 1999 21:03:13 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: backticks or system()
Message-Id: <slrn83664p.cba.bmccoy@moebius.foiservices.com>
Also Sprach natureboy <robert.castellowNOroSPAM@s1.com.invalid>:
>are there any differences (besides syntax) between using
>backticks and system functions?
Quite so. Have you read the documentation?
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Wed, 17 Nov 1999 14:25:00 -0800
From: Gregor Mosheh <mosheh@post.net>
Subject: Re: backticks or system()
Message-Id: <38332B3C.DF0624A2@post.net>
The big diff is that system() performs the action and returns the exit status
* 256, and `` performs the action and returns an array containing the text
output of the command.
Thus:
$x = system("ls") would set $x to 0 (if the ls worked)
@x = `ls` would set @x to contain the list ('file1', 'file2',
'another_file');
Jonathan Stowe wrote:
> natureboy <robert.castellowNOroSPAM@s1.com.invalid> wrote:
> > are there any differences (besides syntax) between using
> > backticks and system functions?
> >
>
> Er yes, what does it say in the perlfunc and perlop manpages - I dont have
> mine handy right now.
>
> /J\
> --
> "While they're pumping, you're soaking them" - Speed Loader TV Advert
------------------------------
Date: Wed, 17 Nov 1999 18:55:04 GMT
From: weiq@cs.dal.ca
Subject: Call C function from perl
Message-Id: <80utm6$889$1@nnrp1.deja.com>
Good Day everyone
I try to call a C function (compiled executable code)
passed one variable $Q_passed and return one varialbe $Q_return
$Q_return = `C_function $Q_passed`;
It works perfectly fine in command line:------
perl my_perl_program.cgi and returned the value I need
however, it can not return any value from web browser. I would be very
grateful if anyone could help me solve this problem.
Thanks a lot!
Wei
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 Nov 1999 20:38:16 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Call C function from perl
Message-Id: <YmEY3.22011$YI2.997442@typ11.nn.bcandid.com>
In article <80utm6$889$1@nnrp1.deja.com>, <weiq@cs.dal.ca> wrote:
>I try to call a C function (compiled executable code)
>passed one variable $Q_passed and return one varialbe $Q_return
> $Q_return = `C_function $Q_passed`;
>It works perfectly fine in command line:------
> perl my_perl_program.cgi and returned the value I need
>
>however, it can not return any value from web browser. I would be very
>grateful if anyone could help me solve this problem.
Is C_function in your $PATH? Both from command line and from CGI?
What do you do with $Q_return? Do you print it out? Maybe C_function
is outputting to standard error then?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 17 Nov 1999 11:05:46 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Call for Programs: the "phonecode" benchmark
Message-Id: <MPG.129c9c673a604c2198a21d@nntp.hpl.hp.com>
In article <80ua7t$mar$1@news.rz.uni-karlsruhe.de> on 17 Nov 1999
13:23:09 GMT, Lutz Prechelt <prechelt@ira.uka.de> says...
> - Out of the following set of scripting languages:
> Perl, Python, Rexx, Tcl
How odd. I just wrote this in another thread five minutes ago, so I'll
cut and paster it out of my outbox.
Perl is a programming language, and things written using Perl are Perl
programs. Some languages have 'script' in their names, and you can call
things written using them scripts; but Perl isn't one of them.
> o How do the scripting languages compare to standard programming
> languages such as C or Java?
What is there about Perl that distinguishes it from 'standard
programming languages such as C or Java'?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 17 Nov 1999 12:09:02 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Call for Programs: the "phonecode" benchmark
Message-Id: <38330B5E.397270C8@mail.cor.epa.gov>
Lutz Prechelt wrote:
>
> Hi all,
>
> - Out of the following set of scripting languages:
> Perl, Python, Rexx, Tcl
> do you prefer one over the others?
> - Do you think one is inherently better than the others?
> - Or aren't you sure?
Or are you worried by the fact that he uses Perl 5.003 as the
base version for his test? [That's what his webpage says.]
I'll bet that his C and C++ compilers aren't that old.
I'll bet big wads of quatloos that his *Java* compiler isn't.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 17 Nov 1999 14:33:03 -0600
From: Tom Briles <sariq@texas.net>
Subject: Re: Call for Programs: the "phonecode" benchmark
Message-Id: <383310FF.3727D4D9@texas.net>
Lutz Prechelt wrote:
>
> Hi all,
>
> - Out of the following set of scripting languages:
> Perl, Python, Rexx, Tcl
> do you prefer one over the others?
<snip>
> I would now like to extend this investigation to scripting languages:
>
> o Are differences between implementations using the same language
> smaller or even larger than for "standard" programming languages?
>
> o Do systematic differences between different scripting languages
> exist?
>
> o How do the scripting languages compare to standard programming
> languages such as C or Java?
>
Oh my god...it's the return of topmind...
- Tom
------------------------------
Date: 17 Nov 1999 21:13:56 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Call for Programs: the "phonecode" benchmark
Message-Id: <80v5qk$450$1@gellyfish.btinternet.com>
On Wed, 17 Nov 1999 11:05:46 -0800 Larry Rosler wrote:
> In article <80ua7t$mar$1@news.rz.uni-karlsruhe.de> on 17 Nov 1999
> 13:23:09 GMT, Lutz Prechelt <prechelt@ira.uka.de> says...
>> - Out of the following set of scripting languages:
>> Perl, Python, Rexx, Tcl
>
> How odd. I just wrote this in another thread five minutes ago, so I'll
> cut and paster it out of my outbox.
>
> Perl is a programming language, and things written using Perl are Perl
> programs. Some languages have 'script' in their names, and you can call
> things written using them scripts; but Perl isn't one of them.
>
Indeed of those languages cited above only Tcl could be fairly called a
'Scripting language' as that appears to be the intention of its creator
for it to be called that - I dont even think that the idea existed when
Rexx was born or Perl for that matter - Rexx in essence was born in
an older tradition of 'control languages' and programs written in say JCL or
SCL were called CLs if not called programs ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 17 Nov 1999 22:14:06 +0100
From: Sigurd Schi|th <sigurd.schioth@ilf.uio.no>
Subject: Can't find manpage for getkey func. mentioned in map manpage
Message-Id: <38331A9E.D9128C89@ilf.uio.no>
Example from map manpage:
%hash = map { getkey($_) => $_ } @array;
Can't find any manpage for that getkey function (at
http://www.cpan.org/doc/manual/html/pod/perl.html).
Did someone forget to put it in the manual, or is it
not a real function (a meta-function, if it is possible to call it that.
Or a pseudo-function, perhaps).
--
sig.
------------------------------
Date: Wed, 17 Nov 1999 21:28:44 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Can't find manpage for getkey func. mentioned in map manpage
Message-Id: <g6FY3.22069$YI2.1003442@typ11.nn.bcandid.com>
In article <38331A9E.D9128C89@ilf.uio.no>,
Sigurd Schi|th <sigurd.schioth@ilf.uio.no> wrote:
>Example from map manpage:
>%hash = map { getkey($_) => $_ } @array;
>
>Can't find any manpage for that getkey function (at
>http://www.cpan.org/doc/manual/html/pod/perl.html).
>Did someone forget to put it in the manual, or is it
>not a real function (a meta-function, if it is possible to call it that.
A metasyntactic function. Perhaps it should have been called "walnuts"
or "foobar" to make that clear.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 17 Nov 1999 13:47:31 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Can't find manpage for getkey func. mentioned in map manpage
Message-Id: <MPG.129cc251843e529798a224@nntp.hpl.hp.com>
In article <38331A9E.D9128C89@ilf.uio.no> on Wed, 17 Nov 1999 22:14:06
+0100, Sigurd Schi|th <sigurd.schioth@ilf.uio.no> says...
> Example from map manpage:
>
> %hash = map { getkey($_) => $_ } @array;
>
> Can't find any manpage for that getkey function (at
> http://www.cpan.org/doc/manual/html/pod/perl.html).
> Did someone forget to put it in the manual, or is it
> not a real function (a meta-function, if it is possible to call it that.
>
> Or a pseudo-function, perhaps).
s/getkey/foobar/;
It is a meta-function.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 17 Nov 1999 19:02:25 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: CGI Error...
Message-Id: <5ZCY3.21898$YI2.987660@typ11.nn.bcandid.com>
In article <3832CDBD.821A925C@fedex.com>,
James L. Gordon <jlgordon@fedex.com> wrote:
> Load the program up in vi and you should see the ^M character at the
>end of each line.
Some versions of vi (e.g. vim) will just recognize this and use CRLF
to terminate lines, without telling you. In vim, you can :set notx and
then save the file to remove CRLF.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 17 Nov 1999 20:05:36 GMT
From: rknaak@my-deja.com
Subject: compiling module pgsql_perl5-1.8.1 on redhat 6.1
Message-Id: <80v1qd$bi8$1@nnrp1.deja.com>
I downloaded the pgsql_perl5-1.8.1 module from CPAN and when can create
the makefile ok, but when I try to run make I get this message.
It is a fresh server install of redhat 6.1
cc -c -I/include -I/usr/local/include/pgsql -I/usr/include/pgsql -
Dbool=char -DH
AS_BOOL -I/usr/local/include -O2 -DVERSION=\"1.7.3\" -
DXS_VERSION=\"1.7.3\" -
fpic -I/usr/lib/perl5/5.00503/i386-linux/CORE Pg.c
Pg.xs: In function `XS_Pg_PQexec':
Pg.xs:321: sizeof applied to an incomplete type
Pg.xs: In function `XS_PG_conn_exec':
Pg.xs:755: sizeof applied to an incomplete type
make: *** [Pg.o] Error 1
Any ideas??
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 Nov 1999 11:52:38 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: cron filehandle
Message-Id: <38330786.FE0D3819@mail.cor.epa.gov>
Kragen Sitaker wrote:
>
> In article <38309F53.5A21F053@mail.cor.epa.gov>,
> David Cassell <cassell@mail.cor.epa.gov> wrote:
> >cron doesn't run under the same environment as your username.
> >Different home directory, different environment, different
> >privileges, ...
>
> ITYM 'different current directory', no?
Yup.
> How are privileges different? On a vanilla Unix system where users
> typically belong to a single group, and there are no Kerberos or DCE or
> AFS or Coda tokens, they should be the same.
You have systems like that? Other than your home box, I mean.
We have about 140 different groups defined on our networks,
and cron doesn't belong to many of them. Even if group privs
weren't a problem, the first time cron encountered a file
created by username fred with privs 0700, what's going to happen
when it tries to write to the file?
I didn't even consider Kerberos et al. Good points.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 17 Nov 1999 20:47:29 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: cron filehandle
Message-Id: <BvEY3.22022$YI2.998781@typ11.nn.bcandid.com>
In article <38330786.FE0D3819@mail.cor.epa.gov>,
David Cassell <cassell@mail.cor.epa.gov> wrote:
>Kragen Sitaker wrote:
>> How are privileges different? On a vanilla Unix system where users
>> typically belong to a single group, and there are no Kerberos or DCE or
>> AFS or Coda tokens, they should be the same.
>
>You have systems like that? Other than your home box, I mean.
Well, the Solaris box at work is like that. The Solaris box for my
shell at my ISP is like that. My home box actually isn't like that; it
has one group per user, plus a "users" group, which is a far more
sensible setup. (It makes it reasonable to umask 007 or 002.)
>We have about 140 different groups defined on our networks,
>and cron doesn't belong to many of them.
cron normally runs as root. Running a cron job on my work box shows
that it sets me to my normal login group ("users") when it runs my
jobs. Root is not a member of "users".
I wouldn't be surprised -- although I would consider it suboptimal
behavior -- if cron did not set up the groups as with a normal login.
>Even if group privs
>weren't a problem, the first time cron encountered a file
>created by username fred with privs 0700, what's going to happen
>when it tries to write to the file?
It will run fred's cron jobs as fred, so that will be OK. Running them
as root would be bad.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 17 Nov 1999 12:00:57 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Date & Time
Message-Id: <38330979.69DF37F6@mail.cor.epa.gov>
Martien Verbruggen wrote:
>
> On 16 Nov 1999 20:39:19 -0600,
> Abigail <abigail@delanet.com> wrote:
>
> > my $SERVER = "your.server.com";
>
> my server is your server? My... how friendly of you :)
It's the modern version of 'mi casa es su casa'.
"mi deja es su deja"
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 17 Nov 1999 18:36:44 GMT
From: crackbaby1@my-deja.com
Subject: Date localtime help...Newbie
Message-Id: <80usjs$7if$1@nnrp1.deja.com>
I just need to create a varaible with todays date in it...
this is what I have:
$updated_on = ???
this is what I need:
$updated_on = "19991117"
thank you...
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 Nov 1999 20:00:03 +0100
From: Frederic TYNDIUK <tyndiuk@ftls.org>
To: crackbaby1@my-deja.com
Subject: Re: Date localtime help...Newbie
Message-Id: <3832FB33.C841A843@ftls.org>
You can use this :
my($day,$month,$year) =
(localtime(time))[3..5];
$Year += 1900;
$month++;
if ($day < 10) { $day = "0".$day;
}
if ($month < 10) { $month = "0".$month;
}
$updated = $year.$mouth.$day;
Bye
FTLS
crackbaby1@my-deja.com wrote:
>
> I just need to create a varaible with todays date in it...
>
> this is what I have:
> $updated_on = ???
>
> this is what I need:
> $updated_on = "19991117"
>
> thank you...
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
*-----------------------------------------------------------*
| FTLS E-Mail: - tyndiuk@ftls.org |
|(TYNDIUK Frederic) |
| WWW : - http://www.ftls.org/ |
| CGI Scripts Archives : - http://www.ftls.org/cgi/ |
*-----------------------------------------------------------*
------------------------------
Date: Wed, 17 Nov 1999 11:10:56 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Date localtime help...Newbie
Message-Id: <MPG.129c9d9cbb96060b98a21e@nntp.hpl.hp.com>
In article <80usjs$7if$1@nnrp1.deja.com> on Wed, 17 Nov 1999 18:36:44
GMT, crackbaby1@my-deja.com <crackbaby1@my-deja.com> says...
> I just need to create a varaible with todays date in it...
>
> this is what I have:
> $updated_on = ???
>
> this is what I need:
> $updated_on = "19991117"
perldoc -f localtime
perldoc -f sprintf
You can also use the POSIX strftime function, but the above will
suffice.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 17 Nov 1999 20:03:01 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Date localtime help...Newbie
Message-Id: <VRDY3.21988$YI2.994383@typ11.nn.bcandid.com>
In article <80usjs$7if$1@nnrp1.deja.com>, <crackbaby1@my-deja.com> wrote:
>this is what I have:
>$updated_on = ???
>
>this is what I need:
>$updated_on = "19991117"
Hmm, you could do
my $updated_on = sprintf "%.4d%.2d%.2d",
map { ((localtime)[3..5])[$_] + (0, 1, 1900)[$_] } 2, 1, 0;
but I think this could be considered obscure and overly APLish. To do
it more clearly, I'd do
my ($day, $month, $year) = (localtime)[3..5];
my $updated_on = sprintf "%.4d%.2d%.2d", $year + 1900, $month + 1, $day;
You'd think this would be in the FAQ, but it doesn't seem to be.
This code has a potential Y10K problem -- the output will become one
digit longer in the year 10000 A.D.
Bravo to Crack Baby for using the ISO-8601 standard date format. May I
suggest using "%.4d-%.2d-%.2d" instead, e.g. 1999-11-17? It's also OK
according to ISO-8601, and it has the other advantages of the
eight-digit format, but it's more readable, and is visually
identifiable as a date.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 17 Nov 1999 12:37:52 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Date localtime help...Newbie
Message-Id: <MPG.129cb1f8deab602198a220@nntp.hpl.hp.com>
In article <VRDY3.21988$YI2.994383@typ11.nn.bcandid.com> on Wed, 17 Nov
1999 20:03:01 GMT, Kragen Sitaker <kragen@dnaco.net> says...
> In article <80usjs$7if$1@nnrp1.deja.com>, <crackbaby1@my-deja.com> wrote:
> >this is what I have:
> >$updated_on = ???
> >
> >this is what I need:
> >$updated_on = "19991117"
>
> Hmm, you could do
> my $updated_on = sprintf "%.4d%.2d%.2d",
> map { ((localtime)[3..5])[$_] + (0, 1, 1900)[$_] } 2, 1, 0;
What, pray tell, is the functionality of the '.4' specifier in this
format? Penalize yourself two strokes for that!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 17 Nov 1999 14:28:18 -0600
From: Tom Briles <sariq@texas.net>
Subject: Re: Date localtime help...Newbie
Message-Id: <38330FE2.C9A8576F@texas.net>
Frederic TYNDIUK wrote:
*Please* don't post Jeopardy style. Responses should go *after* the
text to which they're responding.
> You can use this :
Yes, you can. But it's not likely to work.
> my($day,$month,$year) =
> (localtime(time))[3..5];
Useless use of 'time'. Heh.
> $Year += 1900;
Hmmm...didn't test it, or didn't cut-n-paste.
But still an improvement on "$Year='19'.$Year;", I suppose.
> $month++;
> if ($day < 10) { $day = "0".$day;
> }
> if ($month < 10) { $month = "0".$month;
> }
Uggh.
> $updated = $year.$mouth.$day;
Hmmm...more misspellings.
> crackbaby1@my-deja.com wrote:
> >
> > I just need to create a varaible with todays date in it...
> >
> > this is what I have:
> > $updated_on = ???
> >
> > this is what I need:
> > $updated_on = "19991117"
> >
You've been told in the past to read some documentation before posting.
You did do that, didn't you?
Try:
perldoc -f localtime
perldoc -f sprintf
my ($day,$mon,$year) = (localtime)[3..5];
my $updated_on = sprintf('%4d%2d%2d', 1900+$year, ++$mon, $day);
- Tom
------------------------------
Date: Wed, 17 Nov 1999 20:55:01 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Date localtime help...Newbie
Message-Id: <FCEY3.22029$YI2.982547@typ11.nn.bcandid.com>
In article <MPG.129cb1f8deab602198a220@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>In article <VRDY3.21988$YI2.994383@typ11.nn.bcandid.com> on Wed, 17 Nov
>1999 20:03:01 GMT, Kragen Sitaker <kragen@dnaco.net> says...
>> Hmm, you could do
>> my $updated_on = sprintf "%.4d%.2d%.2d",
>> map { ((localtime)[3..5])[$_] + (0, 1, 1900)[$_] } 2, 1, 0;
>
>What, pray tell, is the functionality of the '.4' specifier in this
>format? Penalize yourself two strokes for that!
It's so we'll have a four-digit year, even for years before 1000.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 17 Nov 1999 13:16:25 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Date localtime help...Newbie
Message-Id: <MPG.129cbaff809aac5098a221@nntp.hpl.hp.com>
In article <38330FE2.C9A8576F@texas.net> on Wed, 17 Nov 1999 14:28:18 -
0600, Tom Briles <sariq@texas.net> says...
...
> > crackbaby1@my-deja.com wrote:
...
> > > this is what I need:
> > > $updated_on = "19991117"
>
> You've been told in the past to read some documentation before posting.
> You did do that, didn't you?
>
> Try:
>
> perldoc -f localtime
> perldoc -f sprintf
>
> my ($day,$mon,$year) = (localtime)[3..5];
> my $updated_on = sprintf('%4d%2d%2d', 1900+$year, ++$mon, $day);
Not quite. Try ($day, $mon, $year) = (1, 1, 100), for example.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 17 Nov 1999 13:19:45 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Date localtime help...Newbie
Message-Id: <MPG.129cbbc997044f3f98a222@nntp.hpl.hp.com>
In article <FCEY3.22029$YI2.982547@typ11.nn.bcandid.com> on Wed, 17 Nov
1999 20:55:01 GMT, Kragen Sitaker <kragen@dnaco.net> says...
> In article <MPG.129cb1f8deab602198a220@nntp.hpl.hp.com>,
> Larry Rosler <lr@hpl.hp.com> wrote:
> >In article <VRDY3.21988$YI2.994383@typ11.nn.bcandid.com> on Wed, 17 Nov
> >1999 20:03:01 GMT, Kragen Sitaker <kragen@dnaco.net> says...
> >> Hmm, you could do
> >> my $updated_on = sprintf "%.4d%.2d%.2d",
> >> map { ((localtime)[3..5])[$_] + (0, 1, 1900)[$_] } 2, 1, 0;
> >
> >What, pray tell, is the functionality of the '.4' specifier in this
> >format? Penalize yourself two strokes for that!
>
> It's so we'll have a four-digit year, even for years before 1000.
Am I overlooking a smiley? Can (localtime($whatever))[5] be -901 or
less?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 17 Nov 1999 21:03:34 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Date localtime help...Newbie
Message-Id: <80v576$44t$1@gellyfish.btinternet.com>
On Wed, 17 Nov 1999 20:00:03 +0100 Frederic TYNDIUK wrote:
<rearranged the Jeopardism>
> crackbaby1@my-deja.com wrote:
>>
>> I just need to create a varaible with todays date in it...
>>
>> this is what I have:
>> $updated_on = ???
>>
>> this is what I need:
>> $updated_on = "19991117"
>>
>
> You can use this :
>
> my($day,$month,$year) =
> (localtime(time))[3..5];
> $Year += 1900;
> $month++;
> if ($day < 10) { $day = "0".$day;
> }
> if ($month < 10) { $month = "0".$month;
> }
>
> $updated = $year.$mouth.$day;
>
Well he could use this except it looks like some ancient artefact washed
up from the wreck of some CGI script archive:
my ( $day,$month,$year ) = (localtime)[3 .. 5];
$updated = sprintf "%.4d%.02d%.02d", $year + 1900,$month + 1, $day ;
Now isnt that nicer - of course as Larry Rosler points out you can
do this with POSIX::strftime as well ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 17 Nov 1999 16:07:01 -0600
From: Tom Briles <sariq@texas.net>
Subject: Re: Date localtime help...Newbie
Message-Id: <38332705.CA20E9BF@texas.net>
Tom Briles wrote:
>
> my $updated_on = sprintf('%4d%2d%2d', 1900+$year, ++$mon, $day);
Whoops...forgot the '.'s. And, as Larry Rosler pointed out, the '.4'
isn't necessary (assuming we don't go back in time prior to 1000 AD).
Of course, it worked as posted for today's date... :)
Should be:
my $updated_on = sprintf('%d%.2d%.2d', 1900+$year, ++$mon, $day);
- Tom
------------------------------
Date: 17 Nov 1999 17:11:23 GMT
From: jgd@alpha3.csd.uwm.edu (John G Dobnick)
Subject: Re: Date Of Birth from TODAY
Message-Id: <80unjr$d12$1@uwm.edu>
From article <80j3a9$36f$1@nnrp1.deja.com>, by Andrej <webmaster@beautiful-ladies.com>:
>
>
> Hello,
> Recently I began to use Woda data base(http://itc.fgg.uni-lj.si/woda/ )
> Actually I began to study Perl with it, so I not the expert :-)
>
> I have one simple problem, I need to calculate age using today's date
> and
> date of birth and I would not like to use additional perl modules...
Why not? Modules are your friends!
Modules let you make use of someone _else's_ work to solve _your_
problems. Use them. Be lazy! Emulate Larry!
The module Date::Manip (or Date::Calc) may be of use to you.
Check them out.
--
John G Dobnick "Knowing how things work is the basis
Information & Media Technologies for appreciation, and is thus a
University of Wisconsin - Milwaukee source of civilized delight."
jgd@uwm.edu ATTnet: (414) 229-5727 -- William Safire
------------------------------
Date: Wed, 17 Nov 1999 17:03:28 GMT
From: Amy Schmieder <aschmied@earthlink.net>
Subject: Re: DBD::Oracle
Message-Id: <80un4t$377$1@nnrp1.deja.com>
Thanks, for the response, Erik. Another question follows below. :-)
Erik van Roode <newsposter@cthulhu.demon.nl> wrote:
> Amy Schmieder <aschmied@earthlink.net> wrote:
>
> > I am having some trouble with stored procedures and DBI. (Using
> > DBD::Oracle.)
>
> > $cursor=$dbh->prepare($call);
> > $cursor->execute;
> > @row=$cursor->fetchrow_array;
>
> > When run, this returns the error:
> > ERROR no statement executing (perhaps you need to call execute
first)
>
> Do proper error checking and display error messages. My guess is that
> the prepare or the execute fail.
Huh. That is indeed the problem- I did have some error checks in place
(they were not shown), but was counting on RaiseError being set
to 1 for the prepare and execute calls. (For the curious, it is on the
execute call that it fails - with an invalid data type error. As it is
a created data type, I suppose I can see this, but it will cause
problems.)
When rechecking the definition of RaiseError, it still seems that it
ought to have died there: "...When set on, any method which results in
an error occuring will cause the DBI to effectively do a die..." (DBI
perldoc)
What am I missing that it didn't catch the execute error?
Thanks,
Amy Schmieder
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 1409
**************************************