[26249] in Perl-Users-Digest
Perl-Users Digest, Issue: 8433 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 19 18:05:42 2005
Date: Mon, 19 Sep 2005 15:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 19 Sep 2005 Volume: 10 Number: 8433
Today's topics:
Re: chenga script to show one houer more <mothra@nowhereatall.com>
Re: FAQ 4.69 How can I use a reference as a hash key? <jgibson@mail.arc.nasa.gov>
Re: Perl portability <hendry.taylor@btinternet.com>
STDOUT pass-through with system() <kf1zr0y02@sneakemail.com>
Re: why is important to use : use strict? <jurgenex@hotmail.com>
Re: why is important to use : use strict? <mr@sandman.net>
Re: why is important to use : use strict? (Chris Richmond - MD6-FDC ~)
Re: why is important to use : use strict? <john@castleamber.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 19 Sep 2005 10:53:18 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: chenga script to show one houer more
Message-Id: <432f01a9$1@usenet.ugs.com>
Hello,
kozmos241 wrote:
> Hi,
>
> i am new to perl and i am wondering how to change this script to show
> one houer more, i will change it back for daylight saving.
>
>
>
[code snipped]
You might want to take a look at the DateTime project
http://datetime.perl.org/
Hope this helps
Mothra
------------------------------
Date: Mon, 19 Sep 2005 10:34:31 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: FAQ 4.69 How can I use a reference as a hash key?
Message-Id: <190920051034314514%jgibson@mail.arc.nasa.gov>
In article <dgm2cl$cgt$1@reader1.panix.com>, PerlFAQ Server
<comdog@panix.com> wrote:
> This message is one of several periodic postings to comp.lang.perl.misc
> intended to make it easier for perl programmers to find answers to
> common questions. The core of this message represents an excerpt
> from the documentation provided with Perl.
>
> --------------------------------------------------------------------
>
> 4.69: How can I use a reference as a hash key?
>
> You can't do this directly, but you could use the standard Tie::RefHash
> module distributed with Perl.
This answer seems incomplete and therefore misleading. You can use hard
references as hash keys, because they become stringified and are
unique. What you can't do is retrieve the hash key from the hash and
dereference it. However, if you store the references separately, say in
an array, you can associate values with each reference in a hash and
retrieve them.
Proposed modification:
"4.69 How can I use a reference as a hash key?
You can use a reference as a hash key like any scalar, but you can't
retrieve it from the hash and deference it later because it becomes
stringified. For that, you could use the standard Tie::RefHash
module distributed with Perl."
Note: the perdoc Tie::RefHash documentation refers to the
Tie::RefHash::Nestable module for hashes-of-hashes, but I can't find it
on CPAN. Does it still exist? (perl, v5.8.6).
------------------------------
Date: Mon, 19 Sep 2005 19:41:06 +0000 (UTC)
From: Hendry Taylor <hendry.taylor@btinternet.com>
Subject: Re: Perl portability
Message-Id: <dgn48i$712$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com>
Hendry Taylor wrote:
> I wrote a perl script and tested it on windows and it works fine. I then
> moved it onto a solaris machine and now it says that there is a syntax
> error with the following line of code:
>
> $user1 = "User name: ".$rec1[0];
>
> the line of code just before that is:
>
> @rec1 = split(/@/, $autotrack[$records]);
>
>
> any ideas?
> I can't see that there is anything uniquely windows about that. There is
> a difference in the version of perl in that on the windows box I have
> active state v5.8.6 and the solaris box has solaris perl 5.00.3 or
> something like that.
Just as some feedback, I upgraded the perl from 5.00.5 to 5.8.4 and it
now works fine. The older version did not like my switch and case.
------------------------------
Date: 19 Sep 2005 21:22:38 GMT
From: Justin <kf1zr0y02@sneakemail.com>
Subject: STDOUT pass-through with system()
Message-Id: <Xns96D6B0C57276Ckf1zr0y02sneakemail@18.181.0.25>
Hi all,
I've inherited a rather scrappy setup whereby a perl script calls a 2nd
script with system() (which writes to STDOUT) which then exec's a command
(which also writes to STDOUT). Under v5.8.0 I lose the STDOUT (and
STDERR) from the second script onwards. Under our legacy v5.002 it works
as I would hope.
e.g. I have 3 scripts, stage1, stage2, stage3. I run stage1 from the
console, which calls stage2 with system(), which calls stage3 with exec.
-----------------stage1------------------
#!/usr/local/bin/perl
select STDOUT; $|=1; #autoflush STDOUT
print STDOUT "Stage 1 STDOUT\n";
print STDERR "Stage 1 STDERR\n";
#Now call Stage 2 with system() which forks, then retuns
print "Calling (system) Stage 2 from Stage 1...\n";
system("stage2");
print "Returned from Stage 2 to Stage 1\n";
------------------stage2-----------------
#!/usr/local/bin/perl
select STDOUT; $|=1; #autoflush STDOUT
print STDOUT "Stage 2 STDOUT\n";
print STDERR "Stage 2 STDERR\n";
#Now call Stage 3 with system() which forks, then retuns
print "Calling (via exec) Stage 3 from Stage 2...\n";
exec("stage3");
print "Returned from Stage 3 to Stage 2\n";
-------------------stage3----------------
#!/usr/local/bin/perl
select STDOUT; $|=1; #autoflush STDOUT
print STDOUT "Stage 3 STDOUT\n";
print STDERR "Stage 3 STDERR\n";
I run the commands from the console so I see STDOUT and STDERR. Under
Perl v5.002 I get the STDOUT (and STDERR) from all 3 stages displayed:
Stage 1 STDOUT
Stage 1 STDERR
Calling (system) Stage 2 from Stage 1...
Stage 2 STDOUT
Stage 2 STDERR
Calling (via exec) Stage 3 from Stage 2...
Stage 3 STDOUT
Stage 3 STDERR
Returned from Stage 2 to Stage 1
Under Perl v5.8.0 I get the following:
Stage 1 STDOUT
Stage 1 STDERR
Calling (system) Stage 2 from Stage 1...
Returned from Stage 2 to Stage 1
Now I want it to work like v5.002. You can see I've tried autoflush.
According to Perlfaq8, "With system(), both STDOUT and STDERR will go the
same place as the script's versions of these, unless the command
redirects them."
Any ideas?
Cheers,
Justin
------------------------------
Date: Mon, 19 Sep 2005 14:20:02 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: why is important to use : use strict?
Message-Id: <mOzXe.9152$%i1.7167@trnddc09>
Martina wrote:
> Why is important to use "use strict"?
> Perl script work very good without this command.
> Am I forgot something?
You are forgetting that programmers are humans, too, and thus are making
mistakes.
"use strict" catches many of those all too human mistakes like e.g. typos in
variable names.
jue
------------------------------
Date: Mon, 19 Sep 2005 17:36:12 +0200
From: Sandman <mr@sandman.net>
Subject: Re: why is important to use : use strict?
Message-Id: <mr-3F5460.17361219092005@individual.net>
In article <dgmb2o$9cq$1@ss405.t-com.hr>, "Martina" <martina@martina.yu>
wrote:
> Why is important to use "use strict"?
> Perl script work very good without this command.
> Am I forgot something?
>
> Tnx.
strict catches lots of errors that aren't only critical, but could still be the
reason a huge application fails due to variables being incorrectly rrefernced
or named.
And if you make sure to always use strict (and warnings), you will find that
it's easier to get help here since you have shown that at least the syntax is
correct and thus the error must be something else.
--
Sandman[.net]
------------------------------
Date: Mon, 19 Sep 2005 15:33:04 +0000 (UTC)
From: crichmon@filc8046.fm.intel.com (Chris Richmond - MD6-FDC ~)
Subject: Re: why is important to use : use strict?
Message-Id: <dgmlng$q22$1@news01.intel.com>
In article <mOzXe.9152$%i1.7167@trnddc09>,
"Jürgen Exner" <jurgenex@hotmail.com> writes:
>Martina wrote:
>> Why is important to use "use strict"?
>> Perl script work very good without this command.
>> Am I forgot something?
>
>You are forgetting that programmers are humans, too, and thus are making
>mistakes.
>"use strict" catches many of those all too human mistakes like e.g. typos in
>variable names.
I'll have to take exception to this part about variable names.
use strict; almost demands that you also use 'my' variables.
Even when using warnings too, 'my' variables aren't checked for
"variable used only once" warnings. That is my clue that I mis-type
a variable name.
I don't understand that aspect of 'my' variables.
Chris
--
Chris Richmond | I don't speak for Intel & vise versa
------------------------------
Date: 19 Sep 2005 16:07:14 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: why is important to use : use strict?
Message-Id: <Xns96D6711F24336castleamber@130.133.1.4>
crichmon@filc8046.fm.intel.com (Chris Richmond - MD6-FDC ~) wrote:
> I'll have to take exception to this part about variable names.
> use strict; almost demands that you also use 'my' variables.
> Even when using warnings too, 'my' variables aren't checked for
> "variable used only once" warnings. That is my clue that I mis-type
> a variable name.
Which fails if you type a name wrong twice. Especially if you're
refactoring a project :-D.
> I don't understand that aspect of 'my' variables.
I am sure the documentation will clear this up, a lot even.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 8433
***************************************