[16190] in Perl-Users-Digest
Perl-Users Digest, Issue: 3602 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 19:29:10 2000
Date: Mon, 10 Jul 2000 16:28:59 -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: <963271738-v9-i3602@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 10 Jul 2000 Volume: 9 Number: 3602
Today's topics:
Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
STDERR to file... schnurmann@my-deja.com
Re: STDERR to file... <foo@bar.va>
Re: STDERR to file... <kjetilskotheim@iname.com>
Re: STDERR to file... (Tad McClellan)
Re: STDERR to file... schnurmann@my-deja.com
Re: STDERR to file... schnurmann@my-deja.com
Re: STDERR to file... <foo@bar.va>
Re: STDERR to file... (Bart Lateur)
Strange behavior in do while loops in perl 5.00503 <mallen@nospam.tuxtops.com>
Re: Strange behavior in do while loops in perl 5.00503 <aqumsieh@hyperchip.com>
Re: Strange behavior in do while loops in perl 5.00503 <mallen@nospam.tuxtops.com>
Strange behavior with localtime s_m_campbell@my-deja.com
Re: Strange behavior with localtime <tony_curtis32@yahoo.com>
Re: Strange behavior with localtime <billy@arnis-bsl.com>
Re: Strange behavior with localtime s_m_campbell@my-deja.com
Re: Strange behavior with localtime (Peter McMorran)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 10 Jul 2000 14:27:47 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <smjnb3i6nu84@corp.supernews.com>
Following is a summary of articles spanning a 7 day period,
beginning at 03 Jul 2000 15:22:43 GMT and ending at
10 Jul 2000 14:27:54 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 2000 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Excluded Posters
================
perlfaq-suggestions\@(?:.*\.)?perl\.com
Totals
======
Posters: 476
Articles: 1477 (584 with cutlined signatures)
Threads: 398
Volume generated: 2639.5 kb
- headers: 1207.1 kb (23,961 lines)
- bodies: 1349.8 kb (45,778 lines)
- original: 870.5 kb (32,441 lines)
- signatures: 81.1 kb (1,768 lines)
Original Content Rating: 0.645
Averages
========
Posts per poster: 3.1
median: 1.0 post
mode: 1 post - 277 posters
s: 7.1 posts
Posts per thread: 3.7
median: 3.0 posts
mode: 1 post - 99 threads
s: 3.8 posts
Message size: 1830.0 bytes
- header: 836.9 bytes (16.2 lines)
- body: 935.8 bytes (31.0 lines)
- original: 603.5 bytes (22.0 lines)
- signature: 56.2 bytes (1.2 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
80 147.5 ( 63.2/ 73.2/ 47.6) Tad McClellan <tadmc@metronet.com>
66 143.4 ( 53.4/ 77.5/ 73.2) abigail@delanet.com
56 82.6 ( 46.5/ 36.0/ 20.4) Drew Simonis <care227@attglobal.net>
45 85.3 ( 41.8/ 40.5/ 17.4) Jonathan Stowe <gellyfish@gellyfish.com>
40 70.1 ( 36.8/ 32.9/ 17.2) Bob Walton <bwalton@rochester.rr.com>
31 44.8 ( 27.2/ 17.3/ 10.7) Bart Lateur <bart.lateur@skynet.be>
28 58.7 ( 29.0/ 29.1/ 21.6) "Alan J. Flavell" <flavell@mail.cern.ch>
22 47.6 ( 18.5/ 22.5/ 11.3) Uri Guttman <uri@sysarch.com>
21 39.5 ( 15.1/ 20.4/ 11.2) efflandt@xnet.com
19 33.0 ( 18.5/ 11.8/ 6.7) brian d foy <brian@smithrenaud.com>
These posters accounted for 27.6% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
147.5 ( 63.2/ 73.2/ 47.6) 80 Tad McClellan <tadmc@metronet.com>
143.4 ( 53.4/ 77.5/ 73.2) 66 abigail@delanet.com
85.3 ( 41.8/ 40.5/ 17.4) 45 Jonathan Stowe <gellyfish@gellyfish.com>
82.6 ( 46.5/ 36.0/ 20.4) 56 Drew Simonis <care227@attglobal.net>
70.1 ( 36.8/ 32.9/ 17.2) 40 Bob Walton <bwalton@rochester.rr.com>
58.7 ( 29.0/ 29.1/ 21.6) 28 "Alan J. Flavell" <flavell@mail.cern.ch>
51.5 ( 1.7/ 49.8/ 22.3) 2 Ariel Lia <Ariellia@garden.com>
49.0 ( 26.8/ 17.3/ 10.7) 19 Keith Calvert Ivey <kcivey@cpcug.org>
47.6 ( 18.5/ 22.5/ 11.3) 22 Uri Guttman <uri@sysarch.com>
44.8 ( 27.2/ 17.3/ 10.7) 31 Bart Lateur <bart.lateur@skynet.be>
These posters accounted for 29.6% of the total volume.
Top 10 Posters by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
1.000 ( 3.8 / 3.8) 7 Kirill Miazine <news@fido.workone.com>
0.967 ( 1.0 / 1.1) 5 ufssin@my-deja.com
0.944 ( 73.2 / 77.5) 66 abigail@delanet.com
0.936 ( 2.0 / 2.2) 6 "TheEx0rcist" <TheEx0rcist@fanclub.org>
0.932 ( 7.1 / 7.6) 13 zawy <zawy@yahoo.com>
0.922 ( 3.4 / 3.7) 9 "Raphael Pirker" <raphaelp@nr1webresource.com>
0.750 ( 5.0 / 6.7) 5 Neil Kandalgaonkar <neil@brevity.org>
0.742 ( 21.6 / 29.1) 28 "Alan J. Flavell" <flavell@mail.cern.ch>
0.723 ( 3.3 / 4.6) 5 Clinton A. Pierce <clintp@geeksalad.org>
0.699 ( 14.0 / 20.0) 7 H. Merijn Brand <h.m.brand@hccnet.nl>
Bottom 10 Posters by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.430 ( 17.4 / 40.5) 45 Jonathan Stowe <gellyfish@gellyfish.com>
0.430 ( 2.6 / 6.0) 11 Bacbalabby <user@host.com>
0.427 ( 4.6 / 10.7) 13 news@tinita.de
0.419 ( 2.1 / 5.1) 6 "John Coke" <astro@shell.athenet.net>
0.414 ( 3.8 / 9.3) 12 =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
0.407 ( 1.8 / 4.4) 6 Villy Kruse <vek@pharmnl.ohout.pharmapartners.nl>
0.406 ( 2.0 / 5.0) 7 "Ed Bras" <e.bras@hccnet.nl>
0.373 ( 1.8 / 4.9) 7 Rafael Garcia-Suarez <rgarciasuarez@free.fr>
0.347 ( 1.0 / 3.0) 5 M.J.T. Guy <mjtg@cus.cam.ac.uk>
0.205 ( 1.8 / 8.9) 11 Ade Talabi <adetalabi@clara.co.uk>
53 posters (11%) had at least five posts.
Top 10 Threads by Number of Posts
=================================
Posts Subject
----- -------
29 Mini-Faq (was: Help someone new)
26 Why $|++ instead of $|=1 ?
21 Unix database for Perl
21 Symbolic References for Form parsing?
18 unlink() doesn't work for perl win32
18 The BackSpace character ("\b") - bug?
18 My "replace a word in an HTML file" problem (CGI)
17 Delayed HTML Output in PERL
17 Definitive flock code (?)
16 Is there a way to make a perl script into an executable?
These threads accounted for 13.6% of all articles.
Top 10 Threads by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Subject
-------------------------- ----- -------
54.5 ( 24.7/ 28.1/ 19.4) 21 Unix database for Perl
53.2 ( 29.0/ 20.6/ 9.8) 29 Mini-Faq (was: Help someone new)
49.1 ( 0.9/ 48.2/ 20.7) 1 Simple script works on Unix, but can anyone get it to work on NT/IIS ? - edittag.zip [1/1]
46.1 ( 22.8/ 20.8/ 12.4) 26 Why $|++ instead of $|=1 ?
41.6 ( 16.5/ 24.1/ 12.3) 18 My "replace a word in an HTML file" problem (CGI)
35.2 ( 14.7/ 19.6/ 10.0) 14 Simple Reg Expression Question
34.2 ( 14.2/ 19.4/ 10.9) 17 Delayed HTML Output in PERL
34.0 ( 17.6/ 14.0/ 9.1) 18 The BackSpace character ("\b") - bug?
33.7 ( 16.1/ 17.1/ 11.9) 17 Definitive flock code (?)
32.7 ( 17.1/ 13.6/ 9.3) 21 Symbolic References for Form parsing?
These threads accounted for 15.7% of the total volume.
Top 10 Threads by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.909 ( 19.8/ 21.7) 8 language (was: Mini-Faq (was: Help someone new))
0.892 ( 6.6/ 7.4) 6 Problems running the perl debugger
0.809 ( 5.9/ 7.2) 7 RegEx and numbers
0.799 ( 6.6/ 8.3) 5 HP-UX System architecture
0.791 ( 2.0/ 2.6) 5 Sorting an array of numbers
0.779 ( 1.0/ 1.3) 5 Problems with a string
0.777 ( 2.8/ 3.6) 8 HTTP Last-Modified header not always returned
0.777 ( 3.3/ 4.3) 5 how to get text enclosed by matching () ?
0.768 ( 5.2/ 6.7) 10 Please Point me in the right direction
0.768 ( 7.7/ 10.1) 6 Beyond perl? Need advice...
Bottom 10 Threads by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.490 ( 1.9 / 3.9) 8 STDERR to file...
0.487 ( 0.9 / 1.9) 5 Legal SSI procedure?
0.485 ( 3.2 / 6.5) 7 Converting HTML to text, harder than the FAQ implies
0.484 ( 2.5 / 5.2) 8 about mkdir()
0.482 ( 2.9 / 6.0) 6 Win95 Perl installation question
0.476 ( 9.8 / 20.6) 29 Mini-Faq (was: Help someone new)
0.474 ( 2.0 / 4.2) 7 Variable subroutines
0.465 ( 1.6 / 3.5) 5 Newbie questions: treating a scalar string as an array of chars, and the $_
0.454 ( 3.5 / 7.6) 6 redirection using Location: in Perl CGI script
0.421 ( 2.0 / 4.7) 5 Can get perl to open doc, but how do I get it to open html on thefly?
99 threads (24%) had at least five posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
39 alt.perl
31 comp.lang.perl.modules
31 comp.lang.perl
11 comp.lang.perl.moderated
7 comp.lang.perl.tk
7 alt.perl.sockets
7 alt.comp.perlcgi.freelance
7 comp.security.unix
6 alt.comp.lang.superlang
5 uk.comp.os.linux
Top 10 Crossposters
===================
Articles Address
-------- -------
9 abigail@delanet.com
8 "Kenny Lim" <kennylim@techie.net>
6 "James Nelson" <james@kcnet.com>
6 "Treku" <Treku@w.pl>
6 Nick Kew <nick@webthing.com>
6 brian d foy <brian@smithrenaud.com>
4 Joseph Ziegler <joseph@denalii.com>
4 "nicolas" <webmaster@archiTacTic.com>
4 Bart Lateur <bart.lateur@skynet.be>
4 Craig Berry <cberry@cinenet.net>
------------------------------
Date: Wed, 05 Jul 2000 15:36:37 GMT
From: schnurmann@my-deja.com
Subject: STDERR to file...
Message-Id: <8jvkm3$cgk$1@nnrp1.deja.com>
I must be totally braindead today, but how does one redirect
STDERR/STDOUT to a file with a user defined name?
I want things like warn and die to be printed in the file, not to
console.
Thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 05 Jul 2000 18:06:48 +0200
From: Marco Natoni <foo@bar.va>
Subject: Re: STDERR to file...
Message-Id: <39635D18.AB27870F@bar.va>
schnurmann,
schnurmann@my-deja.com wrote:
> I must be totally braindead today, but how does one
> redirect STDERR/STDOUT to a file with a user defined name? I
> want things like warn and die to be printed in the file, not
> to console.
$ perldoc -f open
Best regards,
Marco
------------------------------
Date: Wed, 05 Jul 2000 17:27:49 +0200
From: Kjetil Skotheim <kjetilskotheim@iname.com>
To: schnurmann@my-deja.com
Subject: Re: STDERR to file...
Message-Id: <39636205.FA9CFDCD@iname.com>
Is this a Perl question? I suspect not. If it is a unix question,
I guess the answer depends on which shell you are using.
Might not be too far off:
Tcsh/csh: ( command > stdout ) >& stderr
or ( command >! stdout ) >&! stderr
or command >&! stdout_and_stderr
Writes over existing files if using !, or else an error occur.
Bash/sh: command > stdout 2> stderr
schnurmann@my-deja.com wrote:
>
> I must be totally braindead today, but how does one redirect
> STDERR/STDOUT to a file with a user defined name?
>
> I want things like warn and die to be printed in the file, not to
> console.
>
> Thanks.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
Kjetil Skotheim
kjetilskotheim@iname.com
------------------------------
Date: Wed, 5 Jul 2000 12:43:59 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: STDERR to file...
Message-Id: <slrn8m6pef.hfr.tadmc@magna.metronet.com>
On Wed, 05 Jul 2000 18:06:48 +0200, Marco Natoni <foo@bar.va> wrote:
>schnurmann,
>
>schnurmann@my-deja.com wrote:
>> I must be totally braindead today, but how does one
>> redirect STDERR/STDOUT to a file with a user defined name? I
^^^^^^
>> want things like warn and die to be printed in the file, not
^^^^ ^^^
Those do not use STDOUT (so why is it mentioned above? Do you
really need to also do something with STDOUT?)
>> to console.
>
> $ perldoc -f open
Also:
perldoc -q STDERR
"How can I capture STDERR from an external command?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 06 Jul 2000 12:27:50 GMT
From: schnurmann@my-deja.com
Subject: Re: STDERR to file...
Message-Id: <8k1tvt$s8s$1@nnrp1.deja.com>
Ok, so what does C<'E<gt>-'> mean?
In article <39635D18.AB27870F@bar.va>,
mnatoni@rumbanet.it wrote:
> schnurmann,
>
> schnurmann@my-deja.com wrote:
> > I must be totally braindead today, but how does one
> > redirect STDERR/STDOUT to a file with a user defined name? I
> > want things like warn and die to be printed in the file, not
> > to console.
>
> $ perldoc -f open
>
> Best regards,
> Marco
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 06 Jul 2000 12:30:46 GMT
From: schnurmann@my-deja.com
Subject: Re: STDERR to file...
Message-Id: <8k1u5m$sbf$1@nnrp1.deja.com>
YES, it IS a Perl question. I want all message that would go to STDOUT
or STDERR to go into a log file. I also want this file open for output
so that I may send 'print's to it for log messages, depending on which
log level the programme is being run under. All this goes into the
same log file.
In article <39636205.FA9CFDCD@iname.com>,
Kjetil Skotheim <kjetilskotheim@iname.com> wrote:
> Is this a Perl question? I suspect not. If it is a unix question,
> I guess the answer depends on which shell you are using.
> Might not be too far off:
>
> Tcsh/csh: ( command > stdout ) >& stderr
> or ( command >! stdout ) >&! stderr
> or command >&! stdout_and_stderr
>
> Writes over existing files if using !, or else an error occur.
>
> Bash/sh: command > stdout 2> stderr
>
> schnurmann@my-deja.com wrote:
> >
> > I must be totally braindead today, but how does one redirect
> > STDERR/STDOUT to a file with a user defined name?
> >
> > I want things like warn and die to be printed in the file, not to
> > console.
> >
> > Thanks.
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
> --
> Kjetil Skotheim
> kjetilskotheim@iname.com
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 06 Jul 2000 14:46:44 +0200
From: Marco Natoni <foo@bar.va>
Subject: Re: STDERR to file...
Message-Id: <39647FB4.E2B2A282@bar.va>
schnurmann,
schnurmann@my-deja.com wrote:
> Ok, so what does C<'E<gt>-'> mean?
It is an escape sequence used by any POD translator to format the text
in a certain way. Obviously, try:
$ perldoc perlpod
for information. ;)
Best regards,
Marco
------------------------------
Date: Thu, 06 Jul 2000 23:11:48 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: STDERR to file...
Message-Id: <39671136.9588861@news.skynet.be>
schnurmann@my-deja.com wrote:
> must be totally braindead today, but how does one redirect
>STDERR/STDOUT to a file with a user defined name?
>
>I want things like warn and die to be printed in the file, not to
>console.
Er...
open STDERR, ">filename.txt";
--
Bart.
------------------------------
Date: Fri, 07 Jul 2000 12:41:52 -0800
From: "Mark Allen" <mallen@nospam.tuxtops.com>
Subject: Strange behavior in do while loops in perl 5.00503
Message-Id: <8k5bq4$og9$1@news.bayarea.net>
Hey perl folks,
I'm writing what I thought would be a pretty trivial little script and
I've noticed something odd. I checked the FAQ and the Perl bug tracker
database, and did a search on Deja (where there's only about 14,000
messages archives that mention while loops!!) but I didn't see any tickets
open on this. I can only see this as a feature, and not a bug.
Here's the code snippet:
[...]
do {
print "Please choose (1-3) or "C": ";
$foo = <STDIN>;
chomp;
} while ( $foo < 1 or $foo > 3 or $foo ne "C" );
[...]
This is looks like pretty standard orthodox perl to me, but I'm hardly an
expert.
Anyway, if I run this code, the loop seems to continue forever, no matter
what I choose, but if I remove the last conditional test (i.e., $foo ne
"C") then the numeric evaluation works, and if I remove the numeric
tests, the string evaluation works. If I try to combine them, though,
neither works.
I suppose this question may be in TFM, but if so, could I get a more
specific pointer to TFM section? It's not critical that this problem be
answered, because I've rewritten the loop as a standard while loop using
some if conditionals and the "last" directive, but this has intrigued me.
Regards,
Mark Allen
Please remove the "nospam" if you're going to email me. Thanks.
------------------------------
Date: Fri, 07 Jul 2000 20:29:28 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Strange behavior in do while loops in perl 5.00503
Message-Id: <7avgyhlm47.fsf@merlin.hyperchip.com>
"Mark Allen" <mallen@nospam.tuxtops.com> writes:
> Here's the code snippet:
>
> [...]
>
> do {
> print "Please choose (1-3) or "C": ";
Ahem ... you have double quotes within double quotes. This means to me
that you have not copy/pasted your code, which is a bad thing in general
since you can introduce typos that aren't in your original code.
> $foo = <STDIN>;
> chomp;
What are you chomp()ing? You didn't supply a variable, so chomp() works
on the default $_ variable. That should be:
chomp $foo;
(another typo?)
> } while ( $foo < 1 or $foo > 3 or $foo ne "C" );
You conditional is wrong. It should be:
} while $foo ne 'C' and $foo < 1 or $foo > 3;
or
} until $foo eq 'C' or $foo > 0 and $foo < 4;
Note also that the above will generate a warning under -w when you type
in a letter since, if it's not 'C', the script will attempt to treat it
as a number.
--Ala
------------------------------
Date: Fri, 07 Jul 2000 14:56:18 -0800
From: "Mark Allen" <mallen@nospam.tuxtops.com>
Subject: Re: Strange behavior in do while loops in perl 5.00503
Message-Id: <8k5jm6$9a$1@news.bayarea.net>
In article <7avgyhlm47.fsf@merlin.hyperchip.com>, Ala Qumsieh
<aqumsieh@hyperchip.com> wrote:
>
> "Mark Allen" <mallen@nospam.tuxtops.com> writes:
>> do {
>> print "Please choose (1-3) or "C": ";
> Ahem ... you have double quotes within double quotes. This means to me
> that you have not copy/pasted your code, which is a bad thing in general
> since you can introduce typos that aren't in your original code.
Yes, busted. I tried to type it in from memory.
>> } while ( $foo < 1 or $foo > 3 or $foo ne "C" );
> You conditional is wrong. It should be:
> } while $foo ne 'C' and $foo < 1 or $foo > 3;
> or
> } until $foo eq 'C' or $foo > 0 and $foo < 4;
> Note also that the above will generate a warning under -w when you type
> in a letter since, if it's not 'C', the script will attempt to treat it
> as a number.
Thanks for the help. When I replaced "or" with "and" it works. I'm trying
to wrap my head around this and understand it. I know why "and" works
and why "or" doesn't; but it still seems odd to me.
I wonder if grouping the conditionals explicitly would have made a
difference... I'll write a little test program and find out. :-)
Thanks again for the help.
> --Ala
Mark
--
http://www.tuxtops.com Tuxtops: the Linux on Laptops company
------------------------------
Date: Wed, 05 Jul 2000 13:45:39 GMT
From: s_m_campbell@my-deja.com
Subject: Strange behavior with localtime
Message-Id: <8jve5u$7c0$1@nnrp1.deja.com>
Hi,
I am using localtime to get the current time to compare it with another
time. The following script code worked in the month of June, but not
in the month of July. To get it to work in July, I needed to look at
index 4. In June, I needed to look at index 3.
Why does the index change when the month changes?
Works for month of June:
$LTime = localtime;
@TParts = split(/ /, $LTime);
$Today = @TParts[0];
$Time = substr(@TParts[3], 0, 5);
^
Works for the month of July:
$LTime = localtime;
@TParts = split(/ /, $LTime);
$Today = @TParts[0];
$Time = substr(@TParts[4], 0, 5);
^
What I want to get for $Time is the hh:mm. Is there easier way to get
the time using localtime?
Thanks,
-Shawn
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 05 Jul 2000 09:10:14 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Strange behavior with localtime
Message-Id: <87og4c1xdl.fsf@limey.hpcc.uh.edu>
>> On Wed, 05 Jul 2000 13:45:39 GMT,
>> s_m_campbell@my-deja.com said:
> Hi, I am using localtime to get the current time to
> compare it with another time. The following script code
> worked in the month of June, but not in the month of
> July. To get it to work in July, I needed to look at
> index 4. In June, I needed to look at index 3.
> Why does the index change when the month changes?
> Works for month of June:
> $LTime = localtime; @TParts = split(/ /, $LTime);
> $Today = @TParts[0]; $Time = substr(@TParts[3], 0, 5); ^
> Works for the month of July:
> $LTime = localtime; @TParts = split(/ /, $LTime);
> $Today = @TParts[0]; $Time = substr(@TParts[4], 0, 5); ^
> What I want to get for $Time is the hh:mm. Is there
> easier way to get the time using localtime?
Oh dear, talk about doing things the hard way :-) There
are at least 2 easier ways:
1. localtime doesn't just return a scalar, it also
functions in list context, "perldoc -f localtime",
which result you can then put together however you want
(array elements 0, 1 and 2 for time) with sprintf, e.g.
my (undef, $m, $h) = localtime;
my $hhmm = sprintf '%02d:%02d', $h, $m;
2. use the POSIX ("perldoc POSIX") module's strftime() to
format the time more easily, e.g.
use POSIX 'strftime';
my $hhmm = strftime('%H:%M', localtime);
(#2 is my preference)
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Wed, 05 Jul 2000 14:41:22 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: Strange behavior with localtime
Message-Id: <8jvhee$a2d$1@nnrp1.deja.com>
In article <8jve5u$7c0$1@nnrp1.deja.com>,
s_m_campbell@my-deja.com wrote:
> Hi,
>
> I am using localtime to get the current time to compare it with
another
> time. The following script code worked in the month of June, but not
> in the month of July. To get it to work in July, I needed to look at
> index 4. In June, I needed to look at index 3.
>
> Why does the index change when the month changes?
>
> Works for month of June:
>
> $LTime = localtime;
> @TParts = split(/ /, $LTime);
> $Today = @TParts[0];
> $Time = substr(@TParts[3], 0, 5);
> ^
>
> Works for the month of July:
>
> $LTime = localtime;
> @TParts = split(/ /, $LTime);
> $Today = @TParts[0];
> $Time = substr(@TParts[4], 0, 5);
> ^
>
> What I want to get for $Time is the hh:mm. Is there easier way to get
> the time using localtime?
>
Please re-read perldoc -f localtime
(or http://www.cpan.org/doc/manual/html/pod/perlfunc/localtime.html).
localtime() in array context returns an array which
contains all the date/time details split in peaces.
Hope this helps.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 05 Jul 2000 14:40:55 GMT
From: s_m_campbell@my-deja.com
Subject: Re: Strange behavior with localtime
Message-Id: <8jvhdj$9r3$1@nnrp1.deja.com>
After further investigation it looks like it has nothing to do with the
month but more with the day. If the day is a single digit (1 thru 9)
the index [2] spot is blank and the day in placed in index [3] spot,
thus shifting the rest of the data by one spot. If the day is a double
digit number such as 10, the day appears in the index [2] spot.
Looks like these 2 lines are the problem.
$LTime = localtime;
@TParts = split(/ /, $LTime);
$LTime = "Wed Jun 5 10:00:00 2000" so there are 2 spaces between Jun
and 5. When $LTime = "Wed Jun 10 10:00:00 2000" there is only 1 space
between the month and day. The split function is doing the appropriate
thing.
No help required now....
In article <8jve5u$7c0$1@nnrp1.deja.com>,
s_m_campbell@my-deja.com wrote:
> Hi,
>
> I am using localtime to get the current time to compare it with
another
> time. The following script code worked in the month of June, but not
> in the month of July. To get it to work in July, I needed to look at
> index 4. In June, I needed to look at index 3.
>
> Why does the index change when the month changes?
>
> Works for month of June:
>
> $LTime = localtime;
> @TParts = split(/ /, $LTime);
> $Today = @TParts[0];
> $Time = substr(@TParts[3], 0, 5);
> ^
>
> Works for the month of July:
>
> $LTime = localtime;
> @TParts = split(/ /, $LTime);
> $Today = @TParts[0];
> $Time = substr(@TParts[4], 0, 5);
> ^
>
> What I want to get for $Time is the hh:mm. Is there easier way to get
> the time using localtime?
>
> Thanks,
>
> -Shawn
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 06 Jul 2000 01:11:08 GMT
From: mcmorran@visi.net (Peter McMorran)
Subject: Re: Strange behavior with localtime
Message-Id: <3963dca7$3$zpzbeena$mr2ice@news.visi.net>
In <8jvhdj$9r3$1@nnrp1.deja.com>, on 07/05/00
at 02:40 PM, s_m_campbell@my-deja.com said:
>After further investigation it looks like it has nothing to do
>with the month but more with the day. If the day is a single
>digit (1 thru 9) the index [2] spot is blank and the day in
>placed in index [3] spot, thus shifting the rest of the data by
>one spot. If the day is a double digit number such as 10, the
>day appears in the index [2] spot.
>Looks like these 2 lines are the problem.
> $LTime = localtime;
> @TParts = split(/ /, $LTime);
>$LTime = "Wed Jun 5 10:00:00 2000" so there are 2 spaces
>between Jun and 5. When $LTime = "Wed Jun 10 10:00:00 2000"
>there is only 1 space between the month and day. The split
>function is doing the appropriate thing.
>No help required now....
Actually, there is, because split (/ /, $LTime) doesn't split on
whitespace as you desire. It splits on the space character,
creating null fields for repeated spaces. That's why you get an
extra null field for the double space. The docs say that split ("
", $LTime) is a special case that gives the default behavior of
splitting on whitespace. That would solve your specific problem.
However, using the array return of localtime(), as others have
suggested, lets you do the whole slicing job in one statement.
<snip of previous post>
Cheers,
Peter
--
-----------------------------------------------------------
mcmorran@visi.net (Peter McMorran)
-----------------------------------------------------------
------------------------------
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 3602
**************************************