[8588] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2205 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 29 20:07:27 1998

Date: Sun, 29 Mar 98 17:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 29 Mar 1998     Volume: 8 Number: 2205

Today's topics:
        'Search and Replace' for multiple files <sray@netnuevo.com>
    Re: A problem for Perlxs or Perlxstut (Tye McQueen)
        Caldera Linux perl5.004_04 build/test problem (Peter Leopold)
        Editing a flatfile... <mpriatel@chat.carleton.ca>
    Re: gethostbyaddr (Matthew Cravit)
        How to get the PID of a system call in Perl? <jxg161@psu.edu>
    Re: How to get the PID of a system call in Perl? (Huu Da Tran)
    Re: How to get the PID of a system call in Perl? (Andrew M. Langmead)
    Re: Introduction to Perl DBI (brian d foy)
        Measuring elapsed time to milliseconds or less? (Harry Tennant)
    Re: Measuring elapsed time to milliseconds or less? <quentin@jihad.amd.com>
    Re: Measuring elapsed time to milliseconds or less? (Andrew M. Langmead)
    Re: Perl *is* programming (was Re: Is there a "Newsgrou (I R A Aggie)
    Re: Problems with handling Mac/PC/Unix line breaks (John Moreno)
    Re: Redirect URL (Juergen Heinzl)
        Rotating HTML using Perl <ffinstad@best.com>
    Re: Sysadmin struggeling with PERL/Sed and etc... <quentin@jihad.amd.com>
    Re: Sysadmin struggeling with PERL/Sed and etc... (Joergen W. Lang)
        The "Y2k-bugs-are-not-just-a-legacy-problem" FAQ <zooko@xs4all.nl>
    Re: Use Perl to update Monolith server (Adam)
    Re: What does this one liner do? (Peter Samuelson)
        what is cgi_auto_file? <nkatz@cts.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 29 Mar 1998 15:43:04 -0800
From: Stephanie Ray <sray@netnuevo.com>
Subject: 'Search and Replace' for multiple files
Message-Id: <351EDC88.165F12BA@netnuevo.com>

Can anyone tell me how to iterate through a list of file names and
perform a search and replace on each one?

The following is not doing a blessed thing for me!

#!/usr/local/bin/perl -w

open (INPUT, "test.txt") or die "Can't open test.txt: $!\n";
while ($line = <INPUT>) {
        $filename = $line;
        chop($filename);
        print "filename = $filename\n";
        open HANDLER, "+>>$filename";
        select HANDLER;
        s/foo/bar/;
        select STDOUT;
close HANDLER;
}



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

Date: 29 Mar 1998 13:33:42 -0600
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: A problem for Perlxs or Perlxstut
Message-Id: <6fm7mm$3hk@fohnix.metronet.com>

nisy <ni@aoe.vt.edu> writes:

) I am using C routines called from Perl. I am wondering if arrays
) can be shared across the Perl/C barrier now for Perl 5.004 in NT,
) which  means that arrays (double or float) pass from Perl to C and
) then from C back to Perl with new values.

Some "facts":

    Perl deals with structures that it doesn't create itself as
    strings (Perl strings are just continguous chunks of memory).

    Perl _insists_ of being the one to malloc(), realloc(), and
    free() the memory blocks where it stores it strings.

    Perl uses pack() to create these strings and unpack() to
    pull the data our of them.

    A C array of doubles is stored like the output of Perl's
    pack("d*",@array) ["f*" for floats].

    If the C code is only going to be used with Perl, then you
    can teach the C code to use Perl arrays.  I won't discuss
    this option any further.

One opinion:

    Avoid the temptation of having your XS code expect native
    Perl data structures and using C code to translate that
    data into a C-friendly format.  Every case of such code I
    have seen doesn't scale well:  They usually introduce some
    arbitrary size limits (as dynamic allocation is relatively
    hard in C, especially when it must talk to Perl).  They
    usually add a costly layer of translation that could be
    skipped much of the time if a different design was used.
    They usually are easy to use for simple cases but just
    plain don't support more complex operations.  They are
    also harder to debug and to enhance.

So, use Perl code to generate C-friendly data structures as
Perl strings and have your XS code be simple yet robust.
sysread() and syswrite() are good examples for XS interfaces.

If the C code insists on giving back pointers to memory that
it allocated, then there is no simple way to interface Perl
to it.  So let Perl allocate all structures.

The Perl code would look something like:

    @perl_array= ( 1.2, 3.4, 5.6 );
    $packed_array= pack( "d*", @perl_array );
    some_XS_routine( $packed_array );
    # Elements of $packed_array can be overwritten by above.
    @new_array= unpack( "d*", $packed_array );

The XS code would have an interface like sysread() and syswrite()
[without the file handle argument]:

int
some_XS_routine( svArrayOfDoubles, iElementCount=0, iElementOffset=0 )
        SV *	svArrayOfDoubles
        int     iElementCount
        int	iElementOffset
    CODE:
	RETVAL= 0;         /* Or whatever the error return is */
	if(  0 == iElementCount  ) {
	    iElementCount= SvCUR(svArrayOfDoubles)/sizeof(double);
	}
	if(  SvCUR(svArrayOfDoubles)
	      < sizeof(double)*( iElementOffset + iElementCount )  ) {
            errno= EINVAL;
        } else {
	  double *pdStartOfArray= (double *) SvPV(svArrayOfDoubles,na);
	    if(  NULL == pdStartOfArray  ) {
		errno= EINVAL;
	    } else {
		pdStartOfArray += iElementOffset;
		RETVAL= some_c_routine( pdStartOfArray, iElementCount );
	    }
	}
    OUTPUT:
        RETVAL

Sorry, this code is untested.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: 30 Mar 1998 00:04:22 GMT
From: peter@diamond.harvard.edu (Peter Leopold)
Subject: Caldera Linux perl5.004_04 build/test problem
Message-Id: <6fmni6$glp$1@news.fas.harvard.edu>

Hello everyone,
	I am unable to build/test perl5.004_04 on Caldera Linux (v1.0) 
running 2.0.24.  The build proceeds without error, but tests fail for
	t/lib/io_sock.t
	t/lib/io_udp.t
	t/lib/socket.t

Here is myconfig:
ummary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
  Platform:
    osname=linux, osvers=2.0.24, archname=i586-linux
    uname='linux puck.bruker.com 2.0.24 #24 tue mar 10 20:34:57 est 1998 i586 '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=y useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.7.0
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=undef, d_castneg=define
    intsize=4, alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -ldbm -ldb -ldl -lm -lc
    libc=/lib/libc.so.5.0.9, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

When I compare this with my successful build under solaris 2.5, I see that the
apparently critical difference is 
	 libs=-lsocket

I have looked all over the web for linux source for libsocket or libsocket, but
I haven't found it anywhere. I have also looked in Debian, RedHat and Slackware
distributions for an executable libsocket*, but have found nothing.

I am out of ideas. Can anyone suggest how I can get a clean build/test (with
sockets) for perl5.004_04 under Linux?

I've reported this bug with perlbug.

				Regards,
					Peter Leopold
					peter@diamond.harvard.edu
					pel@bruker.com


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

Date: Sun, 29 Mar 1998 18:23:20 -0500
From: Mark Priatel <mpriatel@chat.carleton.ca>
Subject: Editing a flatfile...
Message-Id: <351ED7E8.45428795@chat.carleton.ca>

Hi guys,

While learning Perl, I whipped up this little phonebook program,
(original, huh?).  Anyhow, my method for changing the data in the
flatfile seems really convoluted.   Surely there must be an easier way,
given all of Perl's search/replace function.   Anyhow, here's part of
the script:

####  READ DATA INTO ARRAY

open (DB, "phone.txt");
 @phonedata = (sort <DB>);
close (DB);

#### OPEN DATABASE FOR EDITING

 open (DB,">phone.txt");
    foreach $i (@phonedata){
      chop($i);
     ($c_last,$c_first,$c_phone,$c_dept) = split(/\|/,$i);

###
This part figures out which entry to modify by comparing the original
data of the entry selected to be edited to actual entry in the file.
Once it finds it, it replaces it with the new data....All I'm trying to
do is find and replace a string in a file...
###
   if($last eq $c_last &&
         $first eq $c_first &&
         $phone eq $c_phone &&
         $dept eq $c_dept){
         print DB "$n_last|$n_first|$n_phone|$n_dept\n";}  #If it
matches enter the new data

       else{
         print DB "$c_last|$c_first|$c_phone|$c_dept\n"} #Otherwise,
just enter the old data

   }
close (DB);
##END

Anyhow, there are a few things I don't like about this script.  1.  I
have to open the DB twice. 2. I rewriting the entire file..

Any suggestions on how to optimize this?  Can the s/// function be used
here?

Mark.



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

Date: 29 Mar 1998 11:15:35 -0800
From: mcravit@shell3.ba.best.com (Matthew Cravit)
Subject: Re: gethostbyaddr
Message-Id: <6fm6kn$e0o$1@shell3.ba.best.com>

In article <351C9422.5D39BD4C@onramp.net>,
Mark Miller  <mdmiller@onramp.net> wrote:
>It is setup to use the gethostbyname but as far as I can tell that needs
>a entry in the hosts file.  I want to be able to use ip/domain name but

I don't think gethostbyname requires an entry in the hosts file, at least
if your system is configured properly. On Solaris, for example, gethostbyname
will, AFAIK, use the /etc/nsswitch.conf file to determine how to resolve
hostnames...if it says to use DNS, gethostbyname should use the DNS.

I've also confirmed just now that gethostbyname on this system (FreeBSD)
will resolve hosts not in the hosts file.

/MC

-- 
Matthew Cravit, N9VWG               | Experience is what allows you to
E-mail: mcravit@best.com (home)     | recognize a mistake the second
        mcravit@net.com (work)      | time you make it.


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

Date: Sun, 29 Mar 1998 14:15:54 -0600
From: Jason Girard <jxg161@psu.edu>
Subject: How to get the PID of a system call in Perl?
Message-Id: <351EABFA.41C9C69@psu.edu>

I'm trying to get the process ID of "ping" when I execute it from a Perl
script, but don't know how.  Since ping just keeps on spewing output I
need to kill it before using its output statistics in the rest of the
script.

Thanks in advance,
Jason

jxg161@psu.edu
or 
jgirard@starnetusa.com


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

Date: Sun, 29 Mar 1998 20:03:09 GMT
From: tranhu@jsp.umontreal.ca (Huu Da Tran)
Subject: Re: How to get the PID of a system call in Perl?
Message-Id: <slrn6hta8c.1nn.tranhu@derby.jsp.umontreal.ca>

Un jour, Jason Girard (jxg161@psu.edu)
     affirmait publiquement que:

| Since ping just keeps on spewing output I need to kill it before using
| its output statistics in the rest of the script. 

Just like this.. on my linux box, I can do:
	ping -c 5 host

Look in your man pages if your ping allows this behaviour.

HTH...

-- 
__________________________________________________________________________
   TRAN, Huu Da                                  Universiti de Montrial
   tranhu@jsp.umontreal.ca         http://www.jsp.umontreal.ca/~tranhu/
//////////////////////////////////////////////////////////////////////////
La France a toujours cru que l'igaliti consiste ` trancher ce qui dipasse. 
                                                             -- J. Cocteau


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

Date: Sun, 29 Mar 1998 22:01:50 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: How to get the PID of a system call in Perl?
Message-Id: <EqLp72.3I0@world.std.com>

Jason Girard <jxg161@psu.edu> writes:

>I'm trying to get the process ID of "ping" when I execute it from a Perl
>script, but don't know how.  Since ping just keeps on spewing output I
>need to kill it before using its output statistics in the rest of the
>script.

The perl function system() waits for the program that it executes to
complete before returning. This means that the PID of that program is
irrelevant.

Since system() is mostly comprised of fork(), exec(), and wait() (with
some signal manipulation thrown in.) then you can perform the same
component steps of system() and have access to the PID.

Also, you could run ping with open() function with the pipe option,
then kill it after you read as many lines as you need. The boolean
true value that open returns when the command is a pipe is the PID of
the command. The program ping may have output more lines than you have
read, but it will be put to sleep when it fills the pipes buffer.

$pid = open PING, "ping $host |";
die unless $pid;
$firstline = <PING>; # make sure we don't kill it before it starts.
kill 'INT', $pid;
while(<PING>) {
  push @stats, $_ if /^---/ .. eof(PING);
}

print @stats;

If you use system to invoke a shell as a child process, and then have
process invoke ping asynchronously, then maybe you can have the shell
return the PID of the process that _it_ started. The shell's $!
variable and the "echo" command may be helpful here.

open PING, "(echo \$! ; ping $host) & |" or die;
$pid = <PING>; # first line the result of "echo"
while(<PING>) {
  # do something with the output
}
close PING;

and as someone else mentioned, many versions of ping have a "-c"
option, which will limit the number of times the command will actually
try to ping the host.
-- 
Andrew Langmead


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

Date: Sun, 29 Mar 1998 18:41:50 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Introduction to Perl DBI
Message-Id: <comdog-ya02408000R2903981841500001@news.panix.com>
Keywords: from just another new york perl hacker

In article <351e8197.0@news.arrakis.es>, "Vmctor Ruiz Marco" <vrm@arrakis.es> posted:

>I am learnig Perl and I need to make a CGI that works with MDB and DBF
>databases. I think DBI is good for this kind of job, so I have get the Perl
>5 version wich includes this module. But I have a question, DBI needs that a
>database server or "database manager program" was running on the server that
>the database is for "talk" with the database or "talks" to the database file
>directly?. If I have a MDB file, do I need to install a database server?.


you need the appropriate DBI::DBD module (the "database driver") that
provides the connection between your database thingy (file, server, 
whatever) and the DBI interface.  see CPAN for the drivers available.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: 29 Mar 1998 20:05:15 GMT
From: harry@htennant.com (Harry Tennant)
Subject: Measuring elapsed time to milliseconds or less?
Message-Id: <6fm9hr$hok$1@newshost.cyberramp.net>

I need to measure elapsed time to milliseconds, or even more precisely, if 
possible.  Is there a way to do this?

I understand the Perl5 Benchmark module returns user and cpu times to the 
millisecond but elapsed time to the second.

What I'm trying to do is time how long it takes to retrieve Web pages.  If 
there's a better way to do this, please let me know.

Thanks.

Harry
-- 
Harry Tennant  & Associates    
8423 Vista View Drive       (214) 340 0694
Dallas, TX 75243            (214) 652 4226 fax
   Discuss and learn about Business on the Net at the 
   Net Commerce Community, http://www.htennant.com
---Nothing but Net:  Seminars & Consulting on the Internet---   



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

Date: 29 Mar 1998 15:19:34 -0600
From: Quentin  Fennessy <quentin@jihad.amd.com>
Subject: Re: Measuring elapsed time to milliseconds or less?
Message-Id: <ximbtuptct5.fsf@jihad.amd.com>

>>>>> "HT" == Harry Tennant <harry@htennant.com> writes:

    HT> I need to measure elapsed time to milliseconds, or even more
    HT> precisely, if possible.  Is there a way to do this?

Check out perlfaq4(1):

	=head2 How can I measure time under a second?

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

Date: Sun, 29 Mar 1998 22:09:54 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Measuring elapsed time to milliseconds or less?
Message-Id: <EqLpKI.6Ln@world.std.com>

harry@htennant.com (Harry Tennant) writes:

>I need to measure elapsed time to milliseconds, or even more precisely, if 
>possible.  Is there a way to do this?

Have you seen the Time::HiRes module on CPAN?

<URL:http://reference.perl.com/module.cgi?Time::HiRes>

-- 
Andrew Langmead


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

Date: Sun, 29 Mar 1998 18:15:43 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl *is* programming (was Re: Is there a "Newsgroup" for Newbies to Perl?)
Message-Id: <fl_aggie-2903981815430001@aggie.coaps.fsu.edu>

In article <6flp8s$8i3$1@gaia.ns.utk.edu>, "Bob Gwynne"
<gwynne@utkux.utk.edu> wrote:

+ This implies that Perl is not just for Unix system administrators
+ and hackers.

It isn't.

However, it still requires programming skills -- to analyze a problem,
think about where you're at, what you got, and where you want to go (today),
and then coming up with a plan to get there. And then implementing code 
that will accomplish your task. Ideally, in a clever and efficient 
manner, but not necessarily.

To claim otherwise is at best disingenious, and at worst, dishonest. Will
you also be telling us that marking up text with HTML is programming?

+ If you are not a professional teacher, don't teach.

I'm not a professional teacher, but I teach every day of my life. Are you
the teacher police? will you come and arrest me because I dare to share
my experience and expertise with other people in an informal setting?

Needless to say, I object strenously to your statement.

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: Sun, 29 Mar 1998 21:46:30 GMT
From: phenix@interpath.com (John Moreno)
Subject: Re: Problems with handling Mac/PC/Unix line breaks
Message-Id: <1d6nven.f84559jtw1f6N@roxboro0-058.dyn.interpath.net>

Robert Cassidy <rmcassid@uci.edu> wrote:

> Fairly newbie using MacPerl, but will likely have to deal with it on unix
> as well.
> 
> I'm trying to figure out how to deal with files that have, without prior
> knowledge, Mac/DOS/unix line breaks. The problem is that some of the files
> I deal with run into the tens and hundreds of megabytes so just grabbing
> the whole file and looking for \n or \r is a wee bit impractical. I can
> make some safe assumptions about how many characters before a break should
> occur, though. 

Read in enough for a break then check to see what is in the proper
position - a return or newline or a return AND newline.

But what kind of file are you running into that have this problem, the
only files I can think of which would have this type of problem is just
plain text files, and they hardly ever run to hundreds of megabytes.


-- 
John Moreno
I am trying to convince the author of YA-NewsWatcher that the latest
version should be released to the public.  He doesn't think there's much
interest in a new version.  Help me prove him wrong.  To do so, send me
mail <mailto:phenix@interpath.com> with a Subject of New YA.  Comments
on what you like/dislike in the current version will be appreciated.


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

Date: 29 Mar 1998 20:16:44 GMT
From: juergen@unicorn.noris.de (Juergen Heinzl)
Subject: Re: Redirect URL
Message-Id: <slrn6htb1c.hg.juergen@unicorn.noris.de>

In article <351C2605.4443F284@boothman.easynet.co.uk>, Andrew Boothman wrote:
>If you are using the CGI.pm module then you can simply use the 
>
>print $query->redirect('http://redirect.here')
>
>command.
>
>Otherwise, you'll have to find the proper HTTP commands for doing that
>sort of thing.

 ... easy ...
print "Location: http://www.nowhere.com.here\n\n";
 ... and this is really all needed.

Bye, Juergen

-- 
\ Real name     : Juergen Heinzl     \       no flames      /
 \ EMail Private : unicorn@noris.de   \ send money instead /
  \ Phone Private : +49 911-4501186    \                  /


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

Date: Sun, 29 Mar 1998 14:59:39 -0800
From: Franco Finstad <ffinstad@best.com>
Subject: Rotating HTML using Perl
Message-Id: <351ED257.FECFAB3B@best.com>

I'd would like to have different text displayed each time my homepage is
loaded. I need the text to be read from a text file that I'm constantly
updating. Is this possible using Perl?

Any help is appreciated.

Thanks
Franco Finstad



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

Date: 29 Mar 1998 15:16:41 -0600
From: Quentin  Fennessy <quentin@jihad.amd.com>
Subject: Re: Sysadmin struggeling with PERL/Sed and etc...
Message-Id: <ximd8f5tcxy.fsf@jihad.amd.com>

>>>>> "DCM" == David C McCall <cyberman@sonoma.edu> writes:

    DCM> I've got 2 files each with the same number of lines of text.
    DCM> I would like to merge these files line by line appending the
    DCM> 2nd files 1st line to the 1st files 1st line, and so on....to
    DCM> a 3rd file.....

Check out the paste program, provided with most (if not all) Unix systems.

>From SunOS5 paste(1):

DESCRIPTION
     The paste utility will concatenate the  corresponding  lines
     of  the  given input files, and write the resulting lines to
     standard output.

     The  default  operation  of  paste  will   concatenate   the
     corresponding lines of the input files.  The NEWLINE charac-
     ter of every line except the line from the last  input  file
     will be replaced with a TAB character.

The FSF also provides a version of paste.

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

Date: Mon, 30 Mar 1998 00:27:18 +0200
From: joergen.lang@schwaben.de (Joergen W. Lang)
Subject: Re: Sysadmin struggeling with PERL/Sed and etc...
Message-Id: <1d6ogri.p5o840z45ftwN@host053-206.seicom.net>

David C McCall <cyberman@sonoma.edu> writes:

> I've got 2 files each with the same number of lines of text.
> I would like to merge these files line by line appending the
> 2nd files 1st line to the 1st files 1st line, and so on....to
> a 3rd file.....

Do you like the Simpsons ?
Now you can do it with Marge ;-))

#!/usr/bin/perl -w

# marge.pl
# Author: Joergen W. Lang
# Date  : 03/30/98 (at least in my timezone)

$path_to_file_1 = "file_1";
$path_to_file_2 = "file_2";
$path_to_newfile = "newfile";

open FILE_1, $path_to_file_1 or die "Can't open $path_to_file_1: $!";
@file_1 = <FILE_1>;
close FILE_1;

open FILE_2, $path_to_file_2 or die "Can't open $path_to_file_2: $!";
@file_2 = <FILE_2>;
close FILE_2;

$i = 0;
for (@file_1) {
   push (@newfile, $_);
   push (@newfile, $file_2[$i]);
   $i++;
}

open NEWFILE, ">$path_to_newfile" or die "Can't open newfile: $!";
print NEWFILE @newfile;
close NEWFILE;

# Marge's End

HTH,

Joergen
-- 
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"
-------------------------------------------------------------------


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

Date: 30 Mar 1998 02:24:53 +0200
From: Zooko Journeyman <zooko@xs4all.nl>
Subject: The "Y2k-bugs-are-not-just-a-legacy-problem" FAQ
Message-Id: <6fmool$e0j$1@xs2.xs4all.nl>

[Greetings, Usenetters.  This is an article i've just hacked up
that i intend to send to reporters and publications when i read
that the year 2000 bug is caused by legacy programs.  I argue
that a "sizeable fraction" of y2k bugs were written in the 
1990's, and i attempt to start a trend of calling them "y2k 
bugs" instead of "The Y2k Bug" since there are many of them and
they come in many different flavors and they must be fixed 
individually.  All flames, compliments, comments, criticisms, 
questions and answers are welcome at "zooko@xs4all.nl".  --Z]



Dear Sir or Madam:


I am writing you in reference to a recent article of yours 
which propagated a common misperception about year 2000 bugs.


I am a professional software engineer, and my motivation in 
writing this correction is solely to help inform the public
about this very important issue.  Permission is granted to
reproduce, distribute, and use this article in any way.


It is often stated (even by knowledgeable engineers, analysts, 
and reporters) that year 2000 bugs are caused by programs 
written in the 1960's, 1970's and 1980's.  This misperception 
is dangerous, as it encourages people who depend only on modern
programs to think that they are not at risk.  In fact, year 
2000 bugs abound in programs from all eras, including programs 
written during the 1990's.


Examples:

JavaScript, JScript, Netscape Navigator, Netscape Communicator,
and Microsoft Internet Explorer suffer from y2k bugs 
themselves, and they also make it complicated for a programmer
to write y2k-safe code using those systems:

http://www.infoworld.com/cgi-bin/displayArchives.pl?97-t04-27.1.htm
http://www.zdnet.com/intweek/printhigh/31698/cs1316.html


American Megatrends was shipping its widely used PC BIOS 
software with year 2000 bugs until as late as July 1995 (or 
even later?  The web pages don't precisely state.):

http://www.amibios.com/support/2000.html


Award was shipping _its_ widely used PC BIOS software with year 
2000 bugs until as late as November 1996:

http://www.award.com/tech/biosfaqs.htm#yr2000


(I bought a brand new PC in June of 1997 and its BIOS had a 
year 2000 bug.)


A y2k bug was discovered in a BeOS application (BeOS was first 
made public in the second half of the 1990's):

http://ww2.altavista.digital.com/cgi-bin/news?msg@4@comp%2esys%2ebe%2eannounce


The popular AltaVista search engine uses 2-digit year fields to
constrain the dates of your search.  If there are any scripts 
out there which use AltaVista to e.g. find all articles on a 
certain topic posted during the last week, those scripts will 
break during the first week of the year 2000.

http://www.altavista.digital.com/cgi-bin/query?pg=aq



These are only a few examples.  Almost certainly there are 
millions of year 2000 bugs that remain undiagnosed or 
unreported, and by my estimate a sizable fraction of them were
written during the 1990's (since the majority of code currently
in use today was written during the 1990's).



You may well ask "Why the heck would someone writing code in 
the 1990's create a year 2000 bug?".  There are 3 reasons:


1.  Legacy data, legacy interfaces.  Often new programs are 
written, and the first task of these new programs is to read in
the data from the old programs that they are replacing.  This 
means that the new programs usually use the same data formats.
Also new programs are sometimes required to interoperate with 
old programs, which means that they often use the same data 
formats.


2.  It's just a bug, like all bugs.  All bugs appear stupid 
once they are identified, but when you are actually 
constructing a complex system, many a bug will be generated out
of misunderstandings or mistakes.  Year 2000 issues are not 
nearly as simple as the media tends to indicate.


For example, let's say that you are writing a program in 1997 
in a modern programming language such as JavaScript or Perl.  
You invoke the standard routine to return the current year.  It
returns "97".  Now you want to use this information for your 
own calculations, and export the information for the benefit of
the user of your program.  What should you do?  Leave it as 
2 digits?  Prepend the string "19" to the year?  Add the number
1900 to the year?  Do a check to see if the year is less than
50, and then add the number 1900 to it if it is greater than 50
and add the number 2000 to it in that case?


The answer varies depending on which language you are using, 
which _version_ of the language (in the case of JavaScript),
and what the users of your program expect to see.


3.  And perhaps most important: human/computer interface.  
Humans routinely use two digits to indicate a year.  Think back
to the last time you wrote a date onto a paper document or 
typed a date into a computer.  More than likely, you wrote 
"98".  When other humans read that number, they will use 
context to determine whether you meant 1898, 1998, 2098, or 98.


But computers are very bad at using context to make such 
distinctions.  All software has to interact with humans at some 
points, and almost all software which uses dates allows the 
humans to enter 2-digit dates.  It then has to infer somehow 
whether that date belongs in the 20th century or the 21st (or 
the 19th or others).  This decision is still a problem for 
programs written in 1998 as it was for programs written in 
1968.




I hope that this letter has been informative to you.  I am 
making a habit of sending this letter via e-mail to each 
publication or reporter who unwittingly propagates the "Y2k is
a legacy problem" myth.  Feel free to contact me for more 
information.


Regards,

Zooko, Journeyman Engineer

-------
mailto: zooko@xs4all.nl
http://www.xs4all.nl/~zooko/public.html



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

Date: Sun, 29 Mar 1998 21:09:58 GMT
From: trickett@pacbell.net.nospam (Adam)
Subject: Re: Use Perl to update Monolith server
Message-Id: <6fmdhc$dq5$2@nnrp2.snfc21.pbi.net>

In article <Pine.GSO.3.96.980329051421.3818Z-100000@user2.teleport.com>, Tom Phoenix <rootbeer@teleport.com> wrote:
>On Sun, 29 Mar 1998, Adam wrote:
>
>> all I need to know nowm is how to excecute one command:
>> 
>> http://members.ml.
>> org/mis-bin/ms3/nic/dyndns?
>> host=<me>&command=Update+Host&do=mod&domain=Fred-2&act=act&ipaddr=<current 
>> IP>&agree=agree
>
>I can't tell what that command is, but it sounds as if you simply need to
>implement the server's protocol.
>
>> From: Adam <trickett@pacbell.net.nospam>
>
>> E-mail suggestions appreciated.
>
>A valid e-mail address is appreciated. :-)

Remove the nospam, thus it becomes trickett at pacbell dot net, I've had just 
TOO much spam, to let my actual email address become valid and displayed on 
the newsgropups. MY ISP even recommends a human redable, but inncorrect and 
correctable email address. Sorry for any confusion this may have caused.

I found a Dynamic DNS update module to do this, but I can't open the tar file, 
my NT stuff claims it's invald. I can usually open these kinds of things, not 
not the one I found via the O'Riely Perl site - most frustrating.



---
 Adam  <trickett at pacbell dot net>

 Unsolicited e-mail will be charged a $10 proof reading
 fee - by replying to this posting you are agreeing to
 these terms and conditions.


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

Date: 29 Mar 1998 02:16:27 -0600
From: psamuels@sampo.REMOVETHIS.creighton.edu (Peter Samuelson)
Subject: Re: What does this one liner do?
Message-Id: <6fl00r$1b$1@sampo.creighton.edu>

      [Tom Phoenix <rootbeer@teleport.com>]
> > > > What would you like to know that isn't in the docs?
    [Tushar Samant <scribble@pobox.com>]
> > > What the select(2) system call does. What does it *mean* when you
> > > say any of the bitmasks can be undef. Is sleeping for 0.1 seconds
> > > the ONLY effect of the call.
  [rjk@coos.dartmouth.edu]
> > Which is, of course, in the documentation for the select(2) system call.
[Tushar Samant again]
> That's not Perl. And what's the first argument there for?

Perl has deep roots in libc and its system calls.  select(2) is a good
example.  I don't see why Perl docs should have to duplicate libc docs
and system call docs.

> > Any of readfds, writefds, and exceptfds may be given as NULL
> > pointers if no descriptors are of interest.
> Not in my man page.

Then perhaps your select(2) doesn't implement that behavior in quite
the same way.  This is the second problem (besides massive duplication
of effort) in precisely documenting all those libc calls: some things
might be system-dependent.  Perl shields us from an awful lot of
system-specific stuff (variable types, include files) but there's
probably a lot left -- especially if you have a weird or buggy libc.

And if your libc isn't documented very well, that's your vendor's
fault.  Small consolation, I know, but there it is.

> Also, and this may be way too personal a feeling, I do think it is
> absurd to cite page numbers of O'Reilly books.

That I agree with.  Just saying that something is in the Blue Camel
should be good enough -- page numbers are mostly noise and can even be
misleading if you happen to have a different edition.  That's what
indexes are for.

-- 
Peter Samuelson
<sampo.creighton.edu ! psamuels>


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

Date: Sun, 29 Mar 1998 14:54:35 -0800
From: Norman Katz <nkatz@cts.com>
Subject: what is cgi_auto_file?
Message-Id: <351ED12B.719A@cts.com>

I have perl5.003 installed on NT4 and I'm using IIS3.
My Script Map in the registry does not have an entry
for .cgi.  However, my .cgi scripts execute fine.
When I check file associations, cgi is associated with
"cgi_auto_file."  But, I can't find any references to this.
Any clues what this means and how my .cgi scripts are
actually executing?

Thanks,
Norm


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". 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 2205
**************************************

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