[6480] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 105 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 12 20:17:28 1997

Date: Wed, 12 Mar 97 17:00:19 -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           Wed, 12 Mar 1997     Volume: 8 Number: 105

Today's topics:
     Re: a tricky regex (Abigail)
     Re: All I want to do is subtract 180 days from a given  <rajeshg@ccwf.cc.utexas.edu>
     Re: BLAT Help (Stephen Frost)
     Re: Counter help me peez >:P <lorraine@ait.nrl.navy.mil>
     Re: Date conversion from server logs to time() format <rajeshg@ccwf.cc.utexas.edu>
     Re: Elegant way to strip spaces off the ^ and $ of a va (Abigail)
     Re: Elegant way to strip spaces off the ^ and $ of a va <jhi@alpha.hut.fi>
     First Beta Test Release of Perl 5.004 (Chip Salzenberg)
     Re: How do I get all more than 2 hours old files (Abigail)
     Integers <Lewellyn@ladyhawk.vip.best.com>
     Re: Interactive drawing alternatives in perl? (David Combs)
     LWP installation errors. Please help. <chapman@techctr.buddcompany.com>
     Re: Making ror to really Rotate Right (Steffen Beyer)
     Re: Perl FAQ part 8 of 0..9: System Interaction [Period <mpeppler@mbay.net>
     Please help with this Script. It's Cameron, not diane. <cooper15@hsonline.net>
     UP/DOWNloading from local system... (D. Ciesnik)
     Re: year 2000 question (Tad McClellan)
     Re: year 2000 question <tchrist@mox.perl.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 12 Mar 1997 20:35:51 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: a tricky regex
Message-Id: <E6y6Jr.Gs6@nonexistent.com>

On Wed, 12 Mar 1997 12:15:30 -0600, Bryan Hart wrote in comp.lang.perl.misc:
++ Sorry for asking such a question here, but I'm getting a bit stumped. 
++ I'm looking for a regex (or some other way) to remove whitespace from a
++ string EXCEPT when the whitespace is enclosed in quotes("").
++ 

Based on Removing C Comments in [1, p293]:

#!/usr/local/bin/perl -w
 
use Carp;
use strict;
 
 
sub remove_spaces ($) {
    local $_ = shift;
 
    s { (   [^"'\s]+
          | (?:"[^"\\]*(?:\\.[^"]*)*"[^"'\s]*)+
          | (?:'[^'\\]*(?:\\.[^"]*)*'[^"'\s]*)+
        )
        | \s+
      }{$1}gsx;
 
    $_;
}
 
 
my @examples = ( 'foo bar', '"foo bar"', 'foo bar" "foo bar',
                 'fo"o b"ar', 'f"o"o b"a"r', 'foo"" bar');
 
 
print join "\n", (map {remove_spaces $_;} @examples);
print "\n";
__END__

foobar
"foo bar"
foobar" "foobar
fo"o b"ar
f"o"ob"a"r
foo""bar


Abigail

[1] Jeffrey Friedl: "Mastering Regular Expressions."
    O'Reilly & Associates, Inc. (Ed. Andy Oram. Powerful
    Techniques for Perl and Other Tools) Sebastopol, 1997.
    [ISBN: 1-56592-257-3].



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

Date: Wed, 12 Mar 1997 17:56:30 -0600
From: Rajesh Gottlieb <rajeshg@ccwf.cc.utexas.edu>
To: Blake Swensen <blake@pbgi.com>
Subject: Re: All I want to do is subtract 180 days from a given date!
Message-Id: <Pine.GSO.3.96.970312175427.2238A-100000@piglet.cc.utexas.edu>


Here's a nudge from me. Just run it and see what it does.

Raj

#!/usr/local/bin/perl -w
# this program outputs the current date and then just for the heck of it
# asks you to enter the number of days you want to subtract from the
# current date and prints what the date would have been then.
 
 
sub dateout {  # outputs the date in a format similar to `date`
   my ($currentTime) = @_;
   my ($sec,$min,$hour,$mday,$mon,$year,$wday,
       $yday,$isdst,$thisday,$thismonth,$thisyear);
 
   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime($currentTime);
   $thisday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$wday];
   $thismonth = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon];
   $thisyear = $year+1900;
   print("$thisday $thismonth $mday $hour:$min:$sec $thisyear\n");
}
 
#main()
$currentTime = time();
dateout($currentTime);
print "Enter the number of days you want to subtract: ";
$subdays = <STDIN>;
$pastTime = $currentTime - $subdays*86400; # there are 86400 seconds in a
day :)
dateout($pastTime);

> Really... thats all.  User inputs a date, and gets a date 180..0 days earlier. 
>  
> 
> I have surfed, searched, read FAQs, downloaded, copied, hacked.  Can some kind 
> soul give me the necessary nudge. 
> 
> Blake
> 
> 



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

Date: 13 Mar 1997 00:06:25 GMT
From: frostbyt@shell01.ozemail.com.au (Stephen Frost)
Subject: Re: BLAT Help
Message-Id: <5g7ge1$e7i@reader1.reader.news.ozemail.net>

Nathan V. Patwardhan (nvp@shore.net) wrote:
: Jeremy Coulter (vss@xtra.co.nz) wrote:

: : Also, I am running IMAIL Mail Server. Does BLAT send the message to
: : the Mail Server ?

: BLAT talks to the smtp (mail) server, yes.  If I understand correctly,
: you pass BLAT command-line arguments and redirect a file to it on STDIN,
: which means that you need to write everything to a file, first, then mail
: the file using BLAT (blech!).

You can write directly to BLAT like this:

#
# Redirect STDOUT > NULL temporarily
#
open(SAVEOUT, ">&STDOUT");
open(STDOUT, ">NUL");
select(STDOUT);
$| = 1;

#
# Send mail via BLAT
#
open (BLAT, "| $blat - -t $recipient -i $from -s \"$subject\"");
print BLAT "Please note the following comments on our Web service:\n\n";
 ... etc etc ...
print BLAT "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
print BLAT "Remote host: $ENV{'REMOTE_HOST'}\n";
print BLAT "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
print BLAT "\cZ";
close(BLAT);

#
# Reset standard STDOUT
#
close(STDOUT);
open(STDOUT, ">&SAVEOUT");
select(STDOUT);
$| = 1;

I redirect STDOUT to prevent BLAT from displaying unwanted stuff
into the browser...

Hope this helps.

Steve
--
********************************************************************
Steve Frost                      Steve Frost          PGP Public Key
Frostbyte Computer Consultants   OzEmail Limited      available from
Melbourne, Australia             Sydney, Australia    my web site.
--------------------------------------------------------------------
http://www.frostbyte.com.au     "I want to stay angry at the evil,
steve.frost@frostbyte.com.au     I want to be hungry for the truth."


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

Date: Wed, 12 Mar 1997 16:56:03 -0500
From: Brian Lorraine <lorraine@ait.nrl.navy.mil>
Subject: Re: Counter help me peez >:P
Message-Id: <33272673.2781@ait.nrl.navy.mil>

ops i realize there were a cuple of mistakes in that previous script,
but the follwing corrected script still has the same problem:
###########################
#!/usr/bin/perl

open (COUNTFILE, "testct") || print "Can't open the
file\n";                
$numero = <COUNTFILE>;                     
chop ($numero);

print "Content type: text/html\n\n";

print "You are visitor number $numero\n";

$numeronext = $numero + 1;              
print (COUNTFILE "$numeronext\n");         
close (COUNTFILE);
###########################

rather odd. I've got another program with similar syntax that writes to
a .dat file and that works just fine... hmmm maybe it has to do with the
fact that the data from this file has numeric value? That's the only
thing that I can think of that might be a problem... anyhoo.. can anyone
help? 

thanx,
    -Brian "the BrAiN" Lorraine-


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

Date: Wed, 12 Mar 1997 18:04:30 -0600
From: Rajesh Gottlieb <rajeshg@ccwf.cc.utexas.edu>
To: Ross Carlson <webmaster@gmom.com>
Subject: Re: Date conversion from server logs to time() format
Message-Id: <Pine.GSO.3.96.970312180052.2238B-100000@piglet.cc.utexas.edu>



> I am trying to find some perl routines that will take the date format
> found in the web server common log format, and convert it into the
> integer format returned by time(). Can anyone point me in the right
> direction?

#!/usr/local/bin/perl -w
 
# output of time()
$currentTime = time();
print "$currentTime\n";
 
# convert output of time() into type much like struct tm in C
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($currentTime);
$thisday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$wday];
$thismonth = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon];
$thisyear = $year+1900;
print("$thisday $thismonth $mday $hour:$min:$sec $thisyear\n");
 
# convert struct tm stuff back into scalar given by time()
use Time::Local;
$currentTime = timelocal($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
print "$currentTime\n";

#####

All you gotta do now is parse your logs and get the right values into 
the format that timelocal() likes.

raj



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

Date: Wed, 12 Mar 1997 20:12:25 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <E6y5Gp.218@nonexistent.com>

On 12 Mar 1997 10:06:02 -0800, Sherman Hsieh wrote in comp.lang.perl.misc:
++ Hi all,
++ 	I couldn't come up with an elegant way to strip off spaces
++ (newline, tab or whatever) of a string. Does anyone have a good solution
++ to this.
++ 
++ Example:
++ 
++ $variable = "	 jklsd jslkjsd   ";
++ 
++ I want to strip off all the spaces before and after the string above so
++ the resulting string should look like:
++ 
++ $variable = "jklsd jslkjsd";
++ 

Elegant you said... Here's a way without using ()'s in the
regex, or having to type the variable twice. And it's easy to
add more variables.

map {s/^\s+//; s/\s+$//;} $variable;



Abigail



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

Date: 12 Mar 1997 23:12:34 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <oeezpw8g6gt.fsf@alpha.hut.fi>


: How about this:
: 
: $variable =~ s/^\s*//;
: $variable =~ s/\s*$//;
: 
: I've always been slightly irked that you can't do this in one pass,
: but it's still pretty darn simple and elegant.

Says who?

$x = ' foo bar  zot    ';
$x =~ s/^\s+|\s+$//g;
print "x = '$x'\n";

Note also the +, not *. It is faster that way.

-- 
$jhi++;
# Jarkko Hietaniemi <URL:http://www.iki.fi/~jhi/> <URL:mailto:jhi@iki.fi>
# Lost interest?  It's so bad I've lost apathy.
# Not speaking for any past, present, or future employers.


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

Date: 12 Mar 1997 23:38:49 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: First Beta Test Release of Perl 5.004
Message-Id: <5g7eq9$msc$1@nadine.teleport.com>

The Perl development team is pleased to announce the first beta test
release of Perl 5.004.  (Please note the word "test".)  For version
control purposes, this release is called "Perl 5.003_93"; when built,
its binary is called "perl5.00393".

You should be able to install and use this release of Perl under almost
all families, mutations, and imitations of UNIX, as well as VMS, OS/2,
QNX, LynxOS, AmigaOS, and Plan 9.  (In the second beta there will be
support for compiling Perl with Microsoft Visual C++ under Windows NT
and Windows 95, but this support is not ready yet.)  Patches to support
other systems are welcome but probably will not be folded into the 5.004
release.

It is *vital* that you read the file "INSTALL" before building this
release; it contains information you absolutely need to know.  For
example, "INSTALL" explains how you can install this beta of Perl 5.004
without removing previous version(s) of Perl, and how you can make Perl
5.004 binary-compatible with Perl 5.003 (and why you have a choice).

There are several new functions and features in Perl 5.004, including a
small number of unavoidable incompatibilies.  See the change notices for
details, in the file "pod/perldelta.pod".  It is *highly* recommended
that you read "pod/perldelta.pod" before using this release if you have
any previous experience with Perl.

We believe that there are no major bugs remaining in this release.
Nevertheless, a good programmer knows that there is always one more bug.
Therefore, we encourage those of you who can do so to try this release
and report all bugs and difficulties, so that we can fix them before the
final release.  In other words, we *want* you to find bugs!

If you do find a bug, please report it to us with the "perlbug" script
in the "utils" directory of the distribution.  Since you may have older
versions of "perlbug" installed, run it as "./perl utils/perlbug"; to
display its documentation, use the "-h" flag.  If you cannot send
external E-Mail from your development platform, or if you use VMS (where
this release's version of "perlbug" has a bug; how ironic), you can
still use "perlbug" to prepare the bug report and save it to a file,
which you should then mail to <perlbug@perl.com>.

If Perl didn't even compile, then you won't be able to use "perlbug".
Instead, compose your bug report by hand, being sure to include the
output of the "myconfig" shell script included in the distribution, and
mail it to <perlbug@perl.com>.

We re-emphasize: *Please* read "INSTALL" and "pod/perldelta.pod".  We
are happy to answer questions, but our time is limited.  By reading the
excellent documentation included with Perl before asking for help, you
will save yourself time, you will save us time, and you will help us
debug the documentation.

You will find this release on CPAN, the Comprehensive Perl Archive
Network.  The following URL at Tom Christiansen's web server (perl.com)
will automatically direct your request to a CPAN FTP site appropriate
for your location:

    http://www.perl.com/CPAN/src/5.0/unsupported/perl5.003_93.tar.gz

If you wish to retrieve the file entirely with HTTP, you can use this
URL at The Perl Institute (perl.org):

    http://www.perl.org/CPAN/src/5.0/unsupported/perl5.003_93.tar.gz

Finally, to quote Douglas Adams: "Share and enjoy!"

	Signed,

	The Perl Development Team

-- -- 
Chip Salzenberg          - a.k.a. -          <chip@atlantic.net>
 "Vacation time.  Families travel east, west, north, or south."
 "Some just burrow straight down." -- Crow T. Robot   // MST3K




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

Date: Wed, 12 Mar 1997 20:44:42 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: How do I get all more than 2 hours old files
Message-Id: <E6y6yJ.MFM@nonexistent.com>

On Wed, 12 Mar 1997 09:16:59 -0800, Ronak Bhatt wrote in comp.lang.perl.misc:
++ Hi,
++ 
++ How would I get the filenames, that were created before two hours ( when
++ the script is run).
++ 

At least under Unix, you can't. Last modification, access and inode
change time are stored, creation time isn't. And the modification
time can easily be *before* the creation time (for instance, see
what happens when you untar a file.)


If you want the files not modified for two hours in the current
directory:

my @files = grep {-M > 1/12;} <*>;



Abigail



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

Date: Wed, 12 Mar 1997 14:52:38 -0800
From: Lewellyn <Lewellyn@ladyhawk.vip.best.com>
Subject: Integers
Message-Id: <Pine.SGI.3.95.970312144216.29688A-100000@shellx.best.com>

Okay, I give up. I have tried the man pages and everything else available to
me but here, so here goes:

How do I convert a decimal number read from <STDIN> to an integer? (Also, how
can I verify input was numeric???) I'm sure I had this figured out one time
when I didn't actually need it... :(

Any help would be appreciated... (BTW, I'm using Perl 5 and have 4 available,
if for whatever reason 4 is easier.)

Please send copies of all emails <g> regarding this to my personal emailbox,
if
posted to the newsgroup, as my reader seems to be flaky. (Or, maybe it's the
server.)


TNXE6,

Lewellyn

=-=-=-=
"I do not profess to have accumulated knowledge greater than my years."
	--Lewellyn
=-=-=-=



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

Date: Wed, 12 Mar 1997 23:54:11 GMT
From: dkcombs@netcom.com (David Combs)
Subject: Re: Interactive drawing alternatives in perl?
Message-Id: <dkcombsE6yFqB.7Dr@netcom.com>

In article <E6xE06.J8o@ciba-geigy.ch>,
David M Holmes <david.holmes@bigfoot.com> wrote:
>In article <Pine.SOL.3.91.970307105124.26219B-100000@Helios.goldworks.com>, 
>Serge Kolgan <skolgan@Helios.goldworks.com> wrote:
>>On Fri, 7 Mar 1997, Clay Irving wrote:
>>
>>> Take a peek at the "Graphics" section of Perl Reference:
>>>    http://www.panix.com/~clay/perl/query.cgi?graphics+index
>>
>>this is all great, but not a single module/package mentioned in URL above
>>supports *interactive* drawing, that is: select primitive (click), draw 
>>primitive (click), modify... (click-click-click) :)
>
>Interesting that you should mention this.  I've been seriously thinking 
>about writing such a thing for my final year degree project.
>
>I'm intending to utilise perltk, the OpenGL module perhaps, and the 'PDF 
>on the Fly' module from the University of Nottingham, for final output.
>It would be a vector based drawing package.
>
>I'm going to use the PDF module because it is to be used primarily for 
>creating Origami folding diagrams.
>

By the way, I have asked for and received, for GNU,
the nifty drawing program LEONARDO, defunct some years ago.

Was originally written for sun sunview.

All ("all") that is needed is for someone to TRANSLATE it
to X or something.

The benefit of it is that it has only a ten line .ps "prolog";
all drawings are done via gillions of tiny straight lines.

But it is WONDERFUL for inclusion of graphs (.ps only) etc
in tex documents, troff, etc, because of the TINY TINY overhead
(almost non-existent prolog), ie for being included thousands
of times for small graphic thingies.

Nifty package: isometric and the other variations on that,
postscript "levels", etc.

We (well, Stallman at gnu) awaits only someone to DO the
job.

Would be a WONDERFUL addition to fsf CD!

Contact me if interested in doing it.

  David Combs   dkcombs@netcom.com




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

Date: Wed, 12 Mar 1997 15:48:41 -0500
From: Harold Todd Chapman <chapman@techctr.buddcompany.com>
Subject: LWP installation errors. Please help.
Message-Id: <332716A9.41C6@techctr.buddcompany.com>

I successfully instaled:

perl 5.003
IO-1.15
MD5-1.7
libnet-1.04

all so I could use libwww-perl-5.07 but the following errors were
produced from: make install

somewhere.com# make install
        /usr/local/bin/perl -e 'use Config; chdir q{./blib/script};
foreach (qw(
GET HEAD POST)) {' \
        -e 'unlink "$_";' \
        -e 'system("$Config{\"lns\"} lwp-request $_") && die; }'
lwp-request and GET are identical
Died at -e line 3.
*** Error code 13 (bu21)

Any suggestions? The 'perl Makefile.PL', 'make', and 'make test' were
error free.

Thanks.
-Harold Chapman <chapman@techctr.buddcompany.com>


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

Date: 12 Mar 1997 19:57:36 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: Making ror to really Rotate Right
Message-Id: <5g71rg$eip$1@en1.engelschall.com>

Bekman Stanislav <sbekman@iil.intel.com> wrote:

> I need to do a simple ror (Rotate Right) function
> But not the way perl implement it. ror throws out the shifted bits
> and I need to push them from the left side. That's why it's called
> rotate and no shift. 

> Is there any ready implementation.
> I'm trying to do it my self

> But first I'm in trouble to count the number of bits my code:
> 	# count the lenth of the number 
>   $bits=log($sum)/log(2);                 
> 	# Upper rounding
>   ($bits/int($bits) != 1) && ($bits=int($bits)+1);    

> But sometimes this code mistakes in 1 bit ???

> The function to rotate one bit right:
> sub rotr(){
>   local($num)=@_;
>   local($left,$right);

> # Handle the zero case
>   ($num==0 || $num==1) && (return $num);      
>                 
>   $left = $num << ($bits-1);    # Rotate the number to the left
>   $right = $num >> 1;           # Rotate the number to the right
>    
>     $num = $right+$left;	# Add the 2 parts
>     $num = $num & (2**$bits-1) ;# Take the original number of bits

> return $num;
> }

> So it works for some numbers and doesn't for the other

> Any ideas?
> Thanks

I think the best idea is to write a C function with a XS wrapper around
it so you can call it from Perl.

Yours,
--
    |s  |d &|m  |    Steffen Beyer <sb@sdm.de> (+49 89) 63812-244 fax -150
    |   |   |   |    software design & management GmbH & Co. KG
    |   |   |   |    Thomas-Dehler-Str. 27, 81737 Munich, Germany.
                     "There is enough for the need of everyone in this world,
                     but not for the greed of everyone." - Mahatma Gandhi


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

Date: Wed, 12 Mar 1997 15:04:08 -0800
From: Michael Peppler <mpeppler@mbay.net>
To: Stefan Monnier <monnier@cs.yale.edu>
Subject: Re: Perl FAQ part 8 of 0..9: System Interaction [Periodic Posting]
Message-Id: <33273668.4AA1@mbay.net>

Stefan Monnier wrote:
> 
> Tom Christiansen <tchrist@mox.perl.com> writes:
> > =head2 How do I keep my own module/library directory?
> >
> > When you build modules, use the PREFIX option when generating
> > Makefiles:
> >
> >     perl Makefile.PL PREFIX=/u/mydir/perl
> >
> > then either set the PERL5LIB environment variable before you run
> > scripts that use the modules/libraries (see L<perlrun>) or say
> >
> >     use lib '/u/mydir/perl';
> >
> > See Perl's L<lib> for more information.
> 
> Reminds me of a question:
> where should dynamically linked modules be put ?
> I created a /usr/local/lib/perl5 dir where I keep my perl modules, but if I set
> my PERL5LIB to /usr/local/lib/perl5, only /usr/local/lib/perl5 and
> /usr/local/lib/perl5/auto are searched for .so files, whereas I would much
> prefer to put the .so files at their "natural" place (in my case
> /usr/local/lib/perl5/i386-linux/5.003) but this requires me to add
> /usr/local/lib/perl5/i386-linux/5.003 to my PERL5LIB path, which seems ugly to
> me. What is the "normal" solution ?

If you use MakeMaker then everything is handled for you.

And the files end up in .../lib/perl5/site_perl, site_perl/{arch}/auto
and site_perl/auto, which is the *right thing*

Michael
--
Michael Peppler, Data Migrations Inc.
mpeppler@mbay.net or mpeppler@bix.com



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

Date: 12 Mar 97 21:38:42 GMT
From: dianne  cooper <cooper15@hsonline.net>
Subject: Please help with this Script. It's Cameron, not diane.
Message-Id: <33272262.0@news.hsonline.net>

Could somebody please help me with this portion of a script and tell me
what part of it is for UNIX only. I wan to to get to work on a Windows95
OS. If you could, please tell me what I could do to change it. If this is 
an impossible question, or I couldn't do it without rewriting it then don't
kill yourselves trying to fighure the answer out. I downloaded the script,
And I'm just now trying to learn Perl. 

*************************************************************

    $fields = 5;                       # Number of fields in each record
    $filename = "search.txt";      # The database text file
    $results = 1000;               # maximum number of results to display

    &parse_form;
    
    $searchstring = $FORM{'searchstring'};

    &addrecord if ($searchstring eq "**ADD RECORD**");


    &open_file("FILE1","",$filename);

    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print "<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF VLINK=#800040 ALINK=#800040>\n";
    print "<TITLE>PageDesigns Search Results</TITLE>\n";
    print "<CENTER><BR>\n";
    print "<FONT SIZE=5 COLOR=000000 FACE=\"ARIAL,TIMES NEW ROMAN\">Search Results</FONT></CENTER>\n";

    print "<HR width=80% noshade><BR><UL>\n";
    $counter = 0;

    while (($line = &read_file("FILE1")) && ($counter < $results)) {
         # split the fields at the | character     
         @tabledata = split(/\s*\|\s*/,$line ,$fields);
          &check_record;
          if ($found == 1) {
            $counter++;
            &print_record;
          }

    }
    close(FILE1);
    print "</UL>\n";

    if ($counter == 0) {
       print "<BR><B> Sorry, We Did Not Find Yor Request</B>\n";
    }
    
    
    print "<CENTER>\n";
    print "<HR width=80% noshade>\n";
    print "<FONT SIZE=3 COLOR=000000 FACE=\"ARIAL,TIMES NEW ROMAN\">Click <A HREF="/index.html">Here</A> To Return To OurHhomepage</FONT></CENTER>\n";
    print "</CENTER>\n";
    print "</A></BODY></HTML>\n";



#########################################
#
#  Print the matched record
#
#########################################
sub print_record {
       print "<BR>\n";
       print "<LI><A HREF=" . $linkurl . ">" . $linktitle . "</A>  : $linkdescrip</B><BR>\n";    
}


##########################################
#
#  Check to see if record matches search criteria
#
##########################################
sub check_record {
    # get the data from the record read from the file. $tabledata

   $linktitle = $tabledata[0];
   $linkdescrip = $tabledata[1];
   $linkwords = $tabledata[2];
   $linemail   = $tabledata[3];
   $linkurl   = $tabledata[4];
   chop($linkurl);

    #build the search line with all fields we want to search in
    $searchline = $linktitle . " " . $linkdescrip . " " . $linkwords;


   #search by keywords
   # only perform the keyword search if the length of the search string is greater than 2
   # don't think we want people to search for and  or or etc.
   $sfound = 0;
   $found = 0;
   $notfound = 1; 

   $stlen = length($searchstring);
   if ($stlen > 1) {
       @words = split(/ +/,$searchstring);
        foreach $aword (@words) {
           if ($searchline =~ /\b$aword/i) {
                  $sfound = 1;
           } 
           else {
                  $notfound = 0;
            }
         }
     }
    if ($sfound == 1 && $notfound == 1) {
        $found = 1;
     }

    # if search string is too small .. set found to 1
    if ($stlen <= 1) {
        $found = 1;
    }
    #if page doesn't have a title then return not found
    $tlen = length($linktitle);
    if ($tlen < 1) {
        $found = 0;
    }
}


############################################
#
#  Add Record
#
############################################

sub addrecord {

  $linktitle    = $FORM{'linktitle'};
  $linkdescrip    = $FORM{'linkdescrip'};
  $linkwords    = $FORM{'linkwords'};
  $linkemail   = $FORM{'linkemail'};
  $linkurl = $FORM{'linkurl'};

  # Convert < tags to &lt;
  $linktitle =~ s/</\&lt;/g;
  $linkdescrip =~ s/</\&lt;/g;
  $linkwords =~ s/</\&lt;/g;
  $linkemail =~ s/</\&lt;/g;
  $linkurl =~ s/</\&lt;/g;


  
  &open_file("FILE1",">>",$filename);

  &write_file("FILE1",$linktitle . "|". $linkdescrip. "|" .$linkwords ."|" .$linkemail ."|" .$linkurl ."\n");
   close(FILE1);
   print "Content-type: text/html\n\n";
   print "<html><head><title>Thank You</title></head>\n";
   print "<body><BR><h3><CENTER>Thank You For Adding to our database</CENTER></h3>\n";
   print "</body></html>\n";
   exit;
}











sub parse_form {

   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
   if (length($buffer) < 5) {
         $buffer = $ENV{QUERY_STRING};
    }
 
  @pairs = split(/&/, $buffer);
   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);

      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $FORM{$name} = $value;
   }
}



sub open_file {

  local ($filevar, $filemode, $filename) = @_;
  
  open ($filevar,$filemode . $filename) ||
     die ("Can't open $filename");
}

sub read_file {

  local ($filevar) = @_;

  <$filevar>;  
}

sub write_file {

  local ($filevar, $line) = @_;

  print $filevar ($line);
}


**************************************************************

Thanks for your time!

Cameron Cooper,
Cooper15@hsonline.net


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

Date: 12 Mar 1997 23:38:46 GMT
From: ciesnik@ucsub.Colorado.EDU (D. Ciesnik)
Subject: UP/DOWNloading from local system...
Message-Id: <5g7eq6$agr@lace.colorado.edu>

Hi everyone,

Does anyone have or know of a place where I can look at a sample perl code
which allows a user to access, let's say my web page, and from there
upload files from his/her local system to my web server, or from my web
server download files to his/her local system?  Does this seem overly
complicated?  Thanks for any assistance!
			-Dave
_
www:ucsub.colorado.edu/~ciesnik
e-mail:ciesnik@ucsub.colorado.edu


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

Date: Wed, 12 Mar 1997 12:44:30 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: year 2000 question
Message-Id: <eit6g5.q33.ln@localhost>

Dan Ellsweig (Enterprise Management) (dxe@cassidy.sbi.com) wrote:

: Greetings

: I am in the process of insuring year 2000 compliance for all of
: my PERL code. I have a question regarding the 'localtime()' library
: function.

: Does anyone know of a version of PERL which will support
: 4 character year as returned by localtime()?? Currently
: the localtime function calculates the correct year then it
: subtracts 100 from the year before returning the year value
: in the localtime array. The result is a 2 character year (99 for 1999 or
: 00 for 2000). 


localtime() (and all of Unix, BTW) have a "year 2037" problem.

If you will be able to retire before then, then you won't need
to worry about it  ;-)

-----

c.l.p.m is NOT a free research tool you know. You are expected to
spend some small amount of time _yourself_ before expecting us
to spend _our_ time on _your_ problem.


I did **3 minutes** of research:


1)
http://www.dejanews.com/forms/dnsetfilter.html

2)
set group to comp.lang.perl.misc

3)
search for "year 2000"

4)
read the 78 hits found!!

One of which is this from the new perl FAQ (part 4):


------------
=head2 Does Perl have a year 2000 problem?

Not unless you use Perl to create one. The date and time functions
supplied with perl (gmtime and localtime) supply adequate information
to determine the year well beyond 2000 (2038 is when trouble strikes).
The year returned by these functions when used in an array context is
the year minus 1900. For years between 1910 and 1999 this I<happens>
to be a 2-digit decimal number. To avoid the year 2000 problem simply
do not treat the year as a 2-digit number.  It isn't.

When gmtime() and localtime() are used in a scalar context they return
a timestamp string that contains a fully-expanded year.  For example,
C<$timestamp = gmtime(1005613200)> sets $timestamp to "Tue Nov 13 01:00:00
2001".  There's no year 2000 problem here.
------------


Duh.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 12 Mar 1997 23:28:08 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: year 2000 question
Message-Id: <5g7e68$qs4$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    dxe@cassidy.sbi.com (Dan Ellsweig (Enterprise Management)) writes:
:I am in the process of insuring year 2000 compliance for all of
:my PERL code. 

I suspect that you're ensuring its compliance.  If you were insuring it, 
you'd be paying premiums.

:I have a question regarding the 'localtime()' library
:function.
:
:Does anyone know of a version of PERL which will support
:4 character year as returned by localtime()?? Currently
:the localtime function calculates the correct year then it
:subtracts 100 from the year before returning the year value
:in the localtime array. The result is a 2 character year (99 for 1999 or
:00 for 2000). 

You didn't read the docs on localtime.  Please do so.

Meanwhile, here's an entry from the new perl faq:

    =head2 Does Perl have a year 2000 problem?

    Not unless you use Perl to create one. The date and time functions
    supplied with perl (gmtime and localtime) supply adequate information
    to determine the year well beyond 2000 (2038 is when trouble strikes).
    The year returned by these functions when used in an array context is
    the year minus 1900. For years between 1910 and 1999 this I<happens>
    to be a 2-digit decimal number. To avoid the year 2000 problem simply
    do not treat the year as a 2-digit number.  It isn't.

    When gmtime() and localtime() are used in a scalar context they
    return a timestamp string that contains a fully-expanded year.
    For example, C<$timestamp = gmtime(1005613200)> sets $timestamp to
    "Tue Nov 13 01:00:00 2001".  There's no year 2000 problem here.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


			Brain fried --Core dumped


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

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

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