[16849] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4261 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 8 14:05:45 2000

Date: Fri, 8 Sep 2000 11:05:20 -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: <968436319-v9-i4261@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 8 Sep 2000     Volume: 9 Number: 4261

Today's topics:
        A stupid question? <idleisidle@usa.net>
    Re: A stupid question? <jpryan@labs.tamu.edu>
    Re: A stupid question? <idleisidle@usa.net>
        accessing a shared folder within Intranet <dprowak@ci.syracuse.ny.us>
    Re: ActivePerl 617 cannot be opened by Windows-Installe (Brandon Metcalf)
    Re: calling javac from perl and capturing system output <Peter.Dintelmann@dresdner-bank.com>
    Re: Changing ALL leading blanks to zero <lr@hpl.hp.com>
    Re: Date question?  Can't display English style? <lr@hpl.hp.com>
        different handling of = on unix and windows (in char cl <gyenesz@westel900.hu>
    Re: different handling of = on unix and windows (in cha <jeffp@crusoe.net>
    Re: Environment variables - how to list them all? <bd83h@bedford.waii.com>
    Re: Environment variables - how to list them all? (Abigail)
    Re: Environment variables - how to list them all? (Craig Berry)
        flush the buffer before closing the <nic.alagna@tiscalinet.it>
    Re: flush the buffer before closing the (Abigail)
    Re: how can I tell the internet speed of visitor <flavell@mail.cern.ch>
    Re: how can I tell the internet speed of visitor (Craig Berry)
    Re: how could I convert a string to a hex ASCII <Peter.Dintelmann@dresdner-bank.com>
    Re: How to delete line #1 <lr@hpl.hp.com>
    Re: How to find unused variables? <Peter.Dintelmann@dresdner-bank.com>
        Is HP finally recognizing Perl??? (David Krainess)
    Re: Last day of month <stephenk@cc.gatech.edu>
    Re: Last day of month <lr@hpl.hp.com>
    Re: Last day of month (Craig Berry)
    Re: last in a sub taking effect in caller nobull@mail.com
    Re: New Perl Tutorial - www.perltutor.com huw_watkins@my-deja.com
    Re: Newbie - windows directory location scottfreez@my-deja.com
    Re: ODBC, OLE, ADO, WTF?? <jeff@vpservices.com>
    Re: open'ing lynx doesn't work when called by cron <flavell@mail.cern.ch>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 8 Sep 2000 11:59:07 -0500
From: "Ben Ben" <idleisidle@usa.net>
Subject: A stupid question?
Message-Id: <iW8u5.1156$Aq4.18920@vixen.cso.uiuc.edu>

I am a beginner, here is the question. Any idea? Thanks in advance.

#!/usr/local/bin/perl -w
use strict;
print "Content-type:text/html\n\n";
my $I = 1;
my $J = 2;
my $K = 3;
print qq~
<html>
<head><title></title></head>
<BODY>
<table border="1" width="100%">
  <tr>
    <td width="33%">IIIIII</td>  <!-- I want show the value of $I at
IIIIII -->
    <td width="33%">JJJJJJ</td>  <!-- I want show the value of $J at
JJJJJJ -->
    <td width="34%">KKKKKK</td>  <!-- I want show the value of $K at
KKKKKK -->
  </tr>
</table>
</body></html>
~;





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

Date: Fri, 08 Sep 2000 12:05:09 -0500
From: James Philip Ryan <jpryan@labs.tamu.edu>
Subject: Re: A stupid question?
Message-Id: <39B91C45.119914A8@labs.tamu.edu>

i don't know if your question is this simple, but substitute $I for
IIIIII, $J for JJJJ, etc. etc.


-james

Ben Ben wrote:

> I am a beginner, here is the question. Any idea? Thanks in advance.
>
> #!/usr/local/bin/perl -w
> use strict;
> print "Content-type:text/html\n\n";
> my $I = 1;
> my $J = 2;
> my $K = 3;
> print qq~
> <html>
> <head><title></title></head>
> <BODY>
> <table border="1" width="100%">
>   <tr>
>     <td width="33%">IIIIII</td>  <!-- I want show the value of $I at
> IIIIII -->
>     <td width="33%">JJJJJJ</td>  <!-- I want show the value of $J at
> JJJJJJ -->
>     <td width="34%">KKKKKK</td>  <!-- I want show the value of $K at
> KKKKKK -->
>   </tr>
> </table>
> </body></html>
> ~;



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

Date: Fri, 8 Sep 2000 12:15:10 -0500
From: "Ben Ben" <idleisidle@usa.net>
Subject: Re: A stupid question?
Message-Id: <m99u5.1166$Aq4.19159@vixen.cso.uiuc.edu>

Yes, Yes, It is.
So, it _is_ a stupid question.





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

Date: Fri, 08 Sep 2000 16:26:05 GMT
From: "David Prowak" <dprowak@ci.syracuse.ny.us>
Subject: accessing a shared folder within Intranet
Message-Id: <xq8u5.5980$JY2.1551591@typhoon.nyroc.rr.com>

Hi,

I'm trying to automate a transfer of a document (.doc) from a shared folder
on someone's PC to our web server.

The IP of the PC where the document located is known.

I'd like to write a Perl program that will be run from the web server
and transfer the file from the shared folder to the web server.

How can I go about "getting" the document from the shared folder?

Are there any Perl modules that would facilitate such a program?

TIA,

Dave






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

Date: 8 Sep 2000 15:30:26 GMT
From: bmetcalf@nortelnetworks.com (Brandon Metcalf)
Subject: Re: ActivePerl 617 cannot be opened by Windows-Installer
Message-Id: <8pb0mi$6g9$1@bcrkh13.ca.nortel.com>

alexa@redneck.gacracker.org writes:

 > I wish to run Perl under Windows NT 4.0. In this NG ActivePerl was
 > recommended by several people. 
 > I downloaded the Windows Installer the windows version of Active Perl.
 > 
 > ActivePerl-5.6.0.617-MSWin32-x86-multi-thread.msi
 > 
 > My Windows Installer gives an error message when trying to open the
 > packet. I downloaded it 3 times, but still the same result.
 > 
 > Anyone out there who had the same problem? Solution?

Nope.  Downloaded and installed it yesterday.

Brandon


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

Date: Fri, 8 Sep 2000 08:55:31 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: calling javac from perl and capturing system output
Message-Id: <8pa2hj$1e3@intranews.bank.dresdner.net>

    Hi,

smehta60@my-deja.com schrieb in Nachricht
<8p8fd2$tod$1@nnrp1.deja.com>...

    [snip]

>do the following in my perl script:
>
>@myArray = `javac Test.java`;
>
>My Test.java (a hello world app) has some compile errors and I want to
>capture that output(i.e the java compile errors) in myArray

    The compile errors are written to STDERR. You
    first have to redirect this to STDOUT.
    Try

        @myArray = qx{ javac Test.java 2>&1 };

    Best regards,

        Peter Dintelmann





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

Date: Fri, 8 Sep 2000 10:53:34 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Changing ALL leading blanks to zero
Message-Id: <MPG.1422c77e26b014df98ad3f@nntp.hpl.hp.com>

In article <39B8ED08.DBD19637@am1.ericsson.se> on Fri, 08 Sep 2000 
09:43:36 -0400, William Cardwell <EUSWMCL@am1.ericsson.se> says...

 ...

> Rafael, I had not seen "%03d". I do: "%3.3d" learned from C lang.

'%03d' and '%3.3d' and '%.3d' are synonymous, and are the same in Perl 
and in C.  I much prefer '%.3d', for two unrelated reasons:

1.  Something like '%08d' or '%010d' causes me headaches, because of the 
use of leading '0' in number literals to specify octal notation.

2.  Using '%.3d' allows also the use of a leading minimum-field-width 
specifier.  But '%3.3d' is redundant, because the '.3' forces padding to 
at least three digits.

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


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

Date: Fri, 8 Sep 2000 10:58:05 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Date question?  Can't display English style?
Message-Id: <MPG.1422c88bf9cc85dd98ad40@nntp.hpl.hp.com>

In article <Pine.GSO.4.21.0009080912520.23350-100000@crusoe.crusoe.net> 
on Fri, 8 Sep 2000 09:14:48 -0400, Jeff Pinyan <jeffp@crusoe.net> 
says...
> On Sep 8, Ivan Lee said:

 ...

> >...  moreover, in both case I display the year is "100" 
> 
> YES, THE YEAR IS 100.  If you read the localtime() documentation, you'll
> know why.  (How did you know that you had to add 1 to $mon?  Guess what
> you have to add to the year...)

I was just observing the precipitous decline here in Y2K-related 
'problems'.  But here we go again!

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


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

Date: Mon, 04 Sep 2000 16:13:23 +0200
From: Zoltan Gyenes <gyenesz@westel900.hu>
Subject: different handling of = on unix and windows (in char class)
Message-Id: <p9b7rssoc31vf0ss30s60kqlh8q0duhhf2@4ax.com>

and again...

after a brief testing I found that running the line

  print "matches\n" if "</B>"=~m/<[+-=].+?>/g;

leads to DIFFERENT results depending the OS, on unix (Tru64) I get the
correct answer (nothing) because "/" is none of the [+-=] characters.
But on Windows NT 4 it prints "matches". the key character is the "=",
without it everything is fine, but including it Win32 perl somehow
matches the "/" with "=". (it's the same if you use ":", "." and some
other chars instead of "/", moreover replacing "=" with "\061" also
doesn't work)
AFAIK in character classes the metacharacters lose their "metaness",
but putting a "*" (into character class) dies on win32 (not on unix).
Anybody experienced similar problems or maybe I know something
terribly wrong?
TIA,
Zoltan Gyenes


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

Date: Fri, 8 Sep 2000 11:45:57 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: different handling of = on unix and windows (in char class)
Message-Id: <Pine.GSO.4.21.0009081141240.23350-100000@crusoe.crusoe.net>

[posted & mailed]

On Sep 4, Zoltan Gyenes said:

>after a brief testing I found that running the line
>
>  print "matches\n" if "</B>"=~m/<[+-=].+?>/g;
>
>leads to DIFFERENT results depending the OS, on unix (Tru64) I get the
>correct answer (nothing) because "/" is none of the [+-=] characters.
>But on Windows NT 4 it prints "matches". the key character is the "=",
>without it everything is fine, but including it Win32 perl somehow
>matches the "/" with "=". (it's the same if you use ":", "." and some
>other chars instead of "/", moreover replacing "=" with "\061" also
>doesn't work)
>AFAIK in character classes the metacharacters lose their "metaness",
>but putting a "*" (into character class) dies on win32 (not on unix).

Here's an excerpt from ascii(1):

     | 40  ( | 41  ) | 42  * | 43  + | 44  , | 45  - | 46  . | 47  / |
     | 48  0 | 49  1 | 50  2 | 51  3 | 52  4 | 53  5 | 54  6 | 55  7 |
     | 56  8 | 57  9 | 58  : | 59  ; | 60  < | 61  = | 62  > | 63  ? |

It shows that '+' comes before '='.  In a character class, [+-=] means all
characters from '+' to '='.  as you can see, those are the characters:

  + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < =

A - as the FIRST OR LAST character of a character class does NOT have a
special meaning, so doing [+=-] means any of the characters:

  + - =

And if you look at the ASCII list again, you'll see '*' comes before '+',
so guess why [+-*] fails. :)

As for why this behavior is different in places... I don't know exactly.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/



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

Date: Fri, 8 Sep 2000 16:53:20 +0100
From: Steve Drewell <bd83h@bedford.waii.com>
Subject: Re: Environment variables - how to list them all?
Message-Id: <1000908165239.29022J-100000@bisv3.bedford.waii.com>

On Fri, 8 Sep 2000, Christopher M. Jones wrote:

=AF "Steve Drewell" <bd83h@bedford.waii.com> wrote:
=AF > I'm new to perl and would like to know how to get a list of ALL
=AF > environment variables and their values from within a perl script.
=AF > Something equivalent to the "env" command in a c-shell is what
=AF > I'm after.
=AF=20
=AF All the environment variables are stored in the %ENV hash.
=AF (And, conversely, storing a value in the %ENV hash results
=AF in the setting of an environment variable)
=AF=20
=AF For example:
=AF=20
=AF=20
=AF foreach (sort keys %ENV)
=AF     {
=AF     print "$_ =3D $ENV{$_}\n";
=AF     }


Thank you!

Steve

Western Geophysical, Bedford, UK
Tel: +44 (0) 1234 224404
Fax: +44 (0) 1234 224517




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

Date: 08 Sep 2000 16:27:50 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Environment variables - how to list them all?
Message-Id: <slrn8ri4qb.vlt.abigail@alexandra.foad.org>

Steve Drewell (bd83h@bedford.waii.com) wrote on MMDLXV September MCMXCIII
in <URL:news:1000908144212.29022I-100000@bisv3.bedford.waii.com>:
** I'm new to perl and would like to know how to get a list of ALL
** environment variables and their values from within a perl script.
** Something equivalent to the "env" command in a c-shell is what
** I'm after.


$ perl -wle '$, = "="; $\ = $/; print @ENV while @ENV = each %ENV'



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: Fri, 08 Sep 2000 17:49:51 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Environment variables - how to list them all?
Message-Id: <sri9lvthljn121@corp.supernews.com>

Abigail (abigail@foad.org) wrote:
: Steve Drewell (bd83h@bedford.waii.com) wrote on MMDLXV September MCMXCIII
: in <URL:news:1000908144212.29022I-100000@bisv3.bedford.waii.com>:
: ** I'm new to perl and would like to know how to get a list of ALL
: ** environment variables and their values from within a perl script.
: ** Something equivalent to the "env" command in a c-shell is what
: ** I'm after.
: 
: $ perl -wle '$, = "="; $\ = $/; print @ENV while @ENV = each %ENV'

Cute, but

  $ perl -we 'print "$_=$ENV{$_}\n" for keys %ENV'

seems more direct.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: Fri, 08 Sep 2000 16:53:01 +0200
From: nik <nic.alagna@tiscalinet.it>
Subject: flush the buffer before closing the
Message-Id: <39B8FD4D.CD62842D@tiscalinet.it>

Hi,
    who can tell me how to flush the buffer in a file opened in writing
mode
before closing it ?

thanks.



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

Date: 08 Sep 2000 17:21:36 GMT
From: abigail@foad.org (Abigail)
Subject: Re: flush the buffer before closing the
Message-Id: <slrn8ri7v5.vlt.abigail@alexandra.foad.org>

nik (nic.alagna@tiscalinet.it) wrote on MMDLXV September MCMXCIII in
<URL:news:39B8FD4D.CD62842D@tiscalinet.it>:
== Hi,
==     who can tell me how to flush the buffer in a file opened in writing
== mode
== before closing it ?


     close HANDLE or die "Failed to close file: $!";


Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Fri, 8 Sep 2000 17:20:14 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: how can I tell the internet speed of visitor
Message-Id: <Pine.GHP.4.21.0009081709340.24353-100000@hpplus03.cern.ch>

On Fri, 8 Sep 2000, Philip 'Yes, that's my address' Newton wrote:

> only people who know the speed are the user and his ISP. So you'd have
> to ask one of them. How else did you think you could find out?

You're right, and this isn't a Perl question as such.

Maybe the hon Usenaut had a real operational question, to which they
thought part of the answer would be knowing the speed of the
connection.  But this is probably a mistake, except in the subset of
cases where the real bottleneck is some old-technology dial-up line to
an ISP.

As so often, it might be easier and more useful to find a solution to
their _real_ question, if we only knew what it was, rather than trying
desperately to find an answer to the one that they asked.  I'd suggest
taking a look at comp.infosystems.www.authoring.* hierarchy and see
what light they can throw on the underlying issue. 




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

Date: Fri, 08 Sep 2000 17:16:41 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: how can I tell the internet speed of visitor
Message-Id: <sri7nprsljn136@corp.supernews.com>

Denson Tang (nospam.tom@hotmail.com) wrote:
: I want to know the internet speed connection of a website visitor, how 
: can I achieve that we PERL?

Ask them.  Seriously.  Every possible method for "sniffing" bandwidth has
flaws so serious that it should not be used.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: Fri, 8 Sep 2000 08:39:27 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: how could I convert a string to a hex ASCII
Message-Id: <8pa1jd$1e2@intranews.bank.dresdner.net>


Larry Rosler schrieb in Nachricht ...
>In article <8p7g7m$1c1@intranews.bank.dresdner.net> on Thu, 7 Sep 2000
>09:30:54 +0200, Dr. Peter Dintelmann <Peter.Dintelmann@dresdner-
>bank.com> says...

    [snip]

>>
>>         print join '', unpack 'H*', 'ABC';
>>
>>     will do the job.
>
>The join() operation is unnecessary.  The print() can handle the list
>output of the unpack() handily.

    print() was just to do the output.

>  And in scalar context the join() is implicit.

    Thanks! I have not been aware of this fact ('context' ;-).

        Peter





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

Date: Fri, 8 Sep 2000 10:11:34 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How to delete line #1
Message-Id: <MPG.1422bd9d73426f6598ad3d@nntp.hpl.hp.com>

In article <_A6u5.2750$WD3.83306@news20.bellglobal.com> on Fri, 08 Sep 
2000 14:20:42 GMT, Yanick Champoux <yanick@babyl.sympatico.ca> says...

 ...

> 	$ perl -ne'log$.&&print' whatever.txt

Fancy, but unnecessarily arcane and slow, and one stroke too long at 
that.

 	$ perl -ne'$.-1&&print' whatever.txt

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


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

Date: Fri, 8 Sep 2000 09:05:40 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: How to find unused variables?
Message-Id: <8pa34j$2i1@intranews.bank.dresdner.net>

    Hi,

Thomas Åhlen schrieb in Nachricht
<_HPt5.252$pz5.129366@news.bahnhof.se>...

>I always use "use strict" and always declare my variables at the top of
the
>script code.

    [snip]

>I want to get warning when variables are declared but not used so i can
>eliminate them.
>How can i get that info?

    you want to get warnings: use the '-w' switch

        #!/usr/bin/perl -w
        use strict;
        $a = 'bla';

   When running you get a message

    Name "main::a" used only once: possible
    typo at ...

    Best regards,

        Peter Dintelmann





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

Date: Fri, 08 Sep 2000 17:18:36 GMT
From: davidkrainess@yahoo.com (David Krainess)
Subject: Is HP finally recognizing Perl???
Message-Id: <8FA96864Adavidkrainessyahooco@38.8.213.2>

I just got a course catalog and sure enough and under HP-UX operations 
there is a course H4311S, Perl Programming, 4 days, $4,000.

We have the lastest HP-UX OS 10.20 patch installed and look at this:

# /usr/contrib/bin/perl -v
 
This is perl, version 4.0
 
$RCSfile: perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
Patch level: 36
 
Copyright (c) 1989, 1990, 1991, Larry Wall
 


I guess I'm a little confused how they could teach a course if they still 
use 4.0.1.8 and haven't incorporated the new version into their software.


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

Date: Fri, 08 Sep 2000 12:32:16 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Last day of month
Message-Id: <39B91490.59A57F7D@cc.gatech.edu>

Ilya Zakharevich wrote:

>
> Eh??!!!  The number of hours in a given day of the year is decided by
> voting in appropriate political bodies (parlaments etc).  There is no
> way to guarantee *anything* about this.
>

If the day length changes, localtime() will become inaccurate and in need of an
upgrade.  Until then, localtime() has every day for the next 100 years as exactly
24 hours long, with the exception of 2 days a year (which are not at the end of
the month).

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Fri, 8 Sep 2000 10:32:55 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Last day of month
Message-Id: <MPG.1422c2a66ecc5b3898ad3e@nntp.hpl.hp.com>

In article <39B86596.7B35A11D@cc.gatech.edu> on Fri, 08 Sep 2000 
00:05:42 -0400, Stephen Kloder <stephenk@cc.gatech.edu> says...
> Logan Shaw wrote:
> 
> > >Just check if tomorrow is the first of the month:
> > >
> > >if ((localtime(time()+60*60*24))[3] == 1) {
> > >  # end of month stuff
> > >}
> >
> > If you want to be anal-retentive and consider the fact that not
> > all days are 24 hours long, then you have to do something else.
> 
> This is irrelevant, since the only 2 days in the year that are not 24 hours
> long are not at the beginning or end of the month.  Similarly, leap seconds
> are too short and too rare to pose a problem.

Leap seconds are so rare that there aren't any at all, in any of the 
standard computer epoch time scales.  Unix epoch time and astronomical 
time are now about half a minute apart, and drifting further.

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


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

Date: Fri, 08 Sep 2000 17:43:12 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Last day of month
Message-Id: <sri99g8qljn144@corp.supernews.com>

Stephen Kloder (stephenk@cc.gatech.edu) wrote:
: If the day length changes, localtime() will become inaccurate and in need of an
: upgrade.  Until then, localtime() has every day for the next 100 years as exactly
: 24 hours long, with the exception of 2 days a year (which are not at the end of
: the month).

The point is that the government in any given country could move DST to
the last day of the month at any moment, and that locale-respecting
programs would then do the same.  Never make the correctness of your code
dependent on legislators behaving rationally.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: 08 Sep 2000 17:26:12 +0100
From: nobull@mail.com
Subject: Re: last in a sub taking effect in caller
Message-Id: <u94s3q3l5n.fsf@wcl-l.bham.ac.uk>

Rajasankar <rajasankark@my-deja.com> writes:

> The following code breaks the 'while' loop in the caller.
> Though the code is erroneous, the behavior looks odd.

That's why it generates a warning.  Warnings tell you when you are
doing something that looks odd.

> Can't perl handle it in a better way?

Your quality metric may not be the same as other people's.

> Can't it just return from the function?

No, that would break in unpreditable ways existing code that uses this
documented feature of the last function.

sub my_looping_function {
  local $_;
  while (my $action = shift) { 
    while ( $_ = get_next() ) {
      $action->();
    }
  }
}

my_looping_function sub {
  next if /some pattern/; # ignore
  # dostuff
  last if /some other pattern/; # move on to next block
}, sub {
  # do more stuff
}

You could possibly promote the warning to an error under strict and
demand code that uses this trick say "no strict 'loops'".  This is,
however, a backward incompatible change and may therefore meet
resistance.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 08 Sep 2000 15:32:47 GMT
From: huw_watkins@my-deja.com
Subject: Re: New Perl Tutorial - www.perltutor.com
Message-Id: <8pb0qu$t0i$1@nnrp1.deja.com>

Thanks for your comments, Gwyn.

The point about -w and use strict is a good one. I was intending
to introduce these in later lessons, but you are right, it's best
to get into good habits from the start.

As to the errors you have detailed - I will be revisiting the
text and amending as appropriate. There is a vicious rumour
circulating that I am going to use this newsgroup to
proof-read the tutorial before publishing it as a book - but
it's not true I tell you, it's not true!

Seriously, thanks for taking the time to make some constructive
comments. My ambition for the site is to make it into a
comprehensive tutorial with intermediate and advanced topics
as well as the beginner's stuff I have started with. I also
plan to include some sort of Perl mega-quiz.

Huw Watkins
--

In article <slrn8rhudn.8ll.tjla@thislove.dyndns.org>,
  tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:
> I was shocked! How could huw_watkins@my-deja.com <huw_watkins@my-
deja.com>
> say such a terrible thing:
> >Anyone new to Perl might find the following link useful:
> >
> >http://perltutor.com
> >
> >PerlTutor.com is a free Perl tutorial, mainly aimed at
> >complete newbies, but also possibly of use to those with
> >some experience in Perl.
>
> I really think you need to use the '-w' flag for all of your scripts
as
> well as the 'use strict' pragma.  For a tutorial level site aimed at
> people who don't know perl it is essential (I think) to start them out
> on the right track, and this means using all the help that is
available.
>
> I have read the first section so far and apart from that flaw the
thing
> seems well paced. I was able to answer all the questions (although I
> doubt I am who you are aiming the thing at) and I feel they are quite
> fair. I like the way you concentrate on "good programming practice"
> (meaningful variable names and such).
>
> You have an error in the section on strings. You say the literal
> 'C:\\AUTOEXEC.BAT' is interpolated into C:\AUTOEXEC.BAT which is
clearly
> wrong. Also given that you assume no previous knowledge of
programming,
> a better introduction to what a backslash in a double quoted string
> means might be a good thing to put in, in place of the complete list
of
> backslash escapes which I doubt someone would really need to learn at
> their first try at programming.
>
> You use the phrase "Each time you use <STDIN> where a scalar value is
> expected" without really what scalar context is or what the
alternatives
> are. A simple example showing what happens when you do:
>
> $line = <STDIN>;
>
> as opposed to:
>
> @lines = <STDIN>;
>
> would help I think. You also use the chop() operator where it is
> probably better to use chomp(). In any case, the use of chop() where
you
> say is unnecessary since in the example you give the input is used as
a
> number. I know I'm probably being quite picky, but for people who are
> completely new to programming it is important I think to get the
details
> right and to pick a fairly simple subset of what you are trying to
> teach.
>
> In the section on concatenation you do a useless stringification:
>
> print 'Welcome, ' . "$name" . "\n" . 'Please select a menu option' .
> "\n";
>
> Also I think it could be instructive to compare the effect of:
>
> 'Welcome to the home page of ' . $name;
>
> to the equivalent:
>
> "Welcome to the home page of $name";
>
> This would help reinforce the stuff you have already gone over.
>
> You have the blatantly false "Expressions may occur on the right hand
> side of the '=' operator". I don't know about you but in "$x = $y * 2"
> the variable $x is a perfectly valid expression.
>
> >It features Javascript quiz questions to test progress,
> >plus exercises with sample answers.
>
> I like these things. They are fun and quick to do :)
>
> >The tutorial is incomplete as yet, but I'm adding new
> >lessons at a rate of one or two per week.
>
> I like the way you don't talk down to your readers.
>
> >There are currently twelve complete lessons:
> >Getting Started, Scalar Data, Operators, Control Structures,
> >Lists and Arrays, The $_ variable, Associative Arrays,
> >Command Line Arguments, Subroutines, Logical Operators,
> >Working with Files, File Test Operators.
>
> Way too many for me to go through them all. I hope you aren't put out
> by this, I think your tutorial is a good resource...I don't usually
> bother with this much effort unless I think it's worth it.
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> I tell ya, I was an ugly kid.  I was so ugly that my dad kept the
kid's
> picture that came with the wallet he bought.
> 		-- Rodney Dangerfield
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 16:27:51 GMT
From: scottfreez@my-deja.com
Subject: Re: Newbie - windows directory location
Message-Id: <8pb41c$qt$1@nnrp1.deja.com>

Thank you Dr. Dintelmann!

> >What's happening is that unless I give the full path from the root of
> >the web server (in this case, the root I assigned in IIS), it looks
for
> >the filename in the root rather than the current location.
>
>     [snip]
>
> >Is there a way to get the file's location into a variable, and then
> >simply append the filename onto that variable? Sure there is.
>
>     1. Use the FindBin module to find out about yourself.
>
>         use FindBin;
>         print $FindBin::Bin;    # directory your prog is in
>
>     (but I did not get it working with Apache/mod_perl).
>
>     2. Use the environment variable PATH_TRANSLATED in your CGI
>     script
>
>         use File::Basename;
>         print dirname( $ENV{PATH_TRANSLATED} );    # dir your script
is
> in
>
>     3. Create a module containing all platform specific issues
>     (path names etc.) and use it. When changing the platform you
>     only have to change one file and can be sure that everything
>     will work.
>
>     Regards,
>
>         Peter Dintelmann
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 09:05:14 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: ODBC, OLE, ADO, WTF??
Message-Id: <39B90E3A.69A2256F@vpservices.com>

Brendon Caligari wrote:
> 
> In article <8pa3pl$rce$1@nnrp1.deja.com>,
>   Brendon Caligari <bcaligari@my-deja.com> wrote:
> >
> >
> > Suppose I have some nice scripts filtering tons of data that has to be
> > eventually imported into an table in a MS-Access db.  The problem as
> > usual lies as to where to get started!!!
> >
> > Any pointing in a right direction is appreciated!!

I suggest you forget ODBC, OLE, and ADO and go straight to the WTF.pm
module.  It is always better to curse the darkness than light a candle. 
=)

Actually the answer lies in a different acronym that you didn't mention:
DBI, the Perl Database Interface.  It has drivers for ODBC and ADO and
many other databases.  See

    http://www.symbolstone.org/technology/perl/DBI/

for further details.  If you need many specific M$ things, then you
should investigate the OLE stuff but if you are doing fairly
straightforward database type things, then DBI and its friends should
give you everything you need in a portable format.

-- 
Jeff


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

Date: Fri, 8 Sep 2000 17:06:36 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: open'ing lynx doesn't work when called by cron
Message-Id: <Pine.GHP.4.21.0009081703100.24353-100000@hpplus03.cern.ch>

On Fri, 8 Sep 2000, Rich More wrote:

>   Richard Lawrence <ralawrence@my-deja.com> wrote:
> >  open(RESULT, "lynx -dump \"http://www.site.com\"|") || die "can't: $!";

> You might want to use the LWP::* modules

-dump produces a formatted rendering of the page, not just the source.

Sure, there are other ways of rendering a web page after retrieving
the source, but maybe the hon. Usenaut was simply looking for

$ENV{TERM} = 'dumb';

prior to invoking lynx as before.

cheers



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 4261
**************************************


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