[10402] in Perl-Users-Digest
Perl-Users Digest, Issue: 3995 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 16 18:01:39 1998
Date: Fri, 16 Oct 98 15:00:16 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 16 Oct 1998 Volume: 8 Number: 3995
Today's topics:
A Simple Question <yong@shell.com>
Re: A Simple Question <uri@camel.fastserv.com>
Re: A Simple Question (Rufus Xavier Sarsaparilla)
Re: Are there any "perl.newbie" group or forum? (Adam Turoff)
ARGV and Use of uninitialized value mike_allen@my-dejanews.com
array references nguyen.van@imvi.bls.com
Re: count files.... (Mark-Jason Dominus)
Re: Flushing HTML to output before forking off another <jason.holland@dial.pipex.com>
Re: HELP!!!!cgi mystery problem (Jesse D. Sightler)
Re: Is this a bug? (Ilya Zakharevich)
Modules (was: off topic) (Adam Turoff)
Net::LDAPapi -> WinNT4 (w/UofMich libs) <bruce.w.mohler@saic.com>
New Module: File::Finder -- OO version of File::Find <jdporter@min.net>
Re: newbie: getting the wrong month out of localtime() <uri@camel.fastserv.com>
Re: newbie: getting the wrong month out of localtime() (Larry Rosler)
Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has regi (Adam Turoff)
Re: Slow Sort? (Mark-Jason Dominus)
Re: sorting <uri@camel.fastserv.com>
Re: Too stupid (David Alan Black)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 16 Oct 1998 15:32:43 -0500
From: yong <yong@shell.com>
Subject: A Simple Question
Message-Id: <3627AD6B.67593853@shell.com>
Suppose a file contains 1 million lines. I want to read in all except
the first line and process them. I can think of this code to do the
work:
open INP, "the_file" or die "XXX";
while (<INP>)
{ next if $.==1; #This is checked every time a line is read in.
&processit;
}
close;
But this is quite a waste if compared to a real human doing the job. If
I do it manually, I'll definitely not ask myself whether the line read
in is the first line from the second line on. In this sense a computer
is stupid. But maybe it's because I don't know better code than what's
shown above. Is this something we can improve or have to live with? In
other words, can we forget about the "next if $.==1;" line from some
point on in order to improve effiency?
Note: The lines in the_file are of variable length and can't be easily
treated by seek (in my opinion), unless the file goes through some
filter first, which may take too much CPU time.
Yong Huang
Email:yong@shell.com
------------------------------
Date: 16 Oct 1998 16:45:07 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: yong <yong@shell.com>
Subject: Re: A Simple Question
Message-Id: <sar4st4p770.fsf@camel.fastserv.com>
>>>>> "y" == yong <yong@shell.com> writes:
y> Suppose a file contains 1 million lines. I want to read in all except
y> the first line and process them. I can think of this code to do the
y> work:
y> open INP, "the_file" or die "XXX";
y> while (<INP>)
y> { next if $.==1; #This is checked every time a line is read in.
y> &processit;
y> }
y> close;
y> But this is quite a waste if compared to a real human doing the job. If
y> I do it manually, I'll definitely not ask myself whether the line read
y> in is the first line from the second line on. In this sense a computer
y> is stupid. But maybe it's because I don't know better code than what's
y> shown above. Is this something we can improve or have to live with? In
y> other words, can we forget about the "next if $.==1;" line from some
y> point on in order to improve effiency?
simple, just read the first line before the loop:
<INP> ;
while (<INP>)
{
&processit;
}
hth,
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: 16 Oct 1998 14:03:03 -0700
From: kirbyk@best.com (Rufus Xavier Sarsaparilla)
Subject: Re: A Simple Question
Message-Id: <708ca7$j1j$1@shell2.ba.best.com>
In article <3627AD6B.67593853@shell.com>, yong <yong@shell.com> wrote:
>Suppose a file contains 1 million lines. I want to read in all except
>the first line and process them. I can think of this code to do the
>work:
>
>open INP, "the_file" or die "XXX";
>while (<INP>)
> { next if $.==1; #This is checked every time a line is read in.
> &processit;
> }
>close;
>
If you want to skip the check, why not just:
open INP, "the_file" or die "XXX";
$junk = <INP>;
while (<INP>)
{
&processit;
}
close;
In other words, read in the first line before you start the loop, and then
you don't have to do any checking. If the first line contains any
interesting data, you can easily save it, too - I assume it's most likely
a header of some sort.
--
Kirby Krueger O- kirbyk@best.com
<*> "Most .sigs this small can't open their own jump gate."
------------------------------
Date: 16 Oct 1998 16:57:30 -0400
From: ziggy@panix.com (Adam Turoff)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <708bvq$apt@panix.com>
Russ Allbery <rra@stanford.edu> wrote:
>I think Perl is really fundamentally a system administrator's language,
>not in the sense that that's all it's good for by any means, but in the
>sense that it appeals strongly to people who want to write something that
>solves a piece of the problem *now* and then can be later expanded into
>something that solves bigger problems later. It's a highly iterative
>language to write in, which appeals to the way I program and is much
>harder to do in many other languages.
I could use the same argument by s/system administrator/web programmer/
(whatever 'web programmer' is supposed to mean these days).
Perl has often been pigeonholed into these two areas of strength.
Unfortunately, as the visibility of perl increases, it becomes more
important to spin it properly.
Perl is _not_ just for breakfast anymore!
That said, I try and describe perl as a 'real world' language. Yahoo
wouldn't be here today without it, and a bazillion sysadmins would be
much more frazzled without it as well. Perl is great for text hacking,
but these are only two instances where hacking text quickly is critical.
I recently finished converting 16GB of legacy data into something more
modern with perl. Had I used lex/yacc/C/C++/etc., I might be halfway
done by now. Perl actually sped the process along.
>Quite a bit of the formality and structure of other languages seems aimed
>at making you figure out what you're doing before you do it. That makes a
>lot of sense for large group projects and other more traditional software
>engineering endeavors. System administrators, though, usually figure out
>what they want to do after they've done it. :)
In the new 'web paradigm', three months of design and team planning is a
joke when you need a product to hit QC in 3 weeks. Much of traditional CS
is going out the window in the name of competitiveness and speed, and that's
not going away anytime soon.
What's C++ doing to support that paradigm? C? Pascal? Ousterhout makes
the case that Tcl and Python fall into the same category of meeting
the increasing demands on development teams.
It's a very fine line here. Teach the 'classical paradigm' of Pascal ->
C -> C++/Smalltalk/Java/? which is practically useless in many parts of
the real world, or teach the 'new paradigm' of perl and instant
gratification when you're not really well-grounded in computing....
Z.
------------------------------
Date: Fri, 16 Oct 1998 20:52:35 GMT
From: mike_allen@my-dejanews.com
Subject: ARGV and Use of uninitialized value
Message-Id: <708bmk$mgv$1@nnrp1.dejanews.com>
Hello,
Why does the following:
#!/usr/bin/perl -w
$ARGV[0] =~ s/,//;
if( $ARGV[0] ) { < error here
print "$ARGV[0]\n";
}
produce:
$ temp.pl
Use of uninitialized value at ./temp.pl line 4
if passed no arguments, but:
if( $ARGV[0] ) {
print "$ARGV[0]\n";
}
does not?
Thanks,
Mike
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 16 Oct 1998 20:24:17 GMT
From: nguyen.van@imvi.bls.com
Subject: array references
Message-Id: <708a1g$jn6$1@nnrp1.dejanews.com>
Hi guys,
I want read a file with each line is assigned as an array reference and also
want to print out all of them. Please give me a general format.
Thanks
Van
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 16 Oct 1998 16:12:05 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: count files....
Message-Id: <7089al$5bb$1@monet.op.net>
In article <36278731.10D7@klaskycsupo.com>,
Jaime Diaz <jamdiaz@klaskycsupo.com> wrote:
>looking for a piece of perl code that will count files in a
>directory.........
sub count_files {
my $dir = shift;
local *D;
opendir D, $dir or return;
my @files = readdir D;
# Use ``my @files = grep { -f "$dir/$_" } readdir D'' for plain files only
closedir D;
@files - 2; # Ignore the files . and .. which are always present
}
------------------------------
Date: Fri, 16 Oct 1998 21:58:15 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
To: nkaiser@my-dejanews.com
Subject: Re: Flushing HTML to output before forking off another process
Message-Id: <3627C177.B089256@dial.pipex.com>
Hello,
nkaiser@my-dejanews.com wrote:
>
> I have a script where I print something out, fork something off, then print
> again. My problem is, I want the first thing I print to be displayed to the
> browser first. But, it seems to wait until the system call is done and display
> everything all at once. ie:
>
> select (STDOUT);
Try setting STDOUT to unbuffered BEFORE doing any output
> print "Please wait, this may take a minute....";
> $|=1;
So you have:
$| = 1;
print "Please wait, this may take a minute....";
> my $output = `/bin/exe`;
> print "Here is the output: $output";
>
> How can I make this so it prints in sequence....
>
> Thanks,
> Neal
Bye!
--
sub jasonHolland {
my %hash = ( website =>
'http://dspace.dial.pipex.com/jason.holland/',
email => 'jason.holland@dial.pipex.com' );
}
------------------------------
Date: Fri, 16 Oct 1998 21:02:44 GMT
From: jsight@pair.com (Jesse D. Sightler)
Subject: Re: HELP!!!!cgi mystery problem
Message-Id: <3627b43e.5156669@news.mindspring.com>
On Fri, 16 Oct 1998 09:25:24 -0700, Kammie Kayl
<kammiek@mail.internetdirect.net> wrote:
>Hi Folks,
> I am having a cgi problem I have never encountered before.
>There is no output of the answers on the email. The email gets sent, and
>the labels appear, but none of the text I write in, or radio buttons I
>choose are showing up.
>The permissions are fine, no errors are even being reported when I tail
>the errors log
>Maybe it's a small small thing I am overlooking, but I am at my wits end
>now.
Answer in the style of your question: Your script is buggy.
Better answer: Please provide us with more info, as you gave nothing
that might even hint at the problem.
------------------
Jesse D. Sightler
http://www3.pair.com/jsight/
------------------------------
Date: 16 Oct 1998 21:49:16 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Is this a bug?
Message-Id: <708f0s$je2$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Jonathan Feinberg
<jdf@pobox.com>],
who wrote in article <m3zpawo8ma.fsf@joshua.panix.com>:
> As for why your one-liner doesn't work, I'm as mystified as you. I
> traced it with perl -Dr, and the results are confusing.
$ may match at two places in a \n-terminated string. Use (?=\n) if
you want to match before a newline only (not *also-at-end-of-string*).
Ilya
------------------------------
Date: 16 Oct 1998 17:02:20 -0400
From: ziggy@panix.com (Adam Turoff)
Subject: Modules (was: off topic)
Message-Id: <708c8s$b33@panix.com>
Matthew Bafford <dragons@scescape.net> wrote:
>Next time post what you've tried, what it's doing, and what you think
>it should be doing. We are here to help, but C<use Mind::Reader;>
>still doesn't work just like we'd like.
So *you're* the guy working on Mind::Reader. We should talk sometime.
I've got some nasty kinks in my Mind::Writer module.
Then again, maybe you knew that already...
Z.
------------------------------
Date: Fri, 16 Oct 1998 13:06:35 -0700
From: Bruce Mohler <bruce.w.mohler@saic.com>
Subject: Net::LDAPapi -> WinNT4 (w/UofMich libs)
Message-Id: <3627A74A.1ADC3D6D@saic.com>
Has anyone successfully installed the Net::LDAPapi module
on Windows NT?
I installed this module (with the Univ of Michigan LDAP 3.3
libraries) on a LINUX box without any problems and it worked
like a champ. It seems to be the most robust of the 3 or 4 Perl
related LDAP interfaces.
When I went to install it on my NT box with (build 502 from
ActiveState), it has been nothing short of impossible.
I downloaded the "Windows LDAP Developer Kit" from
http://www.umich.edu/~dirsvcs/ldap/ and put the libraries
in the .../vc/lib directory with the header files in .../vc/include.
I'm running VC++ 5.0 Pro.
I'm getting a warning from the "perl Makefile.PL" that it can't
find a library for "-llber" (which is not part of the UofM WLDK).
The actual nmake aborts on the first C program with complaints
about the constant.h header file..
I'm only committed to the UofM libraries because we already
have them. If someone can help me get working with the
Netscape libraries, I'll switch to those in a second.
Thanks, in advance. All suggestions welcome!
Bruce
--
Bruce W. Mohler 619-458-2675 (voice)
SAIC/ITS/Server Support 619-535-7806 (fax)
Sr UNIX system administrator 888-781-5697 (pager)
mailto:bruce.w.mohler@saic.com
Of course my password is the same as my pet's name.
My dog's name is Q47pY!3, but I change it every 90 days.
------------------------------
Date: Fri, 16 Oct 1998 16:24:39 -0400
From: John Porter <jdporter@min.net>
Subject: New Module: File::Finder -- OO version of File::Find
Message-Id: <3627AB87.F27DCB49@min.net>
Greetings, Perl mongers;
As it frequently happens that people clamor for a directory
tree traverser with a better interface than File::Find, I have
taken the liberty of object-orientificationalizing File::Find.
The first cut is given below.
I have changed the name of File::Find to File::Finder, to
reflect its more noun-like nature, naturally.
I would be extremely grateful for any comments, suggestions,
bug fixes; in particular, I am considering lobbing this one
over into CPAN, so if you have strong feelings about that, one
way or another, don't hold 'em back.
John Porter
#---------------- I'd Turn Back If I Were You ---------------------
package File::Finder;
require 5.000;
use Config;
require Cwd;
require File::Basename;
=head1 NAME
File::Finder->find - traverse a directory tree
File::Finder->finddepth - traverse a directory tree depth-first
=head1 SYNOPSIS
use File::Finder;
@MyFileFinder::ISA = qw(File::Finder);
sub MyFileFinder::callback {
my $self = shift;
my $filename = shift;
print $self->name, "\n";
}
MyFileFinder->find( '/usr' );
MyFileFinder->finddepth( '/usr' );
=head1 DESCRIPTION
File::Finder is an object-oriented adaptation of the routines
found in File::Find. Rather than passing a sub ref to the find()
function, you derive a class which overrides the callback() method.
For each directory entry encountered during the traversal, the
callback is called. The callback is passed one additional argument:
the name of the file in the current directory; also, you are chdir'd
to that directory whenever the callback is called.
Within the callback, you can obtain other information about
the directory entry by calling the following methods of the object:
$self->dir returns the current directory name;
$self->name returns the full path name of the directory entry;
To prune the search tree at the current directory, the callback
should call $self->prune(1).
C<finddepth> is just like C<find>, except that it does a depth-first
search.
=head2 Note
You do not have to override the default callback to get useful
behavior. If you just want the full path name printed to stdout
for each node encountered, you can use File::Finder directly:
File::Finder->find( '/usr' );
=head1 BUGS
There is currently no way to make find or finddepth follow symlinks.
=head1 AUTHOR
1998-10-16 John Porter jdporter@min.net
Derived from File::Find, which is by the Perl-5-Porters.
(No, I'm not one of them :-)
=cut
package File::Finder;
require 5.000;
use Config;
require Cwd;
require File::Basename;
use strict;
use vars qw( $Is_VMS $Is_NT $dont_use_nlink );
# not meant to be called by the general public.
sub new {
my $p = shift;
bless {
topdirs => [ @_ ],
frames => [],
prune => 0,
depth_first => 0,
}, $p;
}
sub dir {
my $self = shift;
$self->{'frames'}[0][0]
}
sub fixed_dir {
my $self = shift;
$self->{'frames'}[0][1]
}
sub name {
my $self = shift;
$self->{'frames'}[0][2]
}
sub nlink {
my $self = shift;
$self->{'frames'}[0][3]
}
sub Push {
my $self = shift;
unshift @{ $self->{frames} }, [ @_ ];
}
sub Pop {
my $self = shift;
shift @{ $self->{frames} };
}
sub prune {
my( $self, $val ) = @_;
defined $val and $self->{prune} = $val;
$self->{prune}
}
#
# the default callback prints the full name.
#
sub callback {
my $self = shift;
my $file = shift;
# print
# " prune : ", $self->prune, "\n",
# " dir : ", $self->dir, "\n",
# " fixdir: ", $self->fixed_dir, "\n",
# " name : ", $self->name, "\n",
# " file : $file\n";
print $self->name, "\n";
}
sub find {
my $pkg = shift;
my $self = $pkg->new( @_ );
$self->{depth_first} = 0;
$self->_find;
}
sub finddepth {
my $pkg = shift;
my $self = $pkg->new( @_ );
$self->{depth_first} = 1;
$self->_find;
}
#
# this sub is not recursive.
#
sub _find {
my $self = shift;
my $cwd = Cwd::cwd();
for my $topdir ( @{ $self->{topdirs} } ) {
my( $topdev, $topino, $topmode, $topnlink ) =
$Is_VMS
? stat($topdir)
: lstat($topdir)
;
unless ( defined $topnlink ) {
warn "Can't stat $topdir: $!\n";
next;
}
if ( -d _ ) {
if ( chdir $topdir ) {
my $fixtopdir = $topdir;
$fixtopdir =~ s,/$,, ;
$fixtopdir =~ s/\.dir$// if $Is_VMS;
$fixtopdir =~ s/\\dir$// if $Is_NT;
# dir: fixed_dir: name: nlinks:
$self->Push( $topdir, $fixtopdir, $topdir, $topnlink );
$self->prune( 0 );
$self->{depth_first} or $self->callback( '.' );
$self->prune or $self->_find_R;
$self->{depth_first} and $self->callback( '.' );
$self->Pop;
}
else {
warn "Can't cd to $topdir: $!\n";
}
}
else {
my $d;
my $f;
unless (($f,$d) = File::Basename::fileparse($topdir)) {
($f,$d) = ($topdir, '.');
}
if ( chdir $d ) {
# dir: fixed_dir: name: nlinks:
$self->Push( $d, $d, $topdir, $topnlink );
$self->callback( $f );
$self->Pop;
}
}
chdir $cwd;
}
}
sub _find_R {
my $self = shift;
# Get the list of files in the current directory.
opendir DIR, '.' or do { warn "Can't open .: $!\n"; return };
my @filenames = readdir DIR;
closedir DIR;
if ($self->nlink == 2 && !$dont_use_nlink) {
# This dir has no subdirectories.
for (@filenames) {
next if $_ eq '.' || $_ eq '..';
$self->Push(
$self->dir,
$self->fixed_dir,
$self->dir . "/$_",
0
);
$self->callback( $_ );
$self->Pop;
}
}
else {
# This dir has subdirectories.
my $subcount = $self->nlink - 2;
for (@filenames) {
next if $_ eq '.' || $_ eq '..';
$self->Push(
$self->dir,
$self->fixed_dir,
$self->dir . "/$_",
0
);
$self->prune( 0 );
$self->{depth_first} or $self->callback( $_ );
if ($subcount > 0 || $dont_use_nlink) {
# Seen all the subdirs?
# Get link count and check for directoriness.
my($dev,$ino,$mode,$nlink) =
($Is_VMS ? stat($_) : lstat($_));
if ( -d _ ) {
# It really is a directory, so do it recursively.
if ( !$self->prune && chdir $_ ) {
my $d = $self->name;
$d =~ s/\.dir$// if $Is_VMS;
$d =~ s/\\dir$// if $Is_NT;
$self->Push(
$d,
$self->fixed_dir,
$d,
$nlink
);
$self->_find_R;
$self->Pop;
chdir '..';
}
--$subcount;
}
}
$self->{depth_first} and $self->callback( $_ );
$self->Pop;
}
}
}
# Set dont_use_nlink in your hint file if your system's stat doesn't
# report the number of links in a directory as an indication
# of the number of files.
# See, e.g. hints/machten.sh for MachTen 2.2.
$dont_use_nlink = 1 if ($Config::Config{'dont_use_nlink'});
# These are hard-coded for now, but may move to hint files.
if ( $^O eq 'VMS' ) {
$Is_VMS = 1;
$dont_use_nlink = 1;
}
if ( $^O =~ /^mswin32/i ) {
$Is_NT = 1;
$dont_use_nlink = 1;
}
if ( $^O eq 'os2' || $^O eq 'msdos' || $^O eq 'amigaos' ) {
$dont_use_nlink = 1
}
1;
############ END OF File::Finder #############
------------------------------
Date: 16 Oct 1998 16:36:11 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: newbie: getting the wrong month out of localtime()
Message-Id: <sar67dkp7lw.fsf@camel.fastserv.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> [Posted to comp.lang.perl.misc and a copy mailed.]
LR> In article <362772ac.0@news.new-era.net> on 16 Oct 1998 16:22:04 GMT,
LR> scott@softbase.com <scott@softbase.com> says...
>> Marcel Duivesteijn (M.Duivesteijn@cao-horeca.nl) wrote:
>> > To my surprise I got the wrong month. I got month 9 instead of 10.
>>
>> SURPRISE! Welcome to be brain-damaged world of UNIX and C time
>> functions. The month is 0..11 instead of 1..12, which has to be one of
>> the all-time boneheaded decisions in the history of computing. It
>> started in UNIX, and the UNIX time libraries got codified as-is to
>> become the ANSI C libraries. Perl uses these as-is. The brain damage
>> is here to stay!
oh and winblows doesn't use C or ansi libraries? why didn't uncle bill
just create some buggier api and declare it a new standard? i think the
brain damage is with you. as larry says below, have you ever done any 1
based indexing in C? stick to fortran where you belong.
LR> Not that there aren't other errors or strangenesses. The range of
LR> 'seconds' is 0 .. 61 even though there can never be two leap seconds in
LR> one minute and, using the Epoch time scale, there can never be any leap
LR> seconds at all. And the 'day of the year' is 0 .. 365, though that
LR> would never be used as an array index either.
ever heard about leap years? 366 days = 0 .. 365
and i do believe there have been 2 leap seconds added in during some
slow years. :-)
but i think you are right about not getting those seconds out. i don't
know of any way to tell the time functions which years had leap seconds.
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Fri, 16 Oct 1998 14:06:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie: getting the wrong month out of localtime()
Message-Id: <MPG.10915517fd9a5e90989823@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <sar67dkp7lw.fsf@camel.fastserv.com> on 16 Oct 1998 16:36:11
-0400, Uri Guttman <uri@camel.fastserv.com> says...
> ... i think the
> brain damage is with you. as larry says below, have you ever done any 1
> based indexing in C? stick to fortran where you belong.
^ or in Perl!
In email, he (Scott McMahan [scott@softbase.com]) told me that he always
outputs number-based months, never strings.
> LR> Not that there aren't other errors or strangenesses. The range of
> LR> 'seconds' is 0 .. 61 even though there can never be two leap seconds in
> LR> one minute and, using the Epoch time scale, there can never be any leap
> LR> seconds at all. And the 'day of the year' is 0 .. 365, though that
> LR> would never be used as an array index either.
>
> ever heard about leap years? 366 days = 0 .. 365
I think you read that too fast. It is the 'start counting days of the
year at 0' (i.e., documented as days *since* January 1) that I was
objecting to.
> and i do believe there have been 2 leap seconds added in during some
> slow years. :-)
No. The Keepers of the Time decided that they will not allow that to
happen. Ever. (Barring some sort of Velikovskian catastrophe, of
course, but then we won't survive to care.)
> but i think you are right about not getting those seconds out. i don't
> know of any way to tell the time functions which years had leap seconds.
This was discussed here some months ago. Look in DejaNews for leap
seconds.
In the artifical time scale used by all computers, leap seconds are
ignored, and every year is exactly (365 or 366 -- see, I have heard
about leap years!) * 24 * 60 * 60 seconds long. (That's about pi *
10**7 sec, BTW. Ex-physicists like me know that sort of stuff :-)
Thus the Unix Epoch time is now off compared to astronomical time by
about half a minute and counting. So we don't have 'to tell the time
functions which years had leap seconds' -- none of them did.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Oct 1998 17:38:21 -0400
From: ziggy@panix.com (Adam Turoff)
Subject: Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <708ecd$ego@panix.com>
Brad Murray <murrayb@vansel.alcatel.com> wrote:
>ziggy@panix.com (Adam Turoff) writes:
>
>> Let's not forget the Pe[a]rl Sake, the oyster bar, roasted gecko,
>> good beer, or the mother-of-perl inlay at the bar.
>
>Oh I think the place should be vegetarian. Why everyone is so interested
>in roasting and eating their mascots, I will never understand. It just
>doesn't seem right, somehow. The camel should be the bouncer.
tchrist had an interesting observation when there were mostly 3 ora perl
books on the market. (hopelessly paraphrased from TPC 1.0):
First there was the camel.
Then there was the llama.
Note that these are two nice, furry, warm-blooded creatures.
Then the llama was ported to windows. What do we get?
A cold blooded lizard called a gecko.
Roast gecko stays on the menu. I wouldn't mind armadillos crawling
around the room or barbequed moose, grilled squid, marinated horseshoe
crabs, etc. (I draw the line at any of the Oracle bugs, or the canine/feline
Windows animals.)
Z.
------------------------------
Date: 16 Oct 1998 16:06:06 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Slow Sort?
Message-Id: <7088ve$59i$1@monet.op.net>
In article <MPG.109119ea8fa53b7098981a@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>[Posted to comp.lang.perl.misc and a copy mailed.]
>
>In article <707pl6$s40@euphony.tri.sbc.com> on 16 Oct 1998 10:44:38 -
>0500, Steve Monson <monson@tri.sbc.com> says...
>> Now, when I changed my code to use Unix's system sort on a file:
>>
>> open(OUT,">/tmp/sl"); foreach (@sl) {print OUT $_,"\n";} close(OUT);
>
>The following is a *much* faster way of writing the temp file (more than
>five times faster by my benchmark):
>
> open(OUT,">/tmp/sl");
> { local $" = "\n"; print OUT "@s1\n" }
> close(OUT);
Yes, but that has the disadvantage of constructing a gigantic string
with the entire file contents before it prints anything. Is the
speedup really important here?
However, I agree completely with your diagnosis of the real problem:
Perl is using a lot of memory for the array, and the sorting process
is causing the program to thrash. The Unix `sort' command uses
temporary files and a merge process to avoid this.
Possible solution: Write the data to a file, use
system("sort -o file file");
to sort it, and read it back.
I wonder if there's anything to be gained from implementing a Perl
module to do a disk-based merge sort? I suppose probably not.
------------------------------
Date: 16 Oct 1998 16:28:09 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: sorting
Message-Id: <sar7ly0p7z9.fsf@camel.fastserv.com>
>>>>> "JP" == John Porter <jdporter@min.net> writes:
JP> Uri Guttman wrote:
>>
JP> You have now given two answers that don't work.
JP> Care to step down to the world of mortal men, and test one
JP> response before you post it?
i will prove my mortality by commiting variable suicide.
as someone else posted you can say
sort { &$sort_sub } @list ;
which is what i meant. you need the block so you can call through the
sub ref. i think you should just be able to use the sub ref directly.
and remember i was trying (and did) solve the multilevel sort problem,
not how to use a code ref for a sort sub.
JP> Btw, the "solution" I gave before also doesn't work.
JP> It really appears that Perl requires a code block, or the
JP> bareword name of a subroutine.
so we are all mortal, eh?
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: 16 Oct 1998 17:09:27 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Too stupid
Message-Id: <708cm7$1jc$1@pilot.njin.net>
Hello -
Shawn Corey <shawn@magma.ca> writes:
>This is a multi-part message in MIME format.
>--------------1047CE8AB199BC52781F7E33
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>Hi Tim,
>Add the following lines to the end of you program.
>print "\nPress ENTER to exit: ";
>my $tmp = <STDIN>;
>This waits for the user to enter a line. The problem you encountered is
>a MS-DOS one. There is a way of changing this by fooling with the
>Properties of the MS DOS Prompt but I found that if I change it once, it
>changes for all my MS DOS Prompts. I must be doing something wrong.
>Therefore I add the above code when I want a program to wait. Crude but
>effective. BTW xterm does the same thing. Again, there are options to
>prevent this but the above code is an universal solution.
xterm doesn't do what Tim described:
orpheus:~/perl$ cat circum
#!/usr/bin/perl -w
print ("Enter the radius of the circle. ");
$radius = <STDIN>;
chomp ($radius);
$circumference = ((2 * 3.1415)* $radius);
print ("$circumference");
orpheus:~/perl$ perl circum
Enter the radius of the circle. 10
62.83orpheus:~/perl$
orpheus:~/perl$
orpheus:~/perl$ # xterm still running!
Why would the xterm process exit? (I don't ask the question with
the same ardency in the case of DOS, because it seems to me that
such behavior comports with the general Micros**t ethos entirely.)
David Black
dblack@pilot.njin.net
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 3995
**************************************