[13372] in Perl-Users-Digest
Perl-Users Digest, Issue: 782 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 13 18:07:20 1999
Date: Mon, 13 Sep 1999 15:05:09 -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, 13 Sep 1999 Volume: 9 Number: 782
Today's topics:
%HoH2=%HoH1 yields synonymity!?! strebs87@my-deja.com
%HoH2=%HoH1 yields synonymity!?! strebs87@my-deja.com
Re: %HoH2=%HoH1 yields synonymity!?! (Kragen Sitaker)
Re: %HoH2=%HoH1 yields synonymity!?! <crdevilb@mtu.edu>
Re: %HoH2=%HoH1 yields synonymity!?! (Kragen Sitaker)
Bizarre DBI/DBD::Oracle Problem(?) <chatto@ctp.com>
Re: buying perl book (Help me) <mike@crusaders.no>
CGI Oracle problem <antoine@pacha.nl>
Re: Creating a File with Username and password (Kragen Sitaker)
Re: Design Advice needed on Sending Data to Client <flavell@mail.cern.ch>
Re: How to determine a file or folder on winNT (Kragen Sitaker)
Re: How to know an ip address of visitor who are behind (Kragen Sitaker)
Re: How to perform nslookup functions in perl? <blair.kissel@mts.mb.ca>
Re: I need a date function... <dove@synopsys.com>
Re: I need a date function... (Larry Rosler)
installing perl modules <mikej@1185design.com>
Looking to fill time / make money <lchuck@home.com>
Re: multiple perl's <jerrad@networkengines.com>
Re: Perl Y2k (Sam Holden)
Re: Perl Y2k (Sam Holden)
POST is not allowed <ceb012@lmpsil02.comm.mot.com>
Re: POST is not allowed <antoine@pacha.nl>
Rcp (remote copy) in Win32 Perl? <jeff_annex@hotmail.com>
syslog / linux <SternSZ@gmx.de>
Re: syslog / linux <antoine@pacha.nl>
Re: UNCRAP project proposal <tchrist@mox.perl.com>
Re: UNCRAP project proposal (Larry Rosler)
Re: UNCRAP project proposal (Alan Curry)
Re: UNCRAP project proposal (Larry Rosler)
WHY??? <davidmck@earthlink.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 13 Sep 1999 20:07:46 GMT
From: strebs87@my-deja.com
Subject: %HoH2=%HoH1 yields synonymity!?!
Message-Id: <7rjli7$666$1@nnrp1.deja.com>
Please help! Why can't one equate an empty Hash of
Hashes to one that's defined and not empty, get a
copy and preserve the master intact and
independent of the copy? When I modify the copy
the master gets modified, too. !?!!??. Am I
missing something obvious?
# test script
# define master
$Master{'level1_key1'}{'level2_key1'}='blah';
$Master{'level1_key1'}{'level2_key2'}='blah2';
# equate
%Copy=%Master;
&ShowStatus('Before deletion', 'Master','Copy');
#perform 'delete' on the copy
delete $Copy{'level1_key1'}{'level2_key1'};
&ShowStatus('After deleting *!just the copy!*',
'Master','Copy');
print "\n";
#-------------------------------------
sub ShowStatus {
my($when)=shift;
my($k1,$k2,%h);
foreach (@_) {
%h=%$_;
print "\n$when $_ is";
foreach $k1 (keys %h) {
print "\n\t$k1 =>";
foreach $k2 (keys %{$h{$k1}}) {
print "\n\t\t$k2 => ",$h{$k1}{$k2};
}
}
print "\n",'-'x40;
}
}
#-------------------------------------
# end of script
the script yields (in 5.005_03, linux):
Before deletion Master is
level1_key1 =>
level2_key1 => blah
level2_key2 => blah2
----------------------------------------
Before deletion Copy is
level1_key1 =>
level2_key1 => blah
level2_key2 => blah2
----------------------------------------
After deleting *!just the copy!* Master is
level1_key1 =>
level2_key2 => blah2
----------------------------------------
After deleting *!just the copy!* Copy is
level1_key1 =>
level2_key2 => blah2
----------------------------------------
I'm completely mystified; how do I preserve
%Master!?
thanks in advance,
Andrew Strebkov
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 13 Sep 1999 20:21:22 GMT
From: strebs87@my-deja.com
Subject: %HoH2=%HoH1 yields synonymity!?!
Message-Id: <7rjmbk$6no$1@nnrp1.deja.com>
Please help! Why can't one equate an empty Hash of
Hashes to one that's defined and not empty, get a
copy and preserve the master intact and
independent of the copy? When I modify the copy
the master gets modified, too. !?!!??. Am I
missing something obvious?
# test script
# define master
$Master{'level1_key1'}{'level2_key1'}='blah';
$Master{'level1_key1'}{'level2_key2'}='blah2';
# equate
%Copy=%Master;
&ShowStatus('Before deletion', 'Master','Copy');
#perform 'delete' on the copy
delete $Copy{'level1_key1'}{'level2_key1'};
&ShowStatus('After deleting *!just the copy!*',
'Master','Copy');
print "\n";
#-------------------------------------
sub ShowStatus {
my($when)=shift;
my($k1,$k2,%h);
foreach (@_) {
%h=%$_;
print "\n$when $_ is";
foreach $k1 (keys %h) {
print "\n\t$k1 =>";
foreach $k2 (keys %{$h{$k1}}) {
print "\n\t\t$k2 => ",$h{$k1}{$k2};
}
}
print "\n",'-'x40;
}
}
#-------------------------------------
# end of script
the script yields (in 5.005_03, linux):
Before deletion Master is
level1_key1 =>
level2_key1 => blah
level2_key2 => blah2
----------------------------------------
Before deletion Copy is
level1_key1 =>
level2_key1 => blah
level2_key2 => blah2
----------------------------------------
After deleting *!just the copy!* Master is
level1_key1 =>
level2_key2 => blah2
----------------------------------------
After deleting *!just the copy!* Copy is
level1_key1 =>
level2_key2 => blah2
----------------------------------------
I'm completely mystified; how do I preserve %Master!?
thanks in advance,
Andrew Strebkov
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 13 Sep 1999 20:44:54 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: %HoH2=%HoH1 yields synonymity!?!
Message-Id: <andD3.8694$N77.664899@typ11.nn.bcandid.com>
In article <7rjli7$666$1@nnrp1.deja.com>, <strebs87@my-deja.com> wrote:
>Please help! Why can't one equate an empty Hash of
>Hashes to one that's defined and not empty, get a
>copy and preserve the master intact and
>independent of the copy? When I modify the copy
>the master gets modified, too. !?!!??. Am I
>missing something obvious?
%x = %y copies everything in %y into %x. If %y has a reference to a
hash as a value, %x gets a copy of the reference -- referring to the
same hash.
So if you do this:
#!/usr/bin/perl -w
use strict;
my %x = ( a => {a => 'b', 'c' => 'd'} );
my %y = %x;
$y{a}{a}='gorp';
print "$x{a}{a}\n";
then $x{a}{a} will be 'gorp' too. Instead you could say:
#!/usr/bin/perl -w
use strict;
my %x = ( a => {a => 'b', 'c' => 'd'} );
my %y;
my ($k, $v);
while (($k, $v) = each %x) {
$y{k} = {%$v};
}
$y{a}{a} = 'gorp';
print "x: $x{a}{a} y: $y{a}{a}\n";
it works correctly, and you get:
x: b y: gorp
This is known as making a 'deep copy' of %x -- specialized for the
'hash of hashes' case. Someone asked earlier today if there was a
generic deep copy routine for Perl; I haven't seen an answer to that
question yet.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Mon Sep 13 1999
56 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 13 Sep 1999 20:40:43 GMT
From: Colin R. DeVilbiss <crdevilb@mtu.edu>
Subject: Re: %HoH2=%HoH1 yields synonymity!?!
Message-Id: <7rjngb$bn$1@campus1.mtu.edu>
strebs87@my-deja.com wrote:
> When I modify the copy
> the master gets modified, too. !?!!??. Am I
> missing something obvious?
just the fact that the master isn't being modified. :)
> # test script
> # define master
> $Master{'level1_key1'}{'level2_key1'}='blah';
> $Master{'level1_key1'}{'level2_key2'}='blah2';
%Master is a hash of references to hashes--that is, the ``level2_key''
fields below really belong to an anonymous hash.
> # equate
> %Copy=%Master;
This copies one level deep--%Copy contains all the keys and values
that were in %Master, which is just 'level1_key1' => HASH0xstuff.
Thus, changes to the anonymous HASH will affect both.
> I'm completely mystified; how do I preserve
> %Master!?
investigate the Data::Dumper module on CPAN, which implements true
``deep copy'', which is what you want.
Colin DeVilbiss
crdevilb@mtu.edu
------------------------------
Date: Mon, 13 Sep 1999 22:02:25 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: %HoH2=%HoH1 yields synonymity!?!
Message-Id: <RveD3.8895$N77.675515@typ11.nn.bcandid.com>
In article <7rjngb$bn$1@campus1.mtu.edu>,
Colin R. DeVilbiss <crdevilb@mtu.edu> wrote:
>investigate the Data::Dumper module on CPAN, which implements true
> ``deep copy'', which is what you want.
Data::Dumper's deep copy works by creating a string you can then eval.
Here's an (incomplete) deep copy; it works with nested structures made
of references to arrays, hashes, scalars, and objects consisting of
blessed references to one of the above. It handles circular data
structures correctly -- at least the two I've tested it with -- and,
when given a structure that contains multiple references to the same
object, will produce as output a structure that contains multiple
references to a single copy of that object.
BUGS:
- It doesn't handle CODE or GLOB refs, because I'm not sure what it means
to 'deep copy' them.
- It doesn't handle anything not mentioned in 'perldoc -f ref', because
I don't know about it. I suspect lvalues returned by substr are among
these.
- It may not be a good idea to use this on structures containing
blessed objects, because some classes may have their semantics broken
by careless outsiders (like this routine) deep-copying their members.
(I expect most classes with DESTROY methods will have this problem.)
#!/usr/bin/perl -w
use strict;
my $uglymofo = [
{'x' => 'y',
'mother' => {'mama' => 1, 'papa' => 2},
'father' => [undef, 'mama', 'papa'],
},
31,
\\"boo"
];
push @$uglymofo, $uglymofo; # circular data structure
sub deepcopy_internal;
# %$loops lets us look up references we've already copied
sub deepcopy_internal {
my ($ref, $loops) = @_;
my $type = ref $ref;
if (not $type) {
return $ref; # copy scalar
}
if (exists $loops->{$ref}) {
return $loops->{$ref};
}
if (UNIVERSAL::isa($ref, 'HASH')) {
my $h = {};
$loops->{$ref} = $h;
my ($k, $v);
while (($k, $v) = each %$ref) {
$h->{$k} = deepcopy_internal $v, $loops;
}
if ($type ne 'HASH') {
bless $h, $type;
}
return $h;
} elsif (UNIVERSAL::isa($ref, 'ARRAY')) {
my $a = [];
$loops->{$ref} = $a;
push @$a, map {deepcopy_internal $_, $loops} @$ref;
if ($type ne 'ARRAY') {
bless $a, $type;
}
return $a;
} elsif (UNIVERSAL::isa($ref, 'REF')) {
my $ss;
my $s = \$ss;
$loops->{$ref} = $s;
$$s = deepcopy_internal $$ref, $loops;
if ($type ne 'REF') {
bless $s, $type;
}
return $s;
} elsif (UNIVERSAL::isa($ref, 'SCALAR')) {
my $ss;
my $s = \$ss;
$loops->{$ref} = $s;
$$s = deepcopy_internal $$ref, $loops;
if ($type ne 'SCALAR') {
bless $s, $type;
}
return $s;
} else {
die "Can't handle $ref (type $type)";
}
}
sub deepcopy {
deepcopy_internal $_[0], {};
}
my $circle = [];
push @$circle, $circle;
my $x;
for ('foo', \'foo', [], ['foo'], {}, {'a' => ['foo']}, $circle, $uglymofo) {
$x = deepcopy $_;
print $x, "\n";
}
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Mon Sep 13 1999
56 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 18:02:18 -0500
From: Charlie Hatton <chatto@ctp.com>
Subject: Bizarre DBI/DBD::Oracle Problem(?)
Message-Id: <37DD827A.4E40165D@ctp.com>
Hi -- I'm having a very odd problem, using the following setup:
Perl 5.005_03 on Solaris 2.6, with DBI v1.13 and DBD-Oracle v1.03
connecting to a (local) Oracle 8.0.5 database, with I/O using CGI.pm and
Netscape Enterprise server v3.62. Here's the scoop:
I've written a small piece of code to connect to the DB and pull a few
thousand rows of data from a particular table. It works fine for
NUMBER() or DATE fields no matter how it's called. However, when I try
to retrieve a particular VARCHAR2(255) format field (the most important
to me, naturally), I get very strange results: when called as CGI over
the web, the VARCHAR2 fields are largely blank, with a rare row
containing a single letter from the field (which typically contains
50-200 characters of data). Numerical/date fields select'ed in the same
SQL statement are unaffected. Strangest of all (to me, at least), when I
call the same script from the shell and supply the correct params to the
CGI.pm command line interface, the rows are returned completely
correctly! I've also found that Perl 'thinks' that the text is there in
each row: a test of the format
if ($field ne /\w/) {
print "No text<br>\n";
} else {
print "Field = $field<br>\n";
}
gives me the field names properly from the command line, but a long
string of "Field = " lines via the WWW; the 'No text' flag is never
printed.
Any help would be greatly appreciated -- I've worked with WWW/CGI/DBI
scripts/apps for quite a while, and have never seen *anything* quite
like this. I suspect that the DBI/DBD versions I have might be to blame,
but really only b/c I can't think of a better reason. Thanks in advance;
please post here or send to me at chatto@ctp.com.
Charlie
------------------------------
Date: Mon, 13 Sep 1999 23:52:27 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: buying perl book (Help me)
Message-Id: <_jeD3.2486$rf1.16212@news1.online.no>
Neil <neil@pacifier.com> wrote in message
news:37d93a96.0@news.pacifier.com...
> sine2117@my-deja.com wrote:
> > Hello, anyone have a good tip of a nice perl book. like perl cookbook or
> > something ?
> These are the standard introductory books:
> "The Perl Cookbook" is an introductory learn-by-example book.
> "Learning Perl" is a gentle introduction to Perl, for those with little
> programming experience.
> "Programming Perl" is an introduction for those with programming
experience.
and if you can't afford buying them all at once, you might consider buying
the "Perl CD Bookshelf"
Perl in a Nutshell, Learning Perl (llama and gecko), Programming Perl,
Advanced Perl Programming and Perl Cookbook. All books in HTML-format on a
CD (and the nutshell is included as dead trees as well).
No, you can't read it in bed or on the bus, but you can keep a
browser-window in the background while you program.
http://www.oreilly.com/catalog/perlcdbs/
You'll be able to pick it up for less than $40 at online-shops, so it's
definately worth it's price.
--
Trond Michelsen
------------------------------
Date: Mon, 13 Sep 1999 22:06:58 +0200
From: "Anthony Adams" <antoine@pacha.nl>
Subject: CGI Oracle problem
Message-Id: <37dd5926$0$28743@reader1.casema.net>
At my work i'm working on a script that puts some values into a oracle 8
database.
The stupid this is:
When we run it from the commandine it goes extremely fast (as it should)
But when the data is posted from the webpage we designed for it and submit
the data it takes about 20-30 seconds to return. The statement works, data
is entered into the database but why does it take so damn long?
When we put the same data into a flat textfile it returns directly.
Here's the source:
use DBI;
$dbh = DBI->connect( 'dbi:Oracle:oracle:localhost:',
'<username>', # yes i did fill this correctly
'<password>', # see up
{ RaiseError => 1,
AutoCommit => 1}) || die "Database connection not made:
$DBI::errstr";
#my $sql = "INSERT INTO RFC
VALUES($a,'$b','$datein','$c','$reden','$omschrijvin
g','a','zz')";
#$dbh->do($sql);
$dbh->disconnect;
The data is generated by the page.
I don't get it why it takes so long?
Please reply to me at: tadams@snt.nl or antoine@pacha.nl
Maybe i can help you with another problem!
Grtz Anthony
------------------------------
Date: Mon, 13 Sep 1999 20:08:11 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Creating a File with Username and password
Message-Id: <LQcD3.8559$N77.659875@typ11.nn.bcandid.com>
In article <7rji0b$39f$1@nnrp1.deja.com>, <dmcp71@my-deja.com> wrote:
>What I need
>to do is to create a login page with a username, email address and
>password. When the user enters their name, username and email address,
>a file is created for them using their username and password with
>either a unique id number or something similar that will allow them to
>enter additional information and retrieve it whenever they want.
Which part of this are you having trouble with? Creating the login
page, creating user accounts, storing additional information, verifying
logins, what?
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Mon Sep 13 1999
56 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 22:05:46 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Design Advice needed on Sending Data to Client
Message-Id: <Pine.HPP.3.95a.990913220352.13201F-100000@hpplus03.cern.ch>
On Mon, 13 Sep 1999, Kragen Sitaker wrote:
> See the HTTP/1.1 definition:
> http://www.normos.org/ietf/rfc/rfc2068.txt
>
> It's about 160 pages, so you should be able to finish it in just a few
> hours.
What a disappointment then to find what it says in RFC2616:
Network Working Group
Request for Comments: 2616
Obsoletes: 2068
Category: Standards Track
cheers
------------------------------
Date: Mon, 13 Sep 1999 20:10:53 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How to determine a file or folder on winNT
Message-Id: <hTcD3.8569$N77.660914@typ11.nn.bcandid.com>
In article <macD3.2322$rf1.14035@news1.online.no>,
Jon <jonra@hotmail.com> wrote:
>Is there a way to determin whether an object is a file or a folder without
>using the -d $filename. This does not seem to work on winNT.
Can you be more specific about "does not seem to work"? Does it give
you error messages and refuse to run? Does it give you incorrect
results?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Mon Sep 13 1999
56 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 20:18:40 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How to know an ip address of visitor who are behind proxy server?
Message-Id: <A_cD3.8599$N77.661786@typ11.nn.bcandid.com>
In article <Pine.HPP.3.95a.990913193427.13201E-100000@hpplus03.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:
>You could ask the user. They might answer. It might or might not be
>the truth.
I understand JavaScript people have ways of finding these things out.
(Of course, they won't work for smart folks who turn JavaScript off, or
for people with modified JavaScript interpreters.)
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Mon Sep 13 1999
56 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 15:13:19 -0500
From: Blair Kissel <blair.kissel@mts.mb.ca>
Subject: Re: How to perform nslookup functions in perl?
Message-Id: <37DD5ADE.95A60231@mts.mb.ca>
As I indicated in the above thread, I was unaware that the terminology for my
task was a zone transfer, thus I skipped over that example. Once I realized this
was in fact what I needed to do, I subsequently read the example and completed
the task without incident.
Blair
Mitchell Morris wrote:
> In article <37D9170C.9C6380F9@mts.mb.ca>, Blair Kissel wrote:
> >I need to perform the following:
> >
> >nslookup
> >ls -t a foo.com
> >
> >This returns a list of A records for the domain. I need to do this in
> >perl and then store the resulting A records (hostname and ip address) in
> >a hash. I have looked at the Net::DNS module but can't seem to find a
> >way to do it. Can somebody help me please?
> >
> >Thank you,
> >
> >Blair
>
> Maybe you need a newer Net::DNS module. I'm using verion 0.12, available from
> CPAN (as always), and my install includes the exact code you're asking about
> in the lovely "examples" section.
>
> % perldoc Net::DNS
> ...
>
> Find the nameservers for a domain.
>
> use Net::DNS;
> $res = new Net::DNS::Resolver;
> $query = $res->query("foo.com", "NS");
> if ($query) {
> foreach $rr ($query->answer) {
> next unless $rr->type eq "NS";
> print $rr->nsdname, "\n";
> }
> }
> else {
> print "query failed: ", $res->errorstring, "\n";
> }
>
> ...
>
> Perform a zone transfer and print all the records.
>
> use Net::DNS;
> $res = new Net::DNS::Resolver;
> $res->nameservers("ns.foo.com");
> @zone = $res->axfr("foo.com");
> foreach $rr (@zone) {
> $rr->print;
> }
>
> ...
>
> Using my mouse (mostly), and a little supplementary typing, I get:
>
> use strict;
> use Net::DNS;
>
> my %fwd;
> my %rev;
> my @ns;
>
> my $res = new Net::DNS::Resolver;
> my $query = $res->query("foo.com", "NS");
> if ($query) {
> foreach my $rr ($query->answer) {
> next unless $rr->type eq 'NS';
> push @ns, $rr->nsdname;
> }
> } else {
> die "query failed: ", $res->errorstring, "\n";
> }
> $res->nameservers(@ns);
> die "how did *THAT* happen?\n" unless @ns;
> my @zone = $res->axfr("foo.com");
> foreach my $rr (@zone) {
> next unless $rr->type eq 'A';
> print "name=@{[$rr->name]}, ip=@{[$rr->address]}\n";
> $fwd{$rr->name} = $rr->address;
> $rev{$rr->address} = $rr->name;
> }
>
> That wasn't so bad, now was it? I hope that your need hasn't expired. Perhaps
> in the future you will find "perldoc" to be a more timely assistant than
> comp.lang.perl.misc can be.
>
> HTH.
>
> --
> Mitchell Morris
>
> This mind intentionally left blank.
------------------------------
Date: Mon, 13 Sep 1999 14:01:37 -0700
From: David Amann <dove@synopsys.com>
Subject: Re: I need a date function...
Message-Id: <37DD6631.8A807522@synopsys.com>
Hi Jeff,
Jeff Battle wrote:
> I can get the weekday of the current day but I need the weekday of any
> entered date.
>
> What's the easiest way to do this in Perl?
There are two ways to do this. The first way is to convert your date to Epoch
seconds using the Time::Local module, and then use the localtime function to
get the day of the week number. Try this:
#!/usr/local/bin/perl -w
use Time::Local;
#To find the epoch seconds for 9/13/99
# $mon = 0 == 'January'
my ($sec, $min, $hour, $mday, $mon, $year) =
(0, 0, 0, 13, 8, 1999);
$TIME = timelocal($sec, $min, $hour, $mday, $mon, $year);
my ($WEEKDAY) = (localtime $TIME)[6];
You can also use the Date:Calc module from CPAN as follows:
#!/usr/local/bin/perl -w
use Date::Calc qw(Day_of_Week);
#For 9/13/99
my $WEEKDAY = Day_of_Week('1999', '9', '13');
This requires you downloading and installing the Date::Calc module from CPAN
(http://cpan.perl.org).
Hope this helps,
-=dav
------------------------------
Date: Mon, 13 Sep 1999 14:24:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: I need a date function...
Message-Id: <MPG.12470b547c63fd9b989f53@nntp.hpl.hp.com>
In article <37DD6631.8A807522@synopsys.com> on Mon, 13 Sep 1999 14:01:37
-0700, David Amann <dove@synopsys.com> says...
+ Jeff Battle wrote:
+ > I can get the weekday of the current day but I need the weekday of
+ > any entered date.
+ >
+ > What's the easiest way to do this in Perl?
+
+ There are two ways to do this. The first way is to convert your date
+ to Epoch seconds using the Time::Local module, and then use the
+ localtime function to get the day of the week number. Try this:
+
+ #!/usr/local/bin/perl -w
+
+ use Time::Local;
+
+ #To find the epoch seconds for 9/13/99
+ # $mon = 0 == 'January'
+ my ($sec, $min, $hour, $mday, $mon, $year) =
+ (0, 0, 0, 13, 8, 1999);
Ook. You got the month right, but not the year.
+ $TIME = timelocal($sec, $min, $hour, $mday, $mon, $year);
+
+ my ($WEEKDAY) = (localtime $TIME)[6];
Inadvisable use of all-upper-case names for variables, and list
assignment for a scalar.
+ You can also use the Date:Calc module from CPAN as follows:
+
+ #!/usr/local/bin/perl -w
+
+ use Date::Calc qw(Day_of_Week);
+
+ #For 9/13/99
+ my $WEEKDAY = Day_of_Week('1999', '9', '13');
+
+ This requires you downloading and installing the Date::Calc module
+ from CPAN (http://cpan.perl.org).
Yes. So why bother, when the other is smaller, faster, and already on
the system?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 13 Sep 1999 14:02:01 -0700
From: mikej <mikej@1185design.com>
Subject: installing perl modules
Message-Id: <37DD664C.9AEA4171@1185design.com>
Hi,
Im trying to install some perl modules, and I got the perl Makefile.PL
command to work by entering the full path to perl (BTW how do I set it
up so I can just type perl and not the whole path, is there some config
file in Apache?) but now I try to do the make test and make install
commands to finish installing the module but it gives me this error:
make: not found
do I have to set up a full path to this or something? Shouldnt it just
work like a normal unix command? Thanks for any help.
mike
------------------------------
Date: Mon, 13 Sep 1999 21:02:20 GMT
From: Chris <lchuck@home.com>
Subject: Looking to fill time / make money
Message-Id: <37DD65FF.66C26C39@home.com>
Hello all! I'm a college student that is currently in-between jobs. In
search of something interesting to do and also a way to make money, I'm
posting an ad here for anyone who might want to procure my services. I
have been programming Perl for a while now and am most proficient in web
based Perlscript / Active Server Pages. If you or your small business
is looking for a way to automate certain procedures or just a way to
make a process work better, you may want to use Perl. My services come
cheap and I'm always willing to try something new. If you think you
could use me for something, just send an email to lchuck@home.com and
describe the application that you are looking for. Thanks!!!!
Chris
------------------------------
Date: Mon, 13 Sep 1999 17:14:33 -0400
From: jerrad pierce <jerrad@networkengines.com>
Subject: Re: multiple perl's
Message-Id: <37DD6939.7A033148@networkengines.com>
No. IPC could be used as a workaround, shared memory is essentially what I wanted. I am already doing IPC via a FIFO, joy.
------------------------------
Date: 13 Sep 1999 21:30:13 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl Y2k
Message-Id: <slrn7tqr75.fec.sholden@pgrad.cs.usyd.edu.au>
On Mon, 13 Sep 1999 14:26:21 -0400, Li Kong <lkong@hns.com> wrote:
>How can I get a 4-digital year using localtime()?
Wait about 901 1/3 years and call it then.
Didn't other reading the documentation did you... Of course not your time
is much more valuable than the time of the thousands of people whose time
you wasted...
--
Sam
PC's are backwards ... throw them out! Linux is ok though.
--Rob Pike (on the subject of CR/LF etc)
------------------------------
Date: 13 Sep 1999 21:37:35 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl Y2k
Message-Id: <slrn7tqrkv.fec.sholden@pgrad.cs.usyd.edu.au>
On 13 Sep 1999 21:30:13 GMT, Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote:
>On Mon, 13 Sep 1999 14:26:21 -0400, Li Kong <lkong@hns.com> wrote:
>>How can I get a 4-digital year using localtime()?
>
>Wait about 901 1/3 years and call it then.
Or even 900 1/3 years...
--
Sam
Anyway, the other successor to C gobbled up two letters instead of one.
Which is why many Perl scripts have the extension, ``.pl'', finishing
off BCPL. --Larry Wall
------------------------------
Date: Mon, 13 Sep 1999 16:25:01 -0500
From: Eric Brummer <ceb012@lmpsil02.comm.mot.com>
Subject: POST is not allowed
Message-Id: <37DD6BAD.A9FB219E@lmpsil02.comm.mot.com>
Ok,
Here's the problem. I have an apache web server running 1.3b7 on an
hpux machine with perl 5.001 with a whole bunch of perl scripts that
work fine; one this machine I am the web server admin. All the scripts
work fine. On a second server running apache 1.3.3 which is publicly
available and I am not the web admin on, I have the same perl scripts
with perl 5.005-51. Some of the scripts using POST are working and
others using POST are not working. The error that I get is:
Method Not Allowed
The requested method POST is not allowed for the URL ...
I do this as a back, background task and do not want to spend a lot of
time debugging and don't want to open up my machine to "public" access.
Further, I'm leaving the job in 3 weeks and no one knows what I know
about the construction of the tools, so I don't want to have to train
them. I have little idea of the server config. By the way, all of my
shebangs are correct.
Any help would be appreciated. email to ceb012@email.mot.com
------------------------------
Date: Tue, 14 Sep 1999 00:03:56 +0200
From: "Anthony Adams" <antoine@pacha.nl>
Subject: Re: POST is not allowed
Message-Id: <37dd748b$0$758@reader2.casema.net>
What modules are you using?
Maybe some updates could make it work again.. Had the same..
Grtz Anthony
------------------------------
Date: Mon, 13 Sep 1999 16:56:00 -0400
From: Jeff <jeff_annex@hotmail.com>
Subject: Rcp (remote copy) in Win32 Perl?
Message-Id: <37DD64E0.C80ACEEE@hotmail.com>
Hi all,
I wonder if there is a remote copy (rcp) unit for Perl Win32 version?
Since rcp is not a Win32 "shell" command, I can't use the system()
method as
using Perl on UNIX.
Thanks,
Jeff
------------------------------
Date: 13 Sep 1999 22:13:56 +0200
From: Benjamin Schweizer <SternSZ@gmx.de>
Subject: syslog / linux
Message-Id: <m3906a603f.fsf@anthrax.local.net>
Hello,
I´ve written a little daemon and I want to save messages (stdout) to the syslog
daemon. Is there a function in perl or is this done by the os?
regards
-Benjamin
--
http://privat.schlund.de/SternSZ/
$ man 1 perl | grep -A1 "Eclectic" -A1
------------------------------
Date: Tue, 14 Sep 1999 00:05:18 +0200
From: "Anthony Adams" <antoine@pacha.nl>
Subject: Re: syslog / linux
Message-Id: <37dd74dc$0$764@reader2.casema.net>
Benjamin Schweizer heeft geschreven in bericht ...
>Hello,
>
>I´ve written a little daemon and I want to save messages (stdout) to the
syslog
>daemon. Is there a function in perl or is this done by the os?
>
Have you tried to use a | to the syslogd ?
------------------------------
Date: 13 Sep 1999 14:21:32 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: UNCRAP project proposal
Message-Id: <37dd5ccc@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, abigail@delanet.com writes:
:CGI.pm's set of methods that output
:html tags seems to me as useful as an English.pm module with a method
:for every word, and using that instead of writing plain text.
Actually, the real usefulness is what you see in CGI::Form.
Auto-regenerating sticky widgets that implicitly have persistent values.
:It's all
:too much 'oh-golly-this-looks-like-I-am-doing-OOP' just for the sake of
:looking like you're doing OOP.
Yes, that's silly.
--tom
--
if (instr(buf,sys_errlist[errno])) /* you don't see this */
--Larry Wall in eval.c from the 4.0 perl source code
------------------------------
Date: Mon, 13 Sep 1999 13:26:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: UNCRAP project proposal
Message-Id: <MPG.1246fdc56027d22c989f51@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <x7ogf6link.fsf@home.sysarch.com> on 13 Sep 1999 15:23:59 -
0400, Uri Guttman <uri@sysarch.com> says...
...
> the functions are very useful if you are processing a list of items
> (including other sub calls) which can't be nicely done in a here doc (i
> don't like to use the expression interpolation tricks). also it makes
> factoring some attributes over a list of items much easer, e.g. an
> alignment value can be applied to all columns of a table row without
> duplicating it for each column.
Ahem. Don't need no steenkin' module for that!
<TR ALIGN=right><TD> ... </TD></TR>
> if it changes you only have one change
> to make. also using the html functions make sure you have correct html
> syntax and your script will break at the perl compile time which is
> easier to debug than waiting to see what the browser shows.
I don't understand this. There are no semantic checks in CGI.pm, and
the syntax just requires properly nested function calls. So I have no
idea what you mean by breaking at compile time.
> also i do not use the object form, but the exported subs which makes it
> look like regular code. in most cases only one query object is needed
> and this technique uses it behind the scenes so it looks fine.
Of course. I think the CGI object stuff is just blague. (But then so
is most object stuff anyway. :-)
> it is just another tool and i find it helpfule at time. i don't use it
> for all html output but for much of it.
As an avowed anti-module-ite, I began to use CGI.pm when I had to deal
for the first time with a file upload. It solved that problem so well
that I decided to use it to write the HTML output also.
CGI.pm is quite useless when one has long sections (such as <CENTER>ed
text) with program decisions to be made during the content generation.
It is far simpler to generate the <CENTER> and </CENTER> tags
explicitly.
CGI.pm HTML is also far too verbose, insisting on explicitly stating all
defaults and assiduously closing all optional tags (such as </TD>) and
quoting every attribute value. All this unnecessarily lengthens
transmission times for long tables, for example.
On the other hand, CGI.pm never emits a newline (to conserve
transmission time, 15% to 20% according to the docs), though that makes
the output unreadable on a browser. So I have to lace my function calls
with explicit newlines anyway, because it is essential for debugging to
be able to read the HTML output, either in a browser or directly from
the command line.
These two attitudes toward output length are inconsistent, to say the
least.
Having written one program using (mostly, as you say) CGI.pm output
functions, I don't think I'll rewrite it using HTML, but I also don't
think I'll do my next program that way. Of course, having learned Yet
Another Little Language (the HTML-output function calls of CGI.pm) in
addition to HTML, I would find it easier the next time. But who cares?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 13 Sep 1999 21:01:11 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: UNCRAP project proposal
Message-Id: <rCdD3.8756$N77.666649@typ11.nn.bcandid.com>
In article <37dd5ccc@cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>In comp.lang.perl.misc, abigail@delanet.com writes:
>:CGI.pm's set of methods that output
>:html tags seems to me as useful as an English.pm module with a method
>:for every word, and using that instead of writing plain text.
>
>Actually, the real usefulness is what you see in CGI::Form.
>Auto-regenerating sticky widgets that implicitly have persistent values.
I found those most annoying when I was making a form where the same values
just don't belong in the same place from one instance to another. I asked for
textfield("foo","bar") and CGI.pm decided it would rather keep the
foo=BIG_WRONG_THING it had seen in the input than just give me what I asked
for.
There is the -force flag to get rid of that behavior, but I had lots and lots
of fields and I didn't want to go through changing them all from the simple
("foo","bar") to the awfully-verbose (-name=>"foo",-value=>"bar",-force=>1)
so I came up with this not-too-ugly solution:
$in = new CGI();
$out = new CGI('');
$out->textfield("foo","bar") # no stickyness from $in dammit!
>:It's all
>:too much 'oh-golly-this-looks-like-I-am-doing-OOP' just for the sake of
>:looking like you're doing OOP.
>
>Yes, that's silly.
I can think of one advantage: You can't match <table> </table> with the vi %
command.
This thread is silly too. It started with someone suggesting that other
people write something for him, and then proceeding to micro-manage what
methods they're allowed to use to get it done. Very PHB.
--
Alan Curry |Declaration of | _../\. ./\.._ ____. ____.
pacman@cqc.com|bigotries (should| [ | | ] / _> / _>
--------------+save some time): | \__/ \__/ \___: \___:
Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman
------------------------------
Date: Mon, 13 Sep 1999 14:03:40 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: UNCRAP project proposal
Message-Id: <MPG.1247068741dcf214989f52@nntp.hpl.hp.com>
In article <37dd5ccc@cs.colorado.edu> on 13 Sep 1999 14:21:32 -0700, Tom
Christiansen <tchrist@mox.perl.com> says...
> In comp.lang.perl.misc, abigail@delanet.com writes:
> :CGI.pm's set of methods that output
> :html tags seems to me as useful as an English.pm module with a method
> :for every word, and using that instead of writing plain text.
>
> Actually, the real usefulness is what you see in CGI::Form.
> Auto-regenerating sticky widgets that implicitly have persistent values.
Good point -- it is convenient. Of course there are some tricks to do
it yourself. For example,
<INPUT TYPE=checkbox NAME=the_name VALUE=CHECKED $the_value>
which automatically remembers checked-ness. More obvious is the simple
text-box:
<INPUT NAME=the_name VALUE="$the_value">
> :It's all
> :too much 'oh-golly-this-looks-like-I-am-doing-OOP' just for the sake of
> :looking like you're doing OOP.
>
> Yes, that's silly.
Indeed.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 13 Sep 1999 14:27:40 -0500
From: "David McKay" <davidmck@earthlink.net>
Subject: WHY???
Message-Id: <7rjq5o$oq6$1@fir.prod.itd.earthlink.net>
Can someone that knows nothing about client/server on NT4 can develope a
client/server app in C++ faster than in PERL?? 2 weeks screwing off endless
hours trying to glue this piece of junk together in ActivePERL and then the
same person sits down and has a first pass app. done in 2 hours in C++.
It has been extremely frustrating trying to put the pieces together in PERL
to get this freaking thing together. Reading piles of 'disconnected'
documentation, examples that don't work, going through mind-numbing Perl
newsgroups, and websites....argh!! This is complete insanity. PERL on
Windows sux!
Flame my rump. I need to be kicked while I'm down....
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
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 782
*************************************