[13260] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 670 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 28 20:07:21 1999

Date: Sat, 28 Aug 1999 17:05:08 -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           Sat, 28 Aug 1999     Volume: 9 Number: 670

Today's topics:
    Re: Amsterdam Perl Mongers Meeting <eric@terra.nu>
    Re: broker <cassell@mail.cor.epa.gov>
        Data Element Counting (Brian StJohn)
    Re: Data Element Counting (Abigail)
    Re: Data Element Counting <rick.delaney@home.com>
        Development for the open source community. synsthe@my-deja.com
    Re: Functions within functions in a class <rick.delaney@home.com>
    Re: Hashed sets (Eric Bohlman)
        How do you use @TIME? <mace@calweb.com>
        Install Perl on PWS <ynykon@ipm.lviv.ua>
    Re: Install Perl on PWS <cassell@mail.cor.epa.gov>
        Interpolating variables within variables? <casillo@ix.netcom.com>
    Re: Interpolating variables within variables? <tchrist@mox.perl.com>
    Re: Matching E-mail <cassell@mail.cor.epa.gov>
    Re: Matching E-mail <flavell@mail.cern.ch>
        Perl Date Question... <mace@calweb.com>
    Re: Perl Date Question... <rick.delaney@home.com>
    Re: Perl Date Question... (Larry Rosler)
    Re: Perl Date Question... (Matthew Bafford)
    Re: Perl Y2K Bugs on the Internet <cassell@mail.cor.epa.gov>
        Read File And Read WEB html? <a4565992@ethome.net.tw>
    Re: Style question: where should my declarations go? (Larry Rosler)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 28 Aug 1999 15:42:00 +0200
From: Eric Veldhuyzen <eric@terra.nu>
Subject: Re: Amsterdam Perl Mongers Meeting
Message-Id: <m3u2pkrphz.fsf@koffie.terra.nu>

Hans Paijmans writes:
> On 26 Aug 1999 19:07:04 GMT, Robert Jan <rj@NOT4MAIL.xs4all.nl>
> wrote:
>>
>> [English version follows the dutch text]
>>
>> Amsterdam.pm staat voor de "Amsterdamse Perl Mongers", een groep
>> van

> Hoe mong je eigenlijk een perl?

Met voldoende bier natuurijk!

-- 
#!perl #                       Life ain't fair, but root passwords help.
# Eric Veldhuyzen                                   http://www.terra.nu/
$!=$;=$_+(++$_);($:,$~,$/,$^,$*,$@)=$!=~                 # eric@terra.nu
/.(.)...(.)(.)....(.)..(.)..(.)/;`$^$~$/$: $^$*$@$~ $_>&$;` #Perl Monger


------------------------------

Date: Sat, 28 Aug 1999 15:43:25 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: broker
Message-Id: <37C8660D.7FF4CB53@mail.cor.epa.gov>

Webmaster wrote:
> 
> I´ve done it with PHP, and strongly recommend it for running shell commands.
> 
> Igor Vinokurov <igor@rtsnet.ru> escribió en el mensaje de noticias
> 37c52a6f.0@news.rtsnet.ru...
> > Hello.
> >
> > There is a necessity to run on remote server (unix host) some
> > administrative commands (create user, create home directory etc)
> > from script on local host.

Why would you recommend that?  You're always better off
*not* jumping out to a shell if you don't have to.
Net::Telnet is designed to run telnet sessions.

If you are going to answer questions in this newsgroup,
could you please give correct answers, in the format which
this newsgroup uses?

TIA,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: 28 Aug 1999 20:13:35 GMT
From: bsj@fc.hp.com (Brian StJohn)
Subject: Data Element Counting
Message-Id: <7q9ftf$l93$1@fcnews.fc.hp.com>

Hey everyone,

I've got a problem I have a solution to, but it's horribly
kludgey and very inefficient.  I'm trying to think of a better
way to do it, but I can't for the life of me. I've got a large
array of characters, which can be one of a given list:
i.e. here's the list of strings a particular array element can 
be:  A39, C21, C24, C34, Basement, etc, etc, etc...

I want to loop through the array and count the occurrances of
each one.  So, if I have 16 occurances of A39 and 200 occurances
of C24, I want to print that data out later.  I've combed through
the FAQs and through the perl cookbook, but haven't come up with
a more elegant solution than to sort through the entire array with
a foreach loop, and test each element for pattern matching.  Is there
a better way to do this?

Thanks,

	Brian



------------------------------

Date: 28 Aug 1999 15:49:18 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Data Element Counting
Message-Id: <slrn7sgj00.tt.abigail@alexandra.delanet.com>

Brian StJohn (bsj@fc.hp.com) wrote on MMCLXXXVIII September MCMXCIII in
<URL:news:7q9ftf$l93$1@fcnews.fc.hp.com>:
-- Hey everyone,
--
-- I've got a problem I have a solution to, but it's horribly
-- kludgey and very inefficient.  I'm trying to think of a better
-- way to do it, but I can't for the life of me. I've got a large
-- array of characters, which can be one of a given list:
-- i.e. here's the list of strings a particular array element can 
-- be:  A39, C21, C24, C34, Basement, etc, etc, etc...
--
-- I want to loop through the array and count the occurrances of
-- each one.  So, if I have 16 occurances of A39 and 200 occurances
-- of C24, I want to print that data out later.  I've combed through
-- the FAQs and through the perl cookbook, but haven't come up with
-- a more elegant solution than to sort through the entire array with
-- a foreach loop, and test each element for pattern matching.  Is there
-- a better way to do this?


    my (%count, $key, $value);
    map {$count {$_} ++} @array;
    while (($key, $value) = each %count) {
        print "I found $value of $key.\n";
    }



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Sat, 28 Aug 1999 20:53:46 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Data Element Counting
Message-Id: <37C84C4A.90351AA8@home.com>

[posted & mailed]

Brian StJohn wrote:
> 
> I want to loop through the array and count the occurrances of
> each one.  So, if I have 16 occurances of A39 and 200 occurances
> of C24, I want to print that data out later.  I've combed through
> the FAQs and through the perl cookbook, but haven't come up with
> a more elegant solution than to sort through the entire array with
> a foreach loop, and test each element for pattern matching.  Is there
> a better way to do this?

Gosh, yes, there is no need for pattern matching,  But you do have to
loop through the array if you want to count occurrences of elements in
the array.

When you want to count distinct items, use a hash.

    for my $item (@array) {
        $count{$item}++;
    }
    for my $item (sort keys %count) {
        print "$item => $count{$item}\n";
    }

-- 
Rick Delaney
rick.delaney@home.com


------------------------------

Date: Sat, 28 Aug 1999 20:42:41 GMT
From: synsthe@my-deja.com
Subject: Development for the open source community.
Message-Id: <7q9hk0$ouv$1@nnrp1.deja.com>

Well I thought I'd give this a try, and see what
comes of it. I'm to the point right now where any
slim possibility looks like a good one. =)

There are two of us working on a rather large
project for the open source and technology minded
community. We're setting up a web site, aptly
named Project Linux (http://www.projectlinux.org/)
- it's intended to be a central point for the open
source community to voice their opinions, as well
as read news, articles, and learn more about Linux
and other open source technologies.

Our plans for the site are pretty extensive, and
we have full confidence it will go far with the
proper work put into it.

The problem is that we're not backed up by, for
example, VA Linux systems. No corporation, no
company, nobody behind the scenes pulling the
strings anywhere along the line, and thus, we
don't have access to the same resources they do.

As such progress is slow as one of us works on the
perl backend systems, and the other does the front
end user interface and static information pages.
We need somebody with a good grasp of Perl, some
enthusiasm for the project, and some time they
could devote to aiding the development of the
systems as part of the Project Linux staff.

The work would be volunteer and as such no
obligations as to time constraints or the such,
however we hope to meet up and work with somebody
who would be highly interested in providing the
community with an excellent resource.

Feel free to reply in the newsgroup, or email me
directly for more information as to what we are
doing and who we are looking for. If you're not
interested, please feel free to skip this message
and accept our apologies for taking up your usenet
time. =)

PS: Yes, I'm posting via deja. I'm in the process
of installing various distributions for review
purposes, and I don't wish to install and set up
slrn under each one at the moment... ;-)

--
Mark Waterous <mark@projectlinux.org>
http://www.projectlinux.org/


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Sat, 28 Aug 1999 20:36:51 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Functions within functions in a class
Message-Id: <37C84852.94DD5B5E@home.com>

[posted & mailed]

Bryan Chan wrote:
> 
> I created two instances (let's say ABA and CDC) of the following class
> and gave each object a different $_foo value.  Then I called the bar
> function with each class, but when the CDC called gooie and printed out
> the value of $blah, it gave the value of $_foo in ABA.  Why does
> CDC::gooie use the $blah from ABA rather than the $bar from CDC?  What
> follows is the code for the class, and the code for my test program.

I ran your code under -w and got

Useless use of hash elem in void context
Useless use of hash elem in void context
Variable "$blah" will not stay shared

If you look up the last warning in perldiag, all will be revealed.

> *************************** package Blah.pm starts here**************
> package Blah;
> use strict;

You use strict but not -w?  I'd reverse the order of importance
there--but still use both.

-- 
Rick Delaney
rick.delaney@home.com


------------------------------

Date: 28 Aug 1999 22:58:04 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Hashed sets
Message-Id: <7q9phs$nrt@dfw-ixnews10.ix.netcom.com>

Steven de Rooij (srooij@wins.uva.nl) wrote:
: Eric Bohlman wrote:
: > As it turns out, this isn't a Frequently Asked Question, but that still
: > doesn't excuse you from doing your homework.  The FAQ documents that come
: > with Perl will quickly enable to tell if a particular question is likely
: > to be one that's been asked here over and over again And if so, they'll
: > give you your answer far faster than it would take to compose a question,
: > post it, and wait for the answer. 
: 
: I did "do my homework", but as far as I could tell, there was nothing
: about this in the FAQ.

Of course not, since as I said, it wasn't a Frequently Asked Question.  I 
was just responding to something you said about not flaming you for 
asking an "inappropriate" question: I was trying to clarify what sorts of 
questions are appropriate vs. inappropriate, and not just for you.

: Do I sense some frustration here?

Not frustration at you.  Frustration at others.



------------------------------

Date: Sat, 28 Aug 1999 16:13:10 -0700
From: "Mace" <mace@calweb.com>
Subject: How do you use @TIME?
Message-Id: <37c86dea@calwebnnrp>

This is the subroutine:

sub GET_TIME
 {
 @TIME = localtime(time);
 if ($TIME[4] == 0){$MONTH = "January"};
 if ($TIME[4] == 1){$MONTH = "February"};
 if ($TIME[4] == 2){$MONTH = "March"};
 if ($TIME[4] == 3){$MONTH = "April"};
 if ($TIME[4] == 4){$MONTH = "May"};
 if ($TIME[4] == 5){$MONTH = "June"};
 if ($TIME[4] == 6){$MONTH = "July"};
 if ($TIME[4] == 7){$MONTH = "August"};
 if ($TIME[4] == 8){$MONTH = "September"};
 if ($TIME[4] == 9){$MONTH = "October"};
 if ($TIME[4] == 10){$MONTH = "November"};
 if ($TIME[4] == 11){$MONTH = "December"};

 if ($TIME[6] == 0){$DAY = "SUNDAY"};
 if ($TIME[6] == 1){$DAY = "MONDAY"};
 if ($TIME[6] == 2){$DAY = "TUESDAY"};
 if ($TIME[6] == 3){$DAY = "WEDNESDAY"};
 if ($TIME[6] == 4){$DAY = "THURSDAY"};
 if ($TIME[6] == 5){$DAY = "FRIDAY"};
 if ($TIME[6] == 6){$DAY = "SATURDAY"};
 }

However, when I put:

print "$DAY\n"; nothing happened, the screen was just blank.  Thanks.




------------------------------

Date: Sat, 28 Aug 1999 23:15:42 +0300
From: Yurij Nykon <ynykon@ipm.lviv.ua>
Subject: Install Perl on PWS
Message-Id: <37C8436E.E7D75475@ipm.lviv.ua>

Hi.

I'm just starting with perl and the first problem I've encountered is,
that I can't setup my Server to understand perl Script. I've downloaded
Perl-distribution for Win32 and installed it on my HD. It works well, I
can start the demonstration program etc. But I cannot make my browsers
to understand pl-files. I have Personal Web Server installed on Win98.
All my pl scripts are in CGI-BIN directory, which have "Execute,
Scripts" permission. But when i try to load pl -file in Browser, the
Dialog "save to disc or launch external program" appears. Can someone
give me some instructions what have I to do to make it work.

Any help will be appreciated.

Yurij Nykon.

P.S. I've just found instructions for installation of PHP on Win32 and
PWS. I've repeated all steps of installation entering instaed of "php"
extention "pl" and instead of location of "php.exe" file the location of
"perl.exe" file. Now in Netscape I get the result, the perl script
produces, but in IE described problem persists. What shall I do to
install perl on my PWS correctly



------------------------------

Date: Sat, 28 Aug 1999 15:48:01 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Install Perl on PWS
Message-Id: <37C86721.89AA7F35@mail.cor.epa.gov>

Yurij Nykon wrote:
> 
> Hi.
> 
> I'm just starting with perl and the first problem I've encountered is,
> that I can't setup my Server to understand perl Script. I've downloaded
> Perl-distribution for Win32 and installed it on my HD. It works well, I
> can start the demonstration program etc. But I cannot make my browsers
> to understand pl-files. I have Personal Web Server installed on Win98.
> All my pl scripts are in CGI-BIN directory, which have "Execute,
> Scripts" permission. But when i try to load pl -file in Browser, the
> Dialog "save to disc or launch external program" appears. Can someone
> give me some instructions what have I to do to make it work.

Yes.  You can find full instructions for this in the documentation
which came to your hard drive when you installed ActiveState Perl.
Go to the Start Menu at the bottom of your screen and open the
Perl Online Documentation.  Look in the ActivePerl FAQ at the 
section on "webserver config".  There you'll find directions for
PWS, among others.

> Any help will be appreciated.
> 
> Yurij Nykon.
> 
> P.S. I've just found instructions for installation of PHP on Win32 and
> PWS. I've repeated all steps of installation entering instaed of "php"
> extention "pl" and instead of location of "php.exe" file the location of
> "perl.exe" file. Now in Netscape I get the result, the perl script
> produces, but in IE described problem persists. What shall I do to
> install perl on my PWS correctly

If it works for one browser but not another, then doesn't
that suggest that it might be a *browser* problem and not
a Perl or CGI problem?  If following the directions in the
aforementioned documentation does not solve your problem,
but leaves you in the same state [works in Nyetscape, not
in Internet Exploder], then you may need to ask this question
in a browser-specific newsgroup.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Sat, 28 Aug 1999 18:41:08 -0400
From: Gregg Casillo <casillo@ix.netcom.com>
Subject: Interpolating variables within variables?
Message-Id: <37C86584.52F8A6EA@ix.netcom.com>

I want to print the contents of a file that contains scalar variable
names. The file contains three lines:

$stop
$hurry
$go

The script:

#!/usr/bin/perl -w

$stop = "red\n";
$hurry = "yellow\n";
$go = "green\n";

open (FILE, "<stuff");
@lines = <FILE>;
close (FILE);

print @lines;
__END__

This does not work and prints:
$stop
$hurry
$go

instead of:
red
yellow
green

How can I interpolate the variables inside the @lines array?

Thanks,
Gregg Casillo
casillo@ix.netcom.com


------------------------------

Date: 28 Aug 1999 16:52:59 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Interpolating variables within variables?
Message-Id: <37c8684b@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, Gregg Casillo <casillo@ix.netcom.com> writes:
:I want to print the contents of a file that contains scalar variable
:names. The file contains three lines:
:
:$stop
:$hurry
:$go

Change your file to include calls to the print function, then
execute it with do $file.

Or read the FAQs:

    How can I expand variables in text strings?
    How can I use a variable as a variable name?

The answer is that you don't want to do this.
Why don't C programmers ever ask this question?
Sigh.

--tom
-- 
	I can't change the way people talk, 
	but I can damn well complain about it.
		--David Casseres in <28542@goofy.Apple.COM>


------------------------------

Date: Sat, 28 Aug 1999 15:40:12 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Matching E-mail
Message-Id: <37C8654C.D493FB18@mail.cor.epa.gov>

Webmaster wrote:
> 
> if ($form{'email'} =~ /.+\@.+/)
> {
>             ALL RIGHT!
> }

Excuse me, but that may be the *worst* e-mail address detector
ever to appear in this newsgroup.  It matches anything containing
a '@' with characters on either side.  It matches this line:

"   a list of illegal characters includes: @ & ! ^ < >"

It matches the blanks on either side of a legal address too.

And of course it matches almost every fake address I've ever 
seen anyone type into a "From:" line.

Since this is discussed properly in the Perl FAQ, I would 
suggest that you refer people there instead.  That is what 
the FAQ is for.

Also, this newsgroup adheres strictly to the Usenet standard
on posting.  So please place your text *after* the parts you
reply to, and trim unnecessary text in the attributed part.

Thank you,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Sun, 29 Aug 1999 01:25:03 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Matching E-mail
Message-Id: <Pine.HPP.3.95a.990829012003.7387B-100000@hpplus03.cern.ch>

On Sat, 28 Aug 1999, David Cassell wrote:

(after rebuking a clueless answer to an FAQ):

>  So please place your text *after* the parts you
> reply to, and trim unnecessary text in the attributed part.

What - and take away the clear alert that tells even the vaguely
clueful that the answer was bogus?

I'm coming more and more to the conclusion that we should stop trying to
discipline Jeopardy-style posters, for fear that they might learn how to
post convincingly before they learn how to give proper answers.

Comments?  :-}



------------------------------

Date: Sat, 28 Aug 1999 13:40:48 -0700
From: "Mace" <mace@calweb.com>
Subject: Perl Date Question...
Message-Id: <37c84a30@calwebnnrp>

I am having great difficulty getting a script to print the line:

Today is Saturday, August 28

Saturday is the day, august the month, etc...  How do I do this?

I have seen a script use something like this:

  if ($TIME[6] == 0){$DAY = "SUNDAY"};
  if ($TIME[6] == 1){$DAY = "MONDAY"};
  if ($TIME[6] == 2){$DAY = "TUESDAY"};
  if ($TIME[6] == 3){$DAY = "WEDNESDAY"};
  if ($TIME[6] == 4){$DAY = "THURSDAY"};
  if ($TIME[6] == 5){$DAY = "FRIDAY"};
  if ($TIME[6] == 6){$DAY = "SATURDAY"};

but I don't know how he got it...

thanks,

Mace




------------------------------

Date: Sat, 28 Aug 1999 20:59:44 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Perl Date Question...
Message-Id: <37C84DB1.96F9EED8@home.com>

[posted & mailed]

Mace wrote:
> 
> I have seen a script use something like this:
> 
>   if ($TIME[6] == 0){$DAY = "SUNDAY"};
>   if ($TIME[6] == 1){$DAY = "MONDAY"};
>   if ($TIME[6] == 2){$DAY = "TUESDAY"};
>   if ($TIME[6] == 3){$DAY = "WEDNESDAY"};
>   if ($TIME[6] == 4){$DAY = "THURSDAY"};
>   if ($TIME[6] == 5){$DAY = "FRIDAY"};
>   if ($TIME[6] == 6){$DAY = "SATURDAY"};
> 
> but I don't know how he got it...

Got what?  @TIME?

perldoc -f localtime

-- 
Rick Delaney
rick.delaney@home.com


------------------------------

Date: Sat, 28 Aug 1999 15:01:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Date Question...
Message-Id: <MPG.1231fc2169ddf9b0989ec7@nntp.hpl.hp.com>

In article <37C84DB1.96F9EED8@home.com> on Sat, 28 Aug 1999 20:59:44 
GMT, Rick Delaney <rick.delaney@home.com> says...
> Mace wrote:
> > 
> > I have seen a script use something like this:
> > 
> >   if ($TIME[6] == 0){$DAY = "SUNDAY"};
> >   if ($TIME[6] == 1){$DAY = "MONDAY"};
> >   if ($TIME[6] == 2){$DAY = "TUESDAY"};
> >   if ($TIME[6] == 3){$DAY = "WEDNESDAY"};
> >   if ($TIME[6] == 4){$DAY = "THURSDAY"};
> >   if ($TIME[6] == 5){$DAY = "FRIDAY"};
> >   if ($TIME[6] == 6){$DAY = "SATURDAY"};
> > 
> > but I don't know how he got it...
> 
> Got what?  @TIME?
> 
> perldoc -f localtime

One can't let this code pass without at least a mention that no one who 
has had even a little programming experience would tolerate that type of 
cookie-cutter stuff.

    $DAY = (qw(SUNDAY MONDAY TUESDAY WEDNESDAY
               THURSDAY FRIDAY SATURDAY))[$TIME[6]];

And the capitals on the variables are disquieting, because capitals 
imply constants.  The whole thing looks like a big loud rant.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Sat, 28 Aug 1999 22:20:38 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Perl Date Question...
Message-Id: <slrn7sgnfk.1lo.*@dragons.duesouth.net>

On Sat, 28 Aug 1999 13:40:48 -0700, Mace" <mace@calweb.com> was
attempting to recharge the laptop battery by typing: 
: I am having great difficulty getting a script to print the line:
: 
: Today is Saturday, August 28

print "Today is Saturday, August 28\n";

:   if ($TIME[6] == 0){$DAY = "SUNDAY"};
:   if ($TIME[6] == 1){$DAY = "MONDAY"};
:   if ($TIME[6] == 2){$DAY = "TUESDAY"};
:   if ($TIME[6] == 3){$DAY = "WEDNESDAY"};
:   if ($TIME[6] == 4){$DAY = "THURSDAY"};
:   if ($TIME[6] == 5){$DAY = "FRIDAY"};
:   if ($TIME[6] == 6){$DAY = "SATURDAY"};

Ugh, how ugly.

my @time = localtime;
my @days = ('Sunday',   'Monday', 'Tuesday',  'Wednesday',
            'Thursday', 'Friday', 'Saturday',            );
my $day  = $days[ $time[6] ];

or:

my @time = localtime;
my $day;

for ( $time[6] ) {
    $day = 
    /0/ && 'Sunday'    || /1/ && 'Monday'   || /2/ && 'Tuesday' ||
    /3/ && 'Wednesday' || /4/ && 'Thursday' || /5/ && 'Friday'  ||
    /6/ && 'Saturday'  ||
           'invalid date'
}

: but I don't know how he got it...

Got what?

@TIME?

perldoc -f localtime
 
: thanks,

HTH,

: Mace

--Matthew


------------------------------

Date: Sat, 28 Aug 1999 15:27:25 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: firstsql@ix.netcom.com
Subject: Re: Perl Y2K Bugs on the Internet
Message-Id: <37C8624D.8E8A0C53@mail.cor.epa.gov>

[courtesy e-mail cc to poster]

Lee Fesperman wrote:
> 
> Jonathan Stowe wrote:
> >
> > It appears that Ms Amon has some particular animus toward Perl as a
> > programming language.  For those in newsgroups that have less experience
> > of this persistent individual might like to see for instance the thread:
> >
> >    <http://x21.deja.com/[ST_rn=ap]/viewthread.xp?AN=481002103&search=thread>
> 
> I did surf through some of that thread. It mainly confirmed my experience that things
> are a bit virulent on the Perl NGs. I don't really see the animus from Ms Amon you see.
> I found her comments fairly reasoned, even if she seemed somewhat lightweight in her
> technical knowledge. Most of the attacks came from the Perl-heads, like:
> 
> "Now, go away, kid, and learn something before you embarrass yourself again.  Lately you
> can't even open your mouth but to change feet."

Then you didn't bother to go back and check the dozens of times 
Jocelyn has pestered this newsgroup, with far-less-well
researched material, in the past.  That is the primary 
cause of the general ire in this newsgroup toward said
poster.

That said, I think that Jonathan is wrong.  I think the
problem is that Jocelyn doesn't see the difference between
the choir to which she is preaching [this ng] and the
script-kiddies who continue to use bad code on their websites 
without understanding it.  Without even wanting to
understand it.  Everyone in c.l.p.misc agrees that there
are lots of Y2K problems in CGI scripts all over the web,
and a lot of people here blame specific cargo-cult-code
favorites, such as Matt's Script Archive.

> In reality, this date 'feature' is a weakness in Perl (and C, Javascript, ...) - a poor
> design. Because of cross-posting, I'm viewing this from the Java NG. Java has this
> deficiency but has recognized it, replaced it with a correct implementation and
> deprecated the problematic stuff.

But Perl has a totally different culture than Java, so I'm
not sure that's a logical analogy.  The problem here is more
that lots of people can write bad Perl code *without* learning
the language or reading the documentation.  Who attempts that
in Java or C++ ?  These are all people who refuse to read
the *basic* docs on localtime() or gmtime(), or to read the
directly-applicable FAQs, or to read all the other docs
which say *not* to do this.  And they don't use the -w
flag or any other means of catching errors in their code.
Some of them are still running Perl 4, which has been outdated
for nearly half a decade.  Who do you know who is still
programming in Borland C++ version 3.1 ?

So merely deprecating this won't stop the cargo-cultists,
and adding new language features won't fix the bad code still 
metastatizing across the internet.  Perhaps Jocelyn would
contact every person she found to be running copies of this
bad code and notify them of the Y2K issues, thus letting
them realize they have *lousy* scripts at their sites.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Sun, 29 Aug 1999 06:19:04 +0800
From: Liao Yen Feng <a4565992@ethome.net.tw>
Subject: Read File And Read WEB html?
Message-Id: <37C86058.E034981E@ethome.net.tw>

i have a perl script in A server ( 10.0.0.1,
path=\home\perltest\cgi-bin\abc.pl)
and i want to read a webhtml...on http://10.0.0.2/data.html
how to do this?...

PS. please answer me by email:omtxpg@npccu.pccu.edu.tw
thanks a lot 8/28



------------------------------

Date: Sat, 28 Aug 1999 15:20:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Style question: where should my declarations go?
Message-Id: <MPG.1232006c1d0bd055989ec8@nntp.hpl.hp.com>

In article <37c82e33$0$17161@nntp1.ba.best.com> on 28 Aug 1999 18:45:07 
GMT, John Callender <jbc@shell2.la.best.com> says...
> In declaring a my variable that needs to be declared at the outermost
> scope of a script, but which will first be modified inside a while loop
> or if block that occurs fairly far down the script, which is better: to
> put it in a big, collective my declaration up at the top of the script,
> or to declare it immediately before the loop or if block where it will
> first be used? I realize that it will work the same either way; I'm
> curious about the opinions of the old hands around here about the
> clarity/maintainability implications of the different approaches.

In C, there is no choice.  Declarations have to be at the beginning of 
the block.  The restriction was lifted in C++, but the style hangs on.  
Some think it helps to document the program (one variable per line, each 
with a descriptive comment).

As Perl allows a choice, my style is to declare the variable where it is 
used, to restrict its scope.  Declaring a 'my' variable ahead of a loop 
is slightly more efficient than declaring it within the loop, but it 
implies that the final value will be used later on.  It is better to 
declare it within the loop, so its limited scope will be clear.  It is 
also necessary if references to different data stored in the variable on 
each iteration are to be saved.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

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 670
*************************************


home help back first fref pref prev next nref lref last post