[19403] in Perl-Users-Digest
Perl-Users Digest, Issue: 1598 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 23 14:10:26 2001
Date: Thu, 23 Aug 2001 11:10:11 -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: <998590211-v10-i1598@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 23 Aug 2001 Volume: 10 Number: 1598
Today's topics:
Retrieving the date in short format <Pcmann1@btinternet.com>
Re: Retrieving the date in short format <tony_curtis32@yahoo.com>
Re: Retrieving the date in short format <ilya@martynov.org>
Re: SOS - Flock <jtjohnston@courrier.usherb.ca>
Re: SOS - Flock <callgirl@la.znet.com>
specific tutorial... <nathan.randle@ntlworld.com>
Strange behavior of perl5 on HP-UX 11.0 (Tanya Ruttenberg)
Re: Strange behavior of perl5 on HP-UX 11.0 <tony_curtis32@yahoo.com>
Re: Strange behavior of perl5 on HP-UX 11.0 <h.m.brand@hccnet.nl>
Re: Using %{$hashref} or %$hashref to dereference?? <Tassilo.Parseval@post.rwth-aachen.de>
Re: Using %{$hashref} or %$hashref to dereference?? (Randal L. Schwartz)
Re: Using %{$hashref} or %$hashref to dereference?? <uri@sysarch.com>
Re: Using %{$hashref} or %$hashref to dereference?? (Anno Siegel)
Re: Why wont this work!?!?!? (Isaac)
win32 system command and stdout (Pentti Peisa)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 23 Aug 2001 16:55:37 +0100
From: "Peter Mann" <Pcmann1@btinternet.com>
Subject: Retrieving the date in short format
Message-Id: <9m38vh$mp3$1@plutonium.btinternet.com>
Dear all,
I am trying to retrieve the current date which I have successully done
using either
gmtime() or localtime()
The problem is that these functions don't provide me witth the date in
the correct format.
My problem is that I need the date in 'Short format' i.e. 25/12/2001 so that
it will be consistent with dates in an access database when i do a select
query.
Ive tried searching perldoc from the command prompt, but there doesnt appear
to be an entry for either of them, or am I lookin in the wrong place? And
examples returned from seach engines dont appear applicable.
Could someone please tell me if its possible to do an easy convert of these
dates, and do I need additional libraries to do the actual date
manipulation?
Thanks in advance
- Pete
------------------------------
Date: 23 Aug 2001 10:58:30 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Retrieving the date in short format
Message-Id: <87lmkaepjt.fsf@limey.hpcc.uh.edu>
>> On Thu, 23 Aug 2001 16:55:37 +0100,
>> "Peter Mann" <Pcmann1@btinternet.com> said:
> Dear all, I am trying to retrieve the current date which
> I have successully done using either gmtime() or
> localtime() The problem is that these functions don't
> provide me witth the date in the correct format.
> My problem is that I need the date in 'Short format'
> i.e. 25/12/2001 so that it will be consistent with dates
> in an access database when i do a select query.
POSIX::strftime()
See "perldoc POSIX"
my $short_format = strftime('%d/%m/%Y', localtime);
hth
t
--
Yes way! Mmmmkay?
------------------------------
Date: 23 Aug 2001 20:05:42 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Retrieving the date in short format
Message-Id: <87r8u2bw2x.fsf@abra.ru>
>>>>> On Thu, 23 Aug 2001 16:55:37 +0100, "Peter Mann" <Pcmann1@btinternet.com> said:
PM> [..skip..]
PM> My problem is that I need the date in 'Short format'
PM> i.e. 25/12/2001 so that it will be consistent with dates in an
PM> access database when i do a select query.
PM> Ive tried searching perldoc from the command prompt, but there
PM> doesnt appear to be an entry for either of them, or am I lookin in
PM> the wrong place? And examples returned from seach engines dont
PM> appear applicable.
See 'perldoc -tf gmtime' and 'perldoc -tf localtime'
PM> Could someone please tell me if its possible to do an easy convert of these
PM> dates, and do I need additional libraries to do the actual date
PM> manipulation?
Both gmtime and localtime in array context return an array with date
info. This if from 'perldoc -tf gmtime':
# 0 1 2 3 4 5 6 7
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) =
gmtime(time);
'time' here is optional for current date.
So if you need dd/mm/yyyy format use something like
my @time = gmtime;
my $date = sprintf '%02d/%02d/%04d', $time[3], $time[4] + 1, $time[5] + 1900;
For better readability it is recomended to use standart Perl modules
Time::localtime and Time::gmtime.
Example:
use Time::gmtime;
my $time = gmtime;
my $date = sprintf '%02d/%02d/%04d', $time->mday, $time->mon + 1,
$time->year + 1900;
See 'perldoc Time::localtime' and 'perldoc Time::gmtime' for
additional info about these modules.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Thu, 23 Aug 2001 16:05:45 GMT
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Re: SOS - Flock
Message-Id: <3B852A56.D7463CE1@courrier.usherb.ca>
God Bless Godzilla for coming up with the most assinine answer possible.
People come here with help and suggestions. Help one's fellow
programmer.
You obviously have more experience than I. What joyous error checking
would you have me do?
"Godzilla!" wrote:
> jtjohnston wrote:
>
> (snipped)
>
> > Please, can someone tell me, am I flocking this correctly?
>
> My presumption is you are childishly helpless or
> exhibit flatline brain activity, perhaps both.
>
> Why don't you simply add error checking for your flock?
>
> jeesshhh....
>
> Godzilla!
------------------------------
Date: Thu, 23 Aug 2001 09:17:52 -0700
From: Kira <callgirl@la.znet.com>
Subject: Re: SOS - Flock
Message-Id: <3B852CB0.A8BE6018@la.znet.com>
jtjohnston wrote:
> God Bless Godzilla for coming up with the most assinine answer possible.
It is spelled "asinine."
An asinine troll article warrants an asinine response.
> People come here with help and suggestions. Help one's fellow
> programmer.
Very few people visit here. A preponderance of articles posted
here are your troll articles, under myriad fake names.
> You obviously have more experience than I.
Yes, obviously. This annoys you to psychotic distraction.
> What joyous error checking would you have me do?
If possible, I would have you check the errors of your ways.
However, your lack of both decent moral values and decent
ethical values, precludes any personal error resolution.
Read and learn; become a better troll.
http://language.perl.com/newdocs/pod/perlopentut.html#File_Locking
Godzilla! Queen Of Canned Mule Manure.
------------------------------
Date: Thu, 23 Aug 2001 16:10:29 +0100
From: "Nathan Randle" <nathan.randle@ntlworld.com>
Subject: specific tutorial...
Message-Id: <m39h7.35643$0L6.5630847@news2-win.server.ntlworld.com>
I have learnt the basics surrounding Perl now I think but I want to make a
log in system for a program I am making. Is there any specific tutorials on
the web that explain how to make a log-in system?
------------------------------
Date: 23 Aug 2001 08:17:54 -0700
From: tanya.ruttenberg@ssa.gov (Tanya Ruttenberg)
Subject: Strange behavior of perl5 on HP-UX 11.0
Message-Id: <5af8662a.0108230717.77b6a9d0@posting.google.com>
I'm not sure if this is an HP OS problem or a Perl problem. That's why
I'm posting it to both newsgroups.
The sys admin installed perl5.00503 yesterday (downloaded the binary
distribution from the HP developer resource website) but it is
unusable due to an inability to execute it:
s12da21: /usr/local/bin/perl -e 'print "Hello\n";'
sh: /usr/local/bin/perl: Execute permission denied.
But it appears to be executable:
s12da21: ls -l /usr/local/bin/perl
-rwxr-xr-x 2 bin bin 384637 Jun 12 15:34 /usr/local/bin/perl
He (the sys admin) got the same error when trying to run it as root!?
I asked him to trace the process to see exactly which file was claiming
insufficient permissions, but he either didn't hear me, didn't know
how, or didn't want to for some other reason. He said he'd "look into it"
but I am skeptical he'll get back to me anytime soon.
Has anyone seen this problem before and do you know how to fix it?
------------------------------
Date: 23 Aug 2001 10:19:19 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Strange behavior of perl5 on HP-UX 11.0
Message-Id: <87u1yyerd4.fsf@limey.hpcc.uh.edu>
>> On 23 Aug 2001 08:17:54 -0700,
>> tanya.ruttenberg@ssa.gov (Tanya Ruttenberg) said:
> The sys admin installed perl5.00503 yesterday
> (downloaded the binary distribution from the HP
> developer resource website) but it is unusable due to an
> inability to execute it:
> s12da21: /usr/local/bin/perl -e 'print "Hello\n";' sh:
> /usr/local/bin/perl: Execute permission denied.
> But it appears to be executable:
> s12da21: ls -l /usr/local/bin/perl -rwxr-xr-x 2 bin bin
> 384637 Jun 12 15:34 /usr/local/bin/perl
> He (the sys admin) got the same error when trying to run
> it as root!?
Maybe the /usr/local filesystem is mounted via NFS with
the noexec flag (nothing to do with perl).
hth
t
--
Yes way! Mmmmkay.
------------------------------
Date: Thu, 23 Aug 2001 18:15:54 +0200
From: "H. Merijn Brand" <h.m.brand@hccnet.nl>
To: comp.sys.hp.hpux,comp.lang.perl.misc
Subject: Re: Strange behavior of perl5 on HP-UX 11.0
Message-Id: <Xns9106B9CD6209EMerijn@192.0.1.90>
Tony Curtis <tony_curtis32@yahoo.com> wrote in
news:87u1yyerd4.fsf@limey.hpcc.uh.edu:
>>> On 23 Aug 2001 08:17:54 -0700, tanya.ruttenberg@ssa.gov (Tanya
>>> Ruttenberg) said:
>
>> The sys admin installed perl5.00503 yesterday
>> (downloaded the binary distribution from the HP
>> developer resource website) but it is unusable due to an inability to
>> execute it:
>
>> s12da21: /usr/local/bin/perl -e 'print "Hello\n";' sh:
>> /usr/local/bin/perl: Execute permission denied.
>
>> But it appears to be executable:
>
>> s12da21: ls -l /usr/local/bin/perl -rwxr-xr-x 2 bin bin 384637 Jun 12
>> 15:34 /usr/local/bin/perl
>
>> He (the sys admin) got the same error when trying to run it as root!?
>
> Maybe the /usr/local filesystem is mounted via NFS with
> the noexec flag (nothing to do with perl).
Or it is built on a different architecture. try
# file /usr/local/bin/perl
--
H.Merijn Brand Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl-5.6.1, 5.7.1 & 628 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.022 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/
------------------------------
Date: Thu, 23 Aug 2001 17:20:58 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Using %{$hashref} or %$hashref to dereference??
Message-Id: <3B851F5A.3080800@post.rwth-aachen.de>
Anno Siegel wrote:
> I think "consistency" must be carefully defined before it can be
> trusted to make a program more readable. You can gain (false)
> consistency if you follow the rule: If you can make two expressions
> look similar, make them look similar. This may give you an optically
> neat program, but obviously you run the risk of hiding distinctions
> that should be visible.
[...]
> Since I'm rambling anyway, allow me an illustration: Suppose you are
> looking for *.log files that are two directories deep. Avoiding LTS
> you have the choice of
>
> m!/[^/]+/! && /\.log$/
> or
> m!/[^/]+/! && m!\.log$!
>
> The first follows the rule that you write a regex /.../ unless there
> is reason not to, and the second emphasizes that both parts of the
> conjunction are similar (namely regexes). Seen in isolation, there
> is no good way to decide which is "better". In the framework of
> a larger program there well may be.
Yes, agreed in this and probably many more cases. Yet, I was so careful
to wrap my statement about consistency into in if-clause....if the OP's
author wants consistency then he might do X since X will under any
circumstances work.
In Carlo's case my main purpose was to give him an example to show that
these two notions are not synonyms. In his case a little bit of
consistency will do good since he has the (noble) ambition to master
Perl almost thoroughly as quickly as possible. In the beginning it's
easier to have a few rules to stick to. You can break them later when
you understand what you are doing.
In this concern, Perl is very special: The learning curve isn't so
steep...but this curve is going on almost infinitely with each day a new
subtlety to be aware of. Perl is not a language that you try once and
leave forever...instead you'll stick with it probably your whole life
(or till something better comes up;-)
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: 23 Aug 2001 08:32:04 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Using %{$hashref} or %$hashref to dereference??
Message-Id: <m1d75m94i3.fsf@halfdome.holdit.com>
>>>>> "Tassilo" == Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> writes:
Tassilo> So, if you are heading for consistency which is not a bad habit, then
Tassilo> you should always use curly brackets since they always work.
We've found it pretty successful in our references class to teach the
curly brace form first (you always fall back to what you learned first
in a pinch), but then show the successive "optimizations" that can be
made... drop the curlies if it's a simple scalar, use arrow for
element access, drop the arrows between subscripty-things. Most
students are relieved to see the optimization, but appreciate the
"full blown form" as the canonical universal idea.
print ["Just another Perl hacker,"]->["with a bit of references to boot"]
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Thu, 23 Aug 2001 17:30:28 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Using %{$hashref} or %$hashref to dereference??
Message-Id: <x7k7zuhefc.fsf@home.sysarch.com>
>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
AS> According to Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>:
>>
>> %{$msg->header}
>>
>> to indicate that you explicitely want to call header on $msg and
>> dereference the returned value into a hash.
>>
>> So, if you are heading for consistency which is not a bad habit, then
>> you should always use curly brackets since they always work.
AS> Taking it to an extreme, would you also fully parenthesize arithmetic
AS> expressions? It always works, and it is consistent.
this is slightly different than the paren thing. parens only group and
don't (normally) affect values. a deref does affect a value and so can
be seen more as an operator (some other thread touched on that
concept). so if you think of it as an operator, then %{$href} can be seen as
the proper full syntax and %$href can be seen as the shortcut. most
people look at it the other way with a normal %$href and %{$href} as the
disambiguated version.
so you can be consistant here by always using the {} in derefs. it
doesn't follow like parens where you can go down an infinite corridor of
nesting. you can't nest %{} unless the data allows it.
so i use {} in my derefs all the time for style reasons. i feel it just
makes it more obvious that a simple deref is going on. and i code for
others to read, not for golf or obsfucation or cool constructs. others
disagree and that is what style is all about.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: 23 Aug 2001 17:52:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Using %{$hashref} or %$hashref to dereference??
Message-Id: <9m3fsf$ge7$1@mamenchi.zrz.TU-Berlin.DE>
According to Uri Guttman <uri@sysarch.com>:
> >>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
>
> AS> According to Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>:
> >>
> >> %{$msg->header}
> >>
> >> to indicate that you explicitely want to call header on $msg and
> >> dereference the returned value into a hash.
> >>
> >> So, if you are heading for consistency which is not a bad habit, then
> >> you should always use curly brackets since they always work.
>
> AS> Taking it to an extreme, would you also fully parenthesize arithmetic
> AS> expressions? It always works, and it is consistent.
>
> this is slightly different than the paren thing. parens only group and
> don't (normally) affect values.
I'm not sure what you mean. Random balanced parentheses strewn about
"1 + 2 * 3" certainly change the value.
> a deref does affect a value and so can
> be seen more as an operator (some other thread touched on that
> concept). so if you think of it as an operator, then %{$href} can be seen as
> the proper full syntax and %$href can be seen as the shortcut. most
> people look at it the other way with a normal %$href and %{$href} as the
> disambiguated version.
I don't quite follow your argument, but I'm with you that %{$href} is
the full form and %$href is syntactic sugar. But then, so is m// vs.
//, and everyone writes the latter. The full form isn't necessarily
the stylistically preferred one.
> so you can be consistant here by always using the {} in derefs. it
> doesn't follow like parens where you can go down an infinite corridor of
> nesting. you can't nest %{} unless the data allows it.
>
> so i use {} in my derefs all the time for style reasons. i feel it just
> makes it more obvious that a simple deref is going on. and i code for
> others to read, not for golf or obsfucation or cool constructs. others
> disagree and that is what style is all about.
I am less decided on that point. In particular for scalar refs I'm
quite happy with the $ref and $$ref distinction. ${$ref} looks overblown
for a measly scalar, somehow :)
Anno
------------------------------
Date: 23 Aug 2001 08:23:05 -0700
From: aspersion@yahoo.com (Isaac)
Subject: Re: Why wont this work!?!?!?
Message-Id: <e680b373.0108230723.40cd0579@posting.google.com>
Tom...Thank you for the insight....for the record. I CAN see the text
output at the command promt under NT using Active perl. I do get an
error under linux when I run the script from the command prompt but a
CTRL-D gets rid of the offline mode.
At any rate....Tom..
Below is the script with the subsituted strings. I do see hello
printed in the HTML but not the print "<b>$fa[3]</b>"; and yes the
array does have like an index of like 20 or so..like I say I can see
it at the command prompt.
How can I and I am quoting you "or output your file as text/plain."??
Thanks in advance.
use CGI qw(:standard);
#use strict;
open (FILE, "file.txt")|| die $!;
@fa = <FILE>; #makes file to an array
close FILE;
$|=1;
#chomp @fa;
print header;
start_html();
print "<b>$fa[3]</b>";
print "<b>hello</b>";
end_html();
Thomas Bätzler <Thomas@Baetzler.de> wrote in message news:<f9c9ot4j9tk3ik51dunpka52q31gjstqm1@4ax.com>...
> On 22 Aug 2001, aspersion@yahoo.com (Isaac) wrote:
> >C:\Inetpub\scripts\test>perl -w test420.pl
> >Content-Type: text/html; charset=ISO-8859-1
> >
> > Range Delay: 11360 meters
> >
> >C:\Inetpub\scripts\test>
> >
> >Which is the content of the file......Which is GOOD
> >
> >But when I access it from a web browser it page comes up BLANK?!?!?!
> >No errors whatsoever.
>
> Your script header claims that the output is text/html, but there is
> just plain text in the output. Try adding start_html() and end_html()
> calls in your code, or output your file as text/plain.
>
> HTH,
------------------------------
Date: 23 Aug 2001 10:34:47 -0700
From: ppeisa@cc.hut.fi (Pentti Peisa)
Subject: win32 system command and stdout
Message-Id: <9de7318a.0108230934.6b6977dd@posting.google.com>
Hi,
I am having difficulties controlling stdout and stderr stream while I
am executing external program with system command. I don't want any
output from those external processes I have tried following codes
without success.
open(STDOUT, ">logfile");
open(STDERR,">errfile.txt");
system("command");
---------------------------------
close(STDOUT);
close(STDERR);
system("command");
--------------------------------
`command`;
----------------------------------
Output from the external command is mixing with my cgi output.
thanks in advance.
Pentti
Helsinki University of Technology
------------------------------
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.
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 1598
***************************************