[13878] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1288 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 5 00:05:49 1999

Date: Thu, 4 Nov 1999 21:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <941778310-v9-i1288@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 4 Nov 1999     Volume: 9 Number: 1288

Today's topics:
        "local %MyPackage::;" -- what does this do? (Ron Newman)
        <!--#exec cgi="/dir/any.cgi"-->(how to execute from bro (Gigabytr)
    Re: duplicates in an array (Peter J. Kernan)
    Re: File handle tests with pattern matching to promote  (Abigail)
    Re: File handle tests with pattern matching to promote  lee.lindley@bigfoot.com
    Re: File handle tests with pattern matching to promote  (Abigail)
        flock (Max)
    Re: flock <jtolley@bellatlantic.net>
    Re: how can I display command results as they occur?? <makkulka@cisco.com>
    Re: how can I display command results as they occur?? lee.lindley@bigfoot.com
    Re: how can I display command results as they occur?? lee.lindley@bigfoot.com
    Re: How can I set reg. expresion to anchor at the end o (Neko)
    Re: how to filter out a field (Tad McClellan)
    Re: HTML::Mason on NT <randy@theory.uwinnipeg.ca>
    Re: Inplace editing and safety lee.lindley@bigfoot.com
    Re: localtime object y2k compliant? (Abigail)
    Re: localtime object y2k compliant? <lr@hpl.hp.com>
    Re: localtime object y2k compliant? <moseley@best.com>
    Re: localtime object y2k compliant? <bivey@teamdev.com>
    Re: newbie filehandle question <jeffp@crusoe.net>
    Re: password question (Kragen Sitaker)
    Re: Perl and commonsense part 2 (Greg Andrews)
    Re: perl and commonsense lee.lindley@bigfoot.com
    Re: PERL in Windows CE? <jtolley@bellatlantic.net>
    Re: Perl modules to build Explorer-like HTML GUI?? <randy@theory.uwinnipeg.ca>
    Re: Perl script to convert a date to unix time? <tdk@cris.com>
    Re: Perl script to convert a date to unix time? <lr@hpl.hp.com>
    Re: problems reading text file (Abigail)
        reverse on range operator <johnlin@chttl.com.tw>
    Re: Sort order in Perl <sumengen@iplab.ece.ucsb.edu>
    Re: Yet another Perl Sockets question... <akira####@mediaone.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 04 Nov 1999 22:53:07 -0500
From: rnewman@thecia.net (Ron Newman)
Subject: "local %MyPackage::;" -- what does this do?
Message-Id: <rnewman-0411992253070001@63.209.225.11>

I tried to use the declaration

   local %MyPackage::;

to localize all variables from a package.  It doesn't seem to work.
Is this statement either legal or useful, and if so, what is it
supposed to do?

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

#!/usr/bin/perl
package MyPackage;

sub foo {
    local %MyPackage::;  # should undef all MyPackage variables
    print "initial local color is: $color\n";
    $color = "red";
    print "now local color is: $color\n";
    # returning from here should restore MyPackage variables to old values
}

$color = "blue";
foo();
print "final color is: $color\n";

---------------
The output I expect is:

  initial local color is:
  now local color is: red
  final color is: blue

but what I get is:

  initial local color is: blue
  now local color is: red
  final color is: red

-- 
Ron Newman        rnewman@thecia.net
http://www2.thecia.net/users/rnewman/


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

Date: 05 Nov 1999 03:50:27 GMT
From: gigabytr@aol.com (Gigabytr)
Subject: <!--#exec cgi="/dir/any.cgi"-->(how to execute from browser created by cgi)
Message-Id: <19991104225027.24297.00001929@ng-fb1.aol.com>

I have a cgi program that loads a header.html and a footer.html files and the
middle content is dynamically created by cgi. I have placed the <!--#exec
cgi="/dir/any.cgi"--> in the header.html file but the browser won't exec the
cgi due to the cgi printing the file to the browser.
# Print the HTML header
sub print_header {
print "Content-type: text/html\n\n";

open (HEADER,"$basepath$delim$header") || print "Could not open
$basepath$delim$header $! \n";
while (<HEADER>) {
print $_;
	}
close(HEADER);	
}
## END print_header;

Please help! Very stuck!
I would appreciate any help with getting the "exec" command to work.

Thanks,
gigabytr@aol.com


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

Date: 5 Nov 1999 04:31:34 GMT
From: pete@theory2.phys.cwru.edu (Peter J. Kernan)
Subject: Re: duplicates in an array
Message-Id: <slrn824nd5.k5i.pete@theory2.phys.cwru.edu>

On 4 Nov 1999 06:47:59 -0600, Abigail <abigail@delanet.com> wrote:
 .=
 .=    #!/opt/perl/bin/perl -w
 .=
 .=    use strict;
 .=
 .=    my @i = map {($_) x (2 + rand 2)} 'a' .. 'z';
 .=
 .=    foreach my $j (reverse 1 .. $#i) {
 .=        my $t = int rand (1 + $j);
 .=        @i [$t, $j] = @i [$j, $t]; } {
 .=        my @s = sort @i;
 .=        my $q;
 .=        my $i;
 .=        for ($i = 1; $i <= $#s; $i ++) {
 .=            if ($s [$i] eq $s [$i - 1]) {$q = $s [$i]} }
 .=            last unless defined $q;
 .=            my $z = 0;
 .=            my @r = ();
 .=            for ($i = 0; $i <= $#i; $i ++) {
 .=            push @r => $i [$i] if $i [$i] ne $q || $z ++;
 .=        }
 .=        @i = @r;
 .=        redo;
 .=    }

a very instructive algorithm, i had never realized one could write
an infinite loop as {redo}

the beauty of it led me to find an order preserving solution.
(after preparing @i one could-- you wont find this in the FAQ either)

my %i;
@i = grep {exists $i{$_} and (delete $i{$_}, 1)} 
     map  {(keys%i or @i{@i}=1)&&$_} @i;

if only the indentation style could be as elegant as the former!
-- 
  Pete


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

Date: 4 Nov 1999 21:16:08 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: File handle tests with pattern matching to promote early termination of a file read
Message-Id: <slrn824j6o.dk.abigail@alexandra.delanet.com>

lee.lindley@bigfoot.com (lee.lindley@bigfoot.com) wrote on MMCCLVI
September MCMXCIII in <URL:news:7vt13g$qdq$1@rguxd.viasystems.com>:
** 
** while() does not test for undef, it just checks for truth.

Outdated perls, yes. Modern perls, no:

[   949] By: TimBunce                              on 1998/05/14  15:11:30
        Log:
             Title:  "while($x=<>) no longer warns (implicit defined added)"
             From:  Nick Ing-Simmons <nik@tiuk.ti.com>
             Msg-ID:  <199805051035.LAA27365@pluto.tiuk.ti.com>
             Files:  MANIFEST op.c t/op/defins.t
     Branch: maint-5.004/perl
           + t/op/defins.t
           ! MANIFEST op.c

[   900] By: nick                                  on 1998/04/25  13:58:17
        Log: Auto-insert defined() test in while when test expression is
             readline (i.e. <>), glob, readdir, or each.
     Branch: ansiperl
           + t/op/defins.t
           ! op.c pod/perlop.pod

  Title:  "Use 'while (defined($x = <>)) {}', per <gnat@frii.com>"
   From:  Chip Salzenberg
  Files:  configpm lib/Term/Cap.pm perlsh pod/perlipc.pod pod/perlop.pod
          pod/perlsub.pod pod/perlsyn.pod pod/perltrap.pod
          pod/perlvar.pod win32/bin/search.bat



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";`$@`'


  -----------== 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: 5 Nov 1999 04:01:49 GMT
From: lee.lindley@bigfoot.com
Subject: Re: File handle tests with pattern matching to promote early termination of a file read
Message-Id: <7vtkrd$50v$1@rguxd.viasystems.com>

Abigail <abigail@delanet.com> wrote:
:>lee.lindley@bigfoot.com (lee.lindley@bigfoot.com) wrote on MMCCLVI
:>September MCMXCIII in <URL:news:7vt13g$qdq$1@rguxd.viasystems.com>:
:>** 
:>** while() does not test for undef, it just checks for truth.

:>Outdated perls, yes. Modern perls, no:

Thanks for the update and for the lesson.  I thought about this
possibility during my research for my post.  The documentation has
not caught up with the code yet.  Next time I will make an attempt to
search the p5p archives as well.

Nevertheless, I stand by my assertion that this particular rare case
is one of those things that has wasted far more time by all of the
people involved than it could possibly merit if you look at it
objectively.  I will call anybody liar who says that they have
actually been *burned* by this bug on

while (<>)

The possibility of it occuring has assumed the proportions of an
urban legend.

I am now laughed out on this and promise not to mention it again.
It really detracts from the legitimate distinction on the difference
between definedness and truth.

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: 4 Nov 1999 22:56:33 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: File handle tests with pattern matching to promote early termination of a file read
Message-Id: <slrn824p32.dk.abigail@alexandra.delanet.com>

lee.lindley@bigfoot.com (lee.lindley@bigfoot.com) wrote on MMCCLVII
September MCMXCIII in <URL:news:7vtkrd$50v$1@rguxd.viasystems.com>:
__ Abigail <abigail@delanet.com> wrote:
__ :>lee.lindley@bigfoot.com (lee.lindley@bigfoot.com) wrote on MMCCLVI
__ :>September MCMXCIII in <URL:news:7vt13g$qdq$1@rguxd.viasystems.com>:
__ :>** 
__ :>** while() does not test for undef, it just checks for truth.
__ 
__ :>Outdated perls, yes. Modern perls, no:
__ 
__ Thanks for the update and for the lesson.  I thought about this
__ possibility during my research for my post.  The documentation has
__ not caught up with the code yet.  Next time I will make an attempt to
__ search the p5p archives as well.


From perlop:

        Anyway, the following lines are equivalent to each other:

           while (defined($_ = <STDIN>)) { print; }
           while ($_ = <STDIN>) { print; }
           while (<STDIN>) { print; }
           for (;<STDIN>;) { print; }
           print while defined($_ = <STDIN>);
           print while ($_ = <STDIN>);
           print while <STDIN>;

       and this also behaves similarly, but avoids the use of $_:

           while (my $line = <STDIN>) { print $line }


__ 
__ Nevertheless, I stand by my assertion that this particular rare case
__ is one of those things that has wasted far more time by all of the
__ people involved than it could possibly merit if you look at it
__ objectively.  I will call anybody liar who says that they have
__ actually been *burned* by this bug on
__ 
__ while (<>)
__ 
__ The possibility of it occuring has assumed the proportions of an
__ urban legend.


It has been pointed out recently that in MacOS, there is *no* trailing
newline af the last line, and that while perl (or the C library) adds the
newline for you - that would not happen if you parse a MacOS generated
file on Unix.



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


  -----------== 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: Fri, 05 Nov 1999 02:33:45 GMT
From: nihilist@kenobiz.com (Max)
Subject: flock
Message-Id: <382241e5.67722414@news.acronet.net>

if i flock(YESFILE, 2)  what happens when another file requests that
same file? does it just die, or does it get placed in a queue?


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

Date: Fri, 05 Nov 1999 03:08:42 GMT
From: James Tolley <jtolley@bellatlantic.net>
Subject: Re: flock
Message-Id: <382249B4.ADED6BC2@bellatlantic.net>

What happened when you tried it?

Max wrote:

> if i flock(YESFILE, 2)  what happens when another file requests that
> same file? does it just die, or does it get placed in a queue?



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

Date: Thu, 04 Nov 1999 18:20:01 -0800
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: how can I display command results as they occur??
Message-Id: <38223ED1.559E335B@cisco.com>

Bill Darbie wrote:

> I have the following line of perl code:
>
> $out = `make 2>&1`;
> print $out;
>
> This does a build of code for me and then prints the output.
> The problem is that the build can take over an hour and I
> want to see the results as they are happening.  Right now
> I see nothing for over an hour and then all the output comes
> out at the end.  How can I execute my make and see the
> results unbuffered?

$|++;
# notice the Pipe in the second arg of open ()
open ( OUT, 'make 2>&1 | ' ) or die "cannot start make \n " ;
while ( <OUT>)
{
    print $_;
}



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

Date: 5 Nov 1999 02:44:43 GMT
From: lee.lindley@bigfoot.com
Subject: Re: how can I display command results as they occur??
Message-Id: <7vtgar$2fr$1@rguxd.viasystems.com>

Bill Darbie <noSpam@noSpam.com> wrote:
:>I have the following line of perl code:

:>$out = `make 2>&1`;
:>print $out;

:>This does a build of code for me and then prints the output.
:>The problem is that the build can take over an hour and I
:>want to see the results as they are happening.  Right now
:>I see nothing for over an hour and then all the output comes
:>out at the end.  How can I execute my make and see the
:>results unbuffered?
----------^^^^^^^^^^

You already have a clue about the answer, so all that is lacking
is how to turn that clue into a proper search of the documentation.

`perldoc -q buffer`
will give you a good idea of what is happening and why.
There are many ways to change the situation, but I don't
recall off-hand whether any of them will let you continue
to use the qx operator.  However, given the information in
the FAQ, you should be able to figure out how to make
a Perl program that does what you want.  Give it a shot.
If you still can't make it write the make output unbuffered,
come back with what you tried.


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: 5 Nov 1999 03:31:40 GMT
From: lee.lindley@bigfoot.com
Subject: Re: how can I display command results as they occur??
Message-Id: <7vtj2s$3lh$1@rguxd.viasystems.com>

Makarand Kulkarni <makkulka@cisco.com> wrote:
:>$|++;
:># notice the Pipe in the second arg of open ()
:>open ( OUT, 'make 2>&1 | ' ) or die "cannot start make \n " ;
:>while ( <OUT>)
:>{
:>    print $_;
:>}

Makarand, 
There is a second reason for teaching a man to fish rather than
giving him one.  That reason is that if you decide you are going to
give him fish to feed his family, then you become responsible for
making sure that it is still fresh and that there is enough there to
feed them all.  If you simply set out to teach him to fish you can
dole out small pieces of advice as time permits, and then depend on
the man to check on the nets and to work hard to search out all of
the holes in the nets and to make sure that they are set to the best
of his ability.  He is the one who is fishing, so he is the
one who is ultimately responsible.  It is a dirty little secret
of teachers everywhere, the lazy bastards  :-)

We would typically include some additional diagnostic information in
the "die" message upon open failure (" ... failed: $!"), but of
course it probably wouldn't be useful here.  What could be useful is
checking the status of close(OUT);

Also, I am not absolutely certain that "make" wouldn't buffer its own
output in this case, rendering the line buffering done in Perl
irrelevant.  You can easily test that by piping the output of make
through the "tee" or "pg" or "more" or "less"  commands.  Discovering
how to make "make" think that it is writing to a terminal so that it
won't buffer its output is my fishing lesson (partly because I am a
lazy bastard and don't remember how to do it off of the top
of my head :-)

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Thu, 04 Nov 1999 19:24:11 -0800
From: tgy@chocobo.org (Neko)
Subject: Re: How can I set reg. expresion to anchor at the end of a string?
Message-Id: <NUoiOPd+0QPCGlzPsjQq3++tcwc+@4ax.com>

On Wed, 03 Nov 1999 19:10:09 GMT, cberry@cinenet.net (Craig Berry) wrote:

>#!/usr/bin/perl -w
># right4 - split string into groups of 4 chars, extras at left end.
># Craig Berry (19991103)
>
>use strict;
>
>my $str    = '12123412341234';
>my @pieces = $str =~ /(.{1,4})(?=(?:.{4})*$)/g;

Perhaps this is a bug in my version of Perl (This is perl, version 5.005_02
built for MSWin32-x86-object), but I changed the quantifier above to just
four dots...

    my @pieces = $str =~ /(.{1,4})(?=(?:....)*$)/g;

>print join(':', @pieces), "\n";

 ...and got different results:

1212:3412:3412:34  # .{4}
12:1234:1234:1234  # ....

I get the expected the latter result for both with an earlier Perl (This is
perl, version 5.004_04 built for i586-linux).  How is it with newer Perls?

-- 
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


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

Date: Thu, 4 Nov 1999 17:35:35 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how to filter out a field
Message-Id: <nn1tv7.gdf.ln@magna.metronet.com>

gande@informix.com wrote:
: Hi Gurus,

: I have a line like 
: $arg= -r-s---- 1 1343 GROUP 0 sept 97 /local/work/dir1/.dir2/file.

: Now my question is how to filter  out only the path name?


   _That's_ your question.

   I would have thought your question was how to clean up
   all of the syntax error messages that that line generates.

   You should post Perl code, not pseudo-Perl code.


:  i.e.,/local/work/dir1


   That is _not_ the path name.

   /local/work/dir1/.dir2/file is the pathname.

   So now I don't know what it is that you want.

   Please try asking again, giving a little more care to making
   your question more clear.


: I thought of using split function. But is there any better solution to
: get this path name??


   It depends on whether the "thing to split on" is consistent or not.

   But you haven't told us what you plan to split on (spaces? slashes?),
   nor how consistent the data format is.


   You leave us in a position of having to guess about several things
   that Make A Difference. If we guess wrong on any one of them, then
   the answer given won't work.

   But since you haven't spec'ed it very thouroughly, maybe you
   only need some sort of "push" rather than a directly usable
   answer.

   Here's my guesses:

--------------
#!/usr/bin/perl -w
use strict;

my $arg= '-r-s---- 1 1343 GROUP 0 sept 97 /local/work/dir1/.dir2/file';

my $path = (split ' ', $arg)[7];

print "$path\n";
--------------



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 4 Nov 1999 21:01:02 -0600
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: HTML::Mason on NT
Message-Id: <7vth76$bf$1@canopus.cc.umanitoba.ca>


Joshua Daniel Edelstein <joshua@groundwaves.com>
    wrote in message news:38219EDD.6694A8C5@groundwaves.com...

> Does anybody know how to compile HTML::Mason on a Windows NT web server
> running Apache?  The folks at http://masonhq.com say that they know it's
> been done, but they have no idea how.  I know that I need a unified
> perl+Apache+mod_perl installation batch, but where do I go from there?

Hi,
   Strictly speaking you don't need mod_perl to use HTML::Mason,
but it is recommended. Installation proceeds exactly as for
unix systems - perl Makefile.PL; nmake; nmake test; nmake install.
I've used it successfully on my Windows 98 system (with mod_perl),
and it was relatively straightforward.

best regards,
Randy Kobes






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

Date: 5 Nov 1999 01:50:00 GMT
From: lee.lindley@bigfoot.com
Subject: Re: Inplace editing and safety
Message-Id: <7vtd48$p8$1@rguxd.viasystems.com>

Uri Guttman <uri@sysarch.com> wrote:
:>>>>>> "DC" == David Cassell <cassell@mail.cor.epa.gov> writes:

:>  DC> Uri Guttman wrote: [snip of good advice]

:>  >> something like (untested):

:>  >> BEGIN{ $SIG{ INT } = sub { $sig_int++ } ;

:>  DC> Hmmm.  Missing a closing curly?

:>covered by the untested pragma as is shown above.
:> 
:>  >> close( ARGVOUT ) && exit if $sig_int && eof) ;

:>  DC> Double hmmm.  eof or eof() are legal, but what's this eof) thing?
:> 
:>ditto.

Nobody is above the fray in c.l.p.misc.  If you post code
that doesn't work, no amount of waffling can save you.

Come on uri, take your whuppin' like a man and stop trying
to hide behind some lawyer-like weasle words like "untested".

We will accept a short acknowldgement like

mea culpa
# or
Ouch.  Sorry about that.
# or
Good catch on that.  I'll be more careful next time.

Lest you be tempted to reply with some less polite
2 word answers, I've been making a club.  :-)

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: 4 Nov 1999 20:11:29 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: localtime object y2k compliant?
Message-Id: <slrn824fdh.dk.abigail@alexandra.delanet.com>

David Cassell (cassell@mail.cor.epa.gov) wrote on MMCCLVI September
MCMXCIII in <URL:news:38221D17.3C3A409F@mail.cor.epa.gov>:
$$ 
$$ Actually, her article listing some 300 non-compliant webpages
$$ may be of interest to some members of this newsgroup.


Hmm, yeah, perhaps. I'm not really impressed by seeing the same error
appear multiple times, because of slight variations in the URL.

Does one really have to list

    http://cgi.dol.ru:$port/readme/textclock.html

for 4 different values of $port?

This is nice too:

   Y2K COUNTDOWN PROGRAM. Therefore the programmer must have been year
   2000 aware and no excuses then for hardcoding 19! 

I don't know about the planet Jocelyn lives on, but all the time I'm
counting down to the year 2000, the current year starts with 19....


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: Thu, 4 Nov 1999 18:12:24 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: localtime object y2k compliant?
Message-Id: <MPG.128bdce53a91280098a1b1@nntp.hpl.hp.com>

In article <MPG.128bd6362642869c98a1af@nntp.hpl.hp.com> on Thu, 4 Nov 
1999 17:43:54 -0800, Larry Rosler <lr@hpl.hp.com> says...
> In article <7vspea$9su$1@nnrp1.deja.com> on Thu, 04 Nov 1999 20:14:06 
> GMT, Jocelyn Amon <finsol@ts.co.nz> says...
> 
> I wonder what your career plans are for 2000 and after.
> 
> What did Jeremiah do after the Babylonian Exile?
> 
> What did Cassandra do after the fall of Troy?
> 
> And those people were right!  What will you do?

I have a suggestion, actually.  The world needs to be made aware of the 
Y2038 Bug, the sooner the better.  You're the one to do it!

I expect to miss the FUD around that one.  What a pity.  It will be so 
much fun.

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


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

Date: Thu, 4 Nov 1999 18:28:06 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: localtime object y2k compliant?
Message-Id: <MPG.128be092acf9c663989847@nntp1.ba.best.com>

Jocelyn Amon (finsol@ts.co.nz) seems to say...
> When will you 'experts' and know-it-alls get it. No amount of
> patronising put-downs, abuse or be-littling of others is going to change
> a thing.  Programmers use logic.

No, programs use logic.  Programmers use the manual.

I'm not worried about a flood of Y2K question.  But I am worried about a 
flood of Y2K responses!


-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: 4 Nov 1999 22:32:50 GMT
From: "William" <bivey@teamdev.com>
Subject: Re: localtime object y2k compliant?
Message-Id: <01bf2714$c32e8be0$3527e1ce@bill.jump.net>

Jocelyn Amon <finsol@ts.co.nz> wrote in article
<7vspea$9su$1@nnrp1.deja.com>...
> In article <3821AF26.C3A77C16@mail.uca.edu>,

> When will you 'experts' and know-it-alls get it. No amount of
> patronising put-downs, abuse or be-littling of others is going to change
> a thing.  Programmers use logic.  This programmer has applied logic to
> the situation and he, logically, assumes that adding 1900 to the year
> value will not give him the correct 4 digit year value after 1999. Seems
> very logical to me!  So maybe he should have run a test to see.  But
> that is a failing of many programmers - don't run tests, jump to
> conclusions or let users find the bugs.

There's nothing logical about it, or, I should say, it's only
logical if you go out of your way to make silly assumptions.
(They are silly because in two or three sentences, the
documentation for localtime tells you EXACTLY what to do - no
room for interpretation. It tells you, by example even, that the
value returned is valid beyond 1999.)

The only question is, since the return values for localtime
are not self evident, the programmer in question must have at
least glanced at the documentation to use it at all, so how
could he miss this bit? How clever do you have to be to read
a simple paragraph or two? (Methinks being Y2K compliant is
the least problem in this case.)-Wm




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

Date: Thu, 4 Nov 1999 22:35:43 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: newbie filehandle question
Message-Id: <Pine.GSO.4.10.9911042234010.4538-100000@crusoe.crusoe.net>

On Nov 4, Larry Rosler blah blah blah:

> > that "line" (a line is considered to be the least number of characters up
> > to and including the $/ character (defaulting to "\n") from the current
> > position).
>                           ^^^^^^^^^
>                           string

Right, I apologize for that fallacy.  I wasn't pasting from any docs, so I
made that error myself -- I have used multi-character values for $/.  Go
figure.

The other error in my post was that I included the character at the
position returned by tell() in the <FILE> return value.

  This is the last straw!
       ^
      "is the last straw!\n"

SHOULD HAVE BEEN

  This is the last straw!
       ^
       "s the last straw!\n"

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI
  jeff pinyan      japhy@pobox.com
  perl stuff       japhy+perl@pobox.com
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/



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

Date: Fri, 05 Nov 1999 04:42:53 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: password question
Message-Id: <hftU3.30145$23.1573308@typ11.nn.bcandid.com>

In article <7vt8kj$ld1$1@nnrp1.deja.com>,  <ardit@my-deja.com> wrote:
>I have a perl script that gets news from the internet, one of the
>websites I'm trying to access is password protected, the problem is
>that I don't know how to put the password and the username in my perl
>script in order to retrieve news from that site, I get news with out a
>problem from other sites that are not protected by a password. Is there
>any code I should use in the script?

If you're doing the HTTP stuff yourself, read RFC 2616.  If you're
using an HTTP module like the ones from LWP, read its docs and look for
information about Basic authentication.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 4 Nov 1999 19:39:17 -0800
From: gerg@shell.ncal.verio.com (Greg Andrews)
Subject: Re: Perl and commonsense part 2
Message-Id: <7vtjh5$f37$1@shell1.ncal.verio.com>

ajmayo@my-deja.com writes:
>Further to my previous post. My colleague asked me how you would
>combine two hashes to create a single hash.
>
>Well, this is simple with two arrays. Just use push..
>
>$a[0]=1;
>$a[1]=2;
>@b=@a;
>$b[0]=3;
>$b[1]=4;
>push @a,@b;
>print $a[2],"\n";
>
>So, let's use commonsense. To do the same with two hashes, you'd do
>this, right?
>
>$a{'1'}=1;
>$a{'2'}=2;
>%b=%a;
>$b{'3'}=3;
>$b{'4'}=4;
>push %a,%b;
>print $a{'4'},"\n";
>
>Don't be silly. This doesn't work. Hashes are not arrays.
>

Exactly.

Based on my observation of your other post and this one, you're
looking these questions from an operation-centric viewpoint,
rather than a data-centric viewpoint, and you're not noticing
that the other viewpoint exists.

In other words, you're taking an operation, like push.
You plug arrays into it, and it works.  You plug hashes
into it, and it fails.  You're taking an operation and
trying to plug different data types into it.  That's what
I called the operation-centric viewpoint.  The operation
stays the same and you vary the data plugged into it.

In the data-centric viewpoint, you'll take one type of data,
like an array.  You apply different operations to it.  Some
will work properly on that data type, while others won't.
You take a different data type, like a hash.  Again, some
operations will work properly on it, and others won't.
The operations that work on an array are not the same as
the ones that work on a hash.


Why not?  You said it:  hashes and arrays are different data types


From the operation-centric point of view, operations should work
on all types of data.

From the data-centric point of view, some operations make sense
with one type of data, and other operations don't make sense.
For the different types of data, different operations make sense.


I suggest that Perl was written using the data-centric point of
view.  You use the operations that make sense for the data type
you're manipulating, and don't use the operations that don't make
sense for that data type.

You approached Perl from a operation-centric point of view, and
discovered that Perl doesn't work that way.


You said the operation-centric point of view was "common sense".
Perhaps it is in another language.  It isn't in Perl.  In Perl,
the data-centric viewpoint is "common sense".



  -Greg
-- 
:::::::::::::::::::  Greg Andrews  gerg@wco.com  :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


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

Date: 5 Nov 1999 02:18:04 GMT
From: lee.lindley@bigfoot.com
Subject: Re: perl and commonsense
Message-Id: <7vteos$p8$2@rguxd.viasystems.com>

David Jacoby <jacoby@dynamo.ecn.purdue.edu> wrote:
:>Kragen Sitaker <kragen@dnaco.net> wrote:

:>>>Array slices aren't lvalues?

:>>No, they're lists of lvalues or lists of rvalues under normal
:>>circumstances.


:>196 jacoby@shay 8:18pm ~/public-web/Work/Javascript % cat test.pl ;
:>#!/usr/local/bin/perl -w
:> 
:>@list = qw( one two ) ;
:> 
:>@list[1,0,] = @list[0,1] ;
:>print join "|" , @list , "\n" ;
:>197 jacoby@shay 8:19pm ~/public-web/Work/Javascript % test.pl
:>two|one|
:>198 jacoby@shay 8:19pm ~/public-web/Work/Javascript %

:>Smells like an lvalue to me, Kragen ;

All you did was:

($val1, $val2) = ($val2, $val1);

The fact that the individual elements that were lvalues came from an
array slice is covered precisely by what Kraken wrote.  The list
itself is still not an lvalue.


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Fri, 05 Nov 1999 03:11:52 GMT
From: James Tolley <jtolley@bellatlantic.net>
Subject: Re: PERL in Windows CE?
Message-Id: <38224A70.9B7BF739@bellatlantic.net>

johnsteele@my-deja.com wrote:

> Anyone know if PERL (ActiveState) will run under Windows CE?

According to CPAN, there are no known binary distributions for CE:

http://www.cpan.org/ports/index.html#win32

James



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

Date: Thu, 4 Nov 1999 20:49:28 -0600
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: Perl modules to build Explorer-like HTML GUI??
Message-Id: <7vtghg$r$1@canopus.cc.umanitoba.ca>


Shmooth <shmooth@yahoo.com> wrote in
    message news:3821BC22.1C7DA118@yahoo.com...
>
> I want to build an M$ Windows Explorer-type interface in HTML.
[snip]

Hi,
    Take a look at the HTML::EP::Explorer module, available
at $CPAN/authors/id/JWIED. This may not do exactly what
you were after, but might be a good start.

best regards,
Randy Kobes





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

Date: Thu, 04 Nov 1999 21:29:21 -0500
From: "Kevin J. Bennett" <tdk@cris.com>
Subject: Re: Perl script to convert a date to unix time?
Message-Id: <38224101.547F4EC4@cris.com>

First I would like to thank everyone for the quick answers.. I worked with
the first suggestion for about 10 minutes and got it working ;)

Stupid me, I forgot to add the use POSIX; for about the first 8 minutes...

Here is the script I am using:

#!/www/shell/bin/perl5
print "Enter Date \(ie 3/4/99\):";
$date = <STDIN>;
chop ($date);
@splitdate = split (/[\/]+/, $date);
$splitdate[0] = ($splitdate[0]-1);
use POSIX;
$time_t = POSIX::mktime( 0, 0, 0, $splitdate[1], $splitdate[0],
$splitdate[2] );
print "$time_t\n";

Again thanks to all.

Kevin.

"Kevin J. Bennett" wrote:

> Does anyone know of a simple perl script that would accept a date like
> 3/5/98 and return the unix time in seconds for that date? To me it seems
> like it would be a very simple thing to do but I have looked for the
> past three days and can't find any direction.
>
> Thanks,
> Kevin.
> tdk@cris.com



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

Date: Thu, 4 Nov 1999 20:52:05 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl script to convert a date to unix time?
Message-Id: <MPG.128c0252c0c8960998a1b2@nntp.hpl.hp.com>

In article <38224101.547F4EC4@cris.com> on Thu, 04 Nov 1999 21:29:21 -
0500, Kevin J. Bennett <tdk@cris.com> says...

 ...

> #!/www/shell/bin/perl5
> print "Enter Date \(ie 3/4/99\):";
                    ^          ^     # noise
> $date = <STDIN>;
> chop ($date);
> @splitdate = split (/[\/]+/, $date);
                       ^  ^^         # noise
> $splitdate[0] = ($splitdate[0]-1);
> use POSIX;
> $time_t = POSIX::mktime( 0, 0, 0, $splitdate[1], $splitdate[0],
> $splitdate[2] );
> print "$time_t\n";

In less than two months, the date will be 1/1/00.  What will your 
program do then?  Do you think it's worth the effort now to think about 
it?

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


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

Date: 4 Nov 1999 20:14:03 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: problems reading text file
Message-Id: <slrn824fic.dk.abigail@alexandra.delanet.com>

Aaron  Chrismas (achrisma@s3.ucf.engr) wrote on MMCCLVI September
MCMXCIII in <URL:news:slrn823sm3.o2k.achrisma@s3.ucf.engr>:
** 
** I have a text file which stores a bit of network info
** anThe problem
** is that on of the fields is wrapped by "<....>".  For
** example:
** 
** A397-13D	<G049>	17.2.3A	99Nov03	99Aug02
** 
** Somewhere between reading the file or printing out the
** contents of the from within my script.  Everything
** between (and including) the brackets is lost.  Does
** anyone know of a solution??


I would trace the network cables in the office if I where you.
Those pointy brackets can easily puncture the cables, and everything
drops out then. Use warm, soapy water and look for bubbles.

Don't use a match!


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


  -----------== 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: Fri, 5 Nov 1999 10:53:29 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: reverse on range operator
Message-Id: <7vtgrr$7vg@netnews.hinet.net>

It is asymmetric that

for(1..100000000) { print }  # will NOT create a huge array, but
for(100000000..1) { print }  # won't work, and
for(reverse 1..100000000) { print }  # will create a huge array

Maybe we can revise 'reverse' on range operator for huge
step-down for-loops, just like the revision on for(1..100000000).





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

Date: Thu, 4 Nov 1999 02:56:15 -0800
From: "Baris Sumengen" <sumengen@iplab.ece.ucsb.edu>
Subject: Re: Sort order in Perl
Message-Id: <7vtmid$p4e@yuggoth.ucsb.edu>

replace ö with oe , etc.
then sort

<h.benne@library.uu.nl> wrote in message
news:7vmnc3$akn$1@news1.xs4all.nl...
> Hello,
>
> This is probably a newbie question, but I do not know the answer and
hopefully
> somebody does.
>
> I want to sort an array with names that contains diacritical characters in
a
> different way Perl does by default.
>
> The order words are sorted by Perl is not the way I want it to be. The
> diacritical character 'ö' for example is sorted after the 'z' and I want
it to
> be sorted as 'oe'. The same for 'ä' (ae) and 'ü' (ue). Is this possible ?
>
> Thanks in advance,
>
> Hugo Benne (h.benne@library.uu.nl)
>






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

Date: Thu, 04 Nov 1999 23:16:37 -0500
From: Akira <akira####@mediaone.net>
Subject: Re: Yet another Perl Sockets question...
Message-Id: <38225A25.29467964@mediaone.net>

Kragen Sitaker wrote:

> In article <38221595.17D5670@titan.ndhm.gtegsc.com>,
> J.Z. Brody <NOSPAMbubba@titan.ndhm.gtegsc.com> wrote:
> >I'm receiving data like:
> >$socket($buff, 1024); ## 1024 because I don't know how big it is... just
> >not bigger than 1024
>
> I don't understand this code.
>
> #!/usr/bin/perl -w
> use strict;
> my ($socket, $buff);
> $socket($buff, 1024);
>
> . . . gives me:
>
> syntax error at - line 5, near "$socket("
> Execution of - aborted due to compilation errors.
>
> So I guess perl doesn't understand it either.

sorry... I should review my posts better...

The actual send/recv should read...

Server:  $socket->send(@filecontents, 0) or die "Send died: $!\n";

Client:  $socket->recv($buff, 1024);


What I'm trying to figure out is how to tell the receiving end to stop looking
for data.  I was assuming (bad idea) that if one side is sending that the other
side that's receiving would stop receiving because the sending side said it was
through. (told you it was a bad idea to assume).  I've talked with a few people
and they said that perl doesn't really account for this.  That it's a function
of the sockets on the machine being used.  Also that I need to send the client
the size of the buffer being sent so that it can use that value for the recv.
ie $socket->recv($buff, $length).

The purpose of posting to the comp.lang.perl.misc (for those thinking of
RTFMing me) is to determine which RTFM i'm missing out on.

Does perl take account of this?  Who tells the server (send) to stop sending?
Who tells the client (recv) to stop buffering to *that* specific buffer?

I'm using IO::Socket for simplicity....

Just need a shove in the right direction...

-jZb



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

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


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