[16059] in Perl-Users-Digest
Perl-Users Digest, Issue: 3471 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 24 09:13:05 2000
Date: Sat, 24 Jun 2000 06:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <961851908-v9-i3471@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 24 Jun 2000 Volume: 9 Number: 3471
Today's topics:
'each' problem in DESTORY on a tied hash <jdb@wcoil.com>
ANNOUNCE: Date::Calc 5.0 release candidate <sb@muccpu1.muc.sdm.de>
Re: cgi/SSI question... <flavell@mail.cern.ch>
Re: Creating a cause from information. (Tad McClellan)
Re: delaying Sendmail command nobull@mail.com
Re: deleting mutiple files? nobull@mail.com
Re: Dereferencing a two dimensional array? (Tad McClellan)
Re: Forcing unbuffered stdout from command line? nobull@mail.com
Re: Help - Brain Teaser (Tad McClellan)
Re: Help with s/ //g and s// /g (M.J.T. Guy)
how to get part of a large html file <hk22@371.net>
Re: OpenFile then Chomp <lilleyb001@hawaii.rr.com>
Re: OpenFile then Chomp <richh@panola.com>
Re: OpenFile then Chomp <bernie@fantasyfarm.com>
oracle DB connection <hanbit@tng.co.kr>
Re: oracle DB connection <nnickee@nnickee.com>
Re: Quick "Perl Way" solution needed <godzilla@stomp.stomp.tokyo>
Redirecting <six4eight@NOSPAMhotmail.com>
Re: Reg Expression Question (Tad McClellan)
Re: regex engin's undocumented behaviour? (Tad McClellan)
Re: Running Perl CGI Scripts <miles@explorer.demon.co.uk>
Re: sending emails from perl script nobull@mail.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Jun 2000 08:29:03 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: 'each' problem in DESTORY on a tied hash
Message-Id: <8j1rgf$p2u$0@206.230.71.43>
Greetings Perlfolk,
I have a slight problem which is causing a big roadblock in the development
of what I thought to be a very simple module. Below is a snippet of the
offending code. The problem is at the ##### (1) ## marker, below. It seems
that the each statment is not finding any keys in the said hash. Yet, there
are keys in it and I have tested it using the each statment on the tied
variable. See the complete listing to see example (only 220 lines) and to
see context for below code snippet at
http://www.josiah.countystart.com/db.txt
Please let me know of anything you can find.
Also, would it be too much to ask if you could reply to my email address,
which is jdb@wcoil.com, as I don't read CLPM as much as I check my email.
I thankyou in advance for any help anybody can provide!
--
Josiah Bryan
VP of Product Development
TDCJ, Inc.
"Anything is possible."
vp@tdcj.com
http://www.josiah.countystart.com/
Tel: 937.316.6256
Code Snippet:
####################################
sub DESTROY
out &whowasi;
my $self = shift;
out " : dieing : ";
my $file = $self->{FILE};
my $success = unlink($file);
carp "@{[&whowasi]}: can't unlink $file: $!" unless $success;
open(F, "> $file") || croak "can't open $file: $!";
flock(F, 2) if ($LOCK);
my ($a,$b);
while (($a,$b) = each %{ $self->{TABLENAMES} }) {
next if(!$a);
out " : table: $a : ";
print F "$a=//\n";
my ($x,$y);
while (($x,$y) = each %{ $self->{TABLES}->{$a} }) { #####
(1) ## Is somthing wrong with this line?
out " : x:$x : y:$y : ";
############ This is never seen
print F e($x).'='.e($y);
############ This is never executed
}
}
flock(F, 8) if ($LOCK);
close(F);
}
#####################
------------------------------
Date: 24 Jun 2000 09:04:34 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: ANNOUNCE: Date::Calc 5.0 release candidate
Message-Id: <8j1tj2$99b$1@solti3.sdm.de>
====================================
Package "Date::Calc" Version 5.0
====================================
- RELEASE CANDIDATE -
This package is available for download from my web site at
http://www.engelschall.com/u/sb/download/
Prerequisites:
--------------
Perl version 5.000 or higher, and an ANSI C compiler (!)
^^^^^^
What's new in version 5.0:
--------------------------
+ Added the new functions "check_time()", "Delta_YMD()",
"Delta_YMDHMS()" and "Add_Delta_YMDHMS()" to Date::Calc.
+ Added the module Date::Object, an object-oriented
frontend to Date::Calc with overloaded operators.
+ Added the module Carp::Clan (used by Date::Object).
+ Added support for Norwegian.
+ Added support for Swedish.
+ Added support for Danish.
+ Added support for Finnish.
+ Fixed the broken parsing of special ISO-Latin-1 characters
in Date::Calc (replaced <ctype.h> with better solution).
- Locales wouldn't help here, because "Decode_Language()" must
work with any locale setting. Moreover, setting a language in
Date::Calc would also require to set the proper corresponding
locale in the current environment, which may not be available
on the current system. The new solution works independently
of any locale and with ALL languages.
+ Fixed the misspelled word "whether" in the documentation.
+ Added a missing "#include <stdio.h>" statement in DateCalc.c
(apparently only relevant to very few platforms).
+ Added a patch which should ensure compatibility with VMS
(this should resolve the problem of too long identifiers).
+ Changed the function "Add_Delta_YMD()" to have a more consistent
(and reversible) behaviour. This might break existing code, though.
+ Changed the corresponding test script (t/f029.t) accordingly.
Abstract:
---------
The Date::Calc package consists of a C library and a Perl module
(which uses the C library, internally) for all kinds of date
calculations based on the Gregorian calendar (the one used in
all western countries today), thereby complying with all relevant
norms and standards: ISO/R 2015-1971, DIN 1355 and, to some extent,
ISO 8601 (where applicable). The package is designed as an efficient
toolbox, not a bulky ready-made application. It provides extensive
documentation and examples of use, multi-language support and
special functions for business needs.
The C library is specifically designed so that it can be used
stand-alone, without Perl.
Moreover, version 5.0 features a new OO frontend module with
overloaded operators for maximum ease of use (Perl only).
Legal issues:
-------------
This package with all its parts is
Copyright (c) 1995 - 2000 by Steffen Beyer.
All rights reserved.
This package is free software; you can redistribute it and/or
modify it under the same terms as Perl itself, i.e., under the
terms of the "Artistic License" or the "GNU General Public License".
The C library at the core of this Perl module can additionally
be redistributed and/or modified under the terms of the
"GNU Library General Public License".
Please refer to the files "Artistic.txt", "GNU_GPL.txt" and
"GNU_LGPL.txt" in this distribution for details!
Author's note:
--------------
This is a release candidate.
Please report any bugs or ugly things you find!
Suggestions are welcome!
I hope you will find this new version beneficial!
Yours sincerely,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
------------------------------
Date: Sat, 24 Jun 2000 12:38:59 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: cgi/SSI question...
Message-Id: <Pine.GHP.4.21.0006241235190.13905-100000@hpplus03.cern.ch>
On Fri, 23 Jun 2000, Rich H added another specimen of upside-down
posting to the Usenet Hall of Shame with this:
> If <!--#include virtual="/cgi-bin/whatever.cgi" --> doesn't work, try
> <!--#exec cgi="/cgi-bin/whatever.cgi" -->
SSI is not standardised, so don't just "try this" at random - consult
the SSI documentation for the http server that you use, and then seek
advice on a group where it is on-topic.
> > Before you buy.
Er, no thanks.
--
"Mir ist es ein Rätsel wie man mit minimalem Verstand so einen
Unfug fabrizieren kann." - Adrian Knoth
------------------------------
Date: Fri, 23 Jun 2000 22:57:01 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Creating a cause from information.
Message-Id: <slrn8l8ccd.tq.tadmc@maxim.metronet.com>
On Fri, 23 Jun 2000 16:07:08 GMT, Steven Merritt
<smerr612@mailandnews.com> wrote:
>The problem is that you're using the magical angle brackets <> on your
>filehandle as the only condition of a while loop. These read a line
>from the filehandle every iteration of the while loop(and only when you
>use it in a while loop) and put it into $_. So what you've done is
>basically do two reads, an implicit read, and an explicit read, per
^^^^^^^^ ^^^^^^^^
No, both reads were explicit.
One input operator in the while clause, and one input operator
in the body of the loop.
The _assignment_ is implicit for the while clause one.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Jun 2000 10:30:03 +0100
From: nobull@mail.com
Subject: Re: delaying Sendmail command
Message-Id: <u9pup7tois.fsf@wcl-l.bham.ac.uk>
"Raphael Pirker" <raphaelp@nr1webresource.com> writes:
> I have an autoresponder that I don't want to send out right away. I want to
> be able to say, for instance, that the Autoresponder will wait 30 minutes in
> the "Outbox" before being sent out. Is this possible?
Yeah, write it to a file in some directory then have a periodic
background job that pipes any file over 30 minutes old into sendmail.
Did you have a Perl question?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 24 Jun 2000 10:39:11 +0100
From: nobull@mail.com
Subject: Re: deleting mutiple files?
Message-Id: <u9og4rto3k.fsf@wcl-l.bham.ac.uk>
Pasquale <pdmos23@geocities.com> writes:
> kind of a newbie at all this, but I have a script that assigns a
> reference number to multiple files, i.e.: 3left.jpg, 3right.jpg,
> 3up.jpg, etc... I would like to delete all files at once, which is
> complicated by the fact that the name following the reference number is
> unknown. I've been looking through the perl docs and haven't found
> much. I did try unlink("$basedir/imgs/$num*.jpg"), but it doesn't
> work. Any suggestions or if this is even possible would be
> appreciated.
The classic way is to use glob(). glob() actually works by calling
the shell.
unlink(glob("$basedir/imgs/$num*.jpg")) or die;
If you want to avoid this use File::Find. File::Find will
also look in subdirectories but is there are none this is not an
issue.
use File::Find;
find sub { unlink or die "unlink $_: $!" if /^$num.*\.jpg$/ } =>
"$basedir/imgs"
> --------------A6AC307A3042C564A1DBFF40
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> <html>
No please, this is a plain text newsgroup.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 23 Jun 2000 22:59:08 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Dereferencing a two dimensional array?
Message-Id: <slrn8l8cgc.tq.tadmc@maxim.metronet.com>
On 23 Jun 2000 10:39:51 -0700, Andrew Perrin - Demography
<aperrin@davis.DEMOG.Berkeley.EDU> wrote:
>tadmc@metronet.com (Tad McClellan) writes:
>
>
>> >
>> >This line does NOT work:
>> > @jr <= $re[$i];
>>
>> Turn on warnings. You have the wrong operator there.
>>
>> @jr , $re[$i]; # this is the same as what you have above
>
>Are you sure? I think you're confusing => with <=. To my knowledge,
><= is only "less than or equal to".
Doh!
Sorry.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Jun 2000 10:51:04 +0100
From: nobull@mail.com
Subject: Re: Forcing unbuffered stdout from command line?
Message-Id: <u9n1kbtnjr.fsf@wcl-l.bham.ac.uk>
David Bolen <db3l@fitlinxx.com> writes:
> Does anyone know of a method to tell perl to treat stdout as an
> interactive TTY even if it might otherwise think it wasn't?
>
> I'm trying to take a system of scripts (which call each other in
> several levels) and wrap them within a master script that traps all of
> their normal output. The idea is to leave the existing system
> untouched, but just wrap it so I can get access to the normal stdout
Without modifying the script? Well I guess you could put a -M switch
on the command line that loads a module that just does "$|=1".
Alternatively use a PTY rather than a FIFO.
I believe the Expect module will help with this.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 23 Jun 2000 23:08:30 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help - Brain Teaser
Message-Id: <slrn8l8d1u.tq.tadmc@maxim.metronet.com>
On Fri, 23 Jun 2000 23:04:29 +0100, David Neupert
<dpeter@freenetname.co.uk> wrote:
>
>Does anyone know how to keep the downstate of an image even when you
>leave the page
Perl does not have "pages". What are you talking about there?
(eg if i have a map of the UK and a dot that changes color
>when clicked
^^^^^^^
Oh. Are you using Perl/Tk then?
>i want it to stay on the down state even if someone leaves the page and
>returns)
>
>Someone suggested cookies can anyone help?
^^^^^^^
Perl does not have cookies either.
I think the WWW has something called a cookie.
Maybe you forgot to mention that you are using Perl
in a CGI environment?
But that doesn't matter, because no part of your question is
about Perl, so it should not be here anyway.
_How_ to do it in Perl might be on topic, but _what_ to do
depends on what you are using Perl for (CGI for your
case, I guess).
You should ask WWW questions in a WWW newsgroup. Ask Perl questions here.
comp.infosystems.www.authoring.cgi
>A response via E-Mail would be apreciated ksimm@globalnet.co.uk
Nope.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Jun 2000 12:32:37 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Help with s/ //g and s// /g
Message-Id: <8j29p5$hjc$1@pegasus.csx.cam.ac.uk>
In article <1103_961794295@eratos>, <abliss@mindspring.com> wrote:
>
>Can someone tell me why the exact same block of code doesn't produce
>the same output the second time it is executed? It seems that,
>somehow, executing "s/ //g;" anywhere in the script makes "s// /g;"
>never work again. I have tried this on several different versions
>and several different machines with no change.
Having the pattern aws an empty string is a special case. From the
perlop section on s/// :
If
the pattern evaluates to the empty string, the last
successfully executed regular expression is used
instead.
Mike Guy
------------------------------
Date: Sat, 24 Jun 2000 18:05:41 +0800
From: "Huang Kai" <hk22@371.net>
Subject: how to get part of a large html file
Message-Id: <8j21c2$ag7$1@news.cz.js.cn>
hi,
I wish exampels for how to get part of a large html file.
or resume operation for html download.
BR
Kevin
------------------------------
Date: Sat, 24 Jun 2000 07:50:17 GMT
From: "Ben" <lilleyb001@hawaii.rr.com>
Subject: Re: OpenFile then Chomp
Message-Id: <ZKZ45.9650$aB6.39861@typhoon.hawaii.rr.com>
>You might try C<chomp($line = `head -1 $file`);>. Programming Perl is
>an empircal science. :-)
If you use this line you will have the overhead of forking a process for
calling head ...
>Try this
> open (FILE,$file) or die ("$file : $!");
> chomp($line = <FILE>);
> close (FILE);
>
>Rich
This is basically the exact same code you were originally using, which would
not be any faster ..
For your particular application, you may want to consider simply using
head -1 from the command line (or in a simple shell script) to put all the
first lines into a file, then pass that file to Perl for processing - that
MAY BE the most efficient way to do it. (Assuming you have an Unix-like OS
that has head .. ) If you use a different OS let us know.
Regards
Ben
TheEx0rcist <TheEx0rcist@fanclub.org> wrote in message
news:8j0ne1$vi4$1@news4.isdnet.net...
> Hi,
>
> Is there a faster/more efficient way to do this :
>
> sub getFirstLine
> {
> my $file = shift;
> my $line;
>
> open (FILE,$file) or die ("$file : $!");
> $line = <FILE>;
> close (FILE);
>
> chomp $line;
>
> return $line;
> };
>
> It is very crictical because the first line is extracted from thousands of
> files so speed is an issue!
>
> Thanks for your help !
>
> --
> TheEx0rcist.
>
>
------------------------------
Date: Sat, 24 Jun 2000 02:19:23 GMT
From: "Rich H" <richh@panola.com>
Subject: Re: OpenFile then Chomp
Message-Id: <SL86P5ISE7F45@CORP.SUPERNEWS.COM>
Try this
open (FILE,$file) or die ("$file : $!");
chomp($line = <FILE>);
close (FILE);
Rich
TheEx0rcist <TheEx0rcist@fanclub.org> wrote in message
news:8j0ne1$vi4$1@news4.isdnet.net...
> Hi,
>
> Is there a faster/more efficient way to do this :
>
> sub getFirstLine
> {
> my $file = shift;
> my $line;
>
> open (FILE,$file) or die ("$file : $!");
> $line = <FILE>;
> close (FILE);
>
> chomp $line;
>
> return $line;
> };
>
> It is very crictical because the first line is extracted from thousands of
> files so speed is an issue!
>
> Thanks for your help !
>
> --
> TheEx0rcist.
>
>
------------------------------
Date: Sat, 24 Jun 2000 07:44:19 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: OpenFile then Chomp
Message-Id: <4k79lsobu4vvuqlf2jm65os72srqpivql1@news.supernews.net>
"TheEx0rcist" <TheEx0rcist@fanclub.org> wrote:
} Is there a faster/more efficient way to do this :
}
} sub getFirstLine
[...]
} open (FILE,$file) or die ("$file : $!");
} $line = <FILE>;
} close (FILE);
} It is very crictical because the first line is extracted from thousands of
} files so speed is an issue!
Well, opening and closing files a lot is a pretty slow operation, I'd think
[the read and chomp is probably not bad]. One alternative would be to let
Unix do the work for you. If the set of files is known, I'd bet that the
fastest way to do it would be to do:
open (FIRST, "head -1 <LOTS OF FILES> | ")
and then read and chomp them from there..
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Sat, 24 Jun 2000 03:32:49 GMT
From: "¾ÈÅ¿í" <hanbit@tng.co.kr>
Subject: oracle DB connection
Message-Id: <8J1AD4$46R$1@NEWSFEED.UNITEL.CO.KR>
I want a data insert into oracle DB using perl.
There was no error message but it couldn't inserted into DB
here is source code. I want a reply.
Have a nice day
#!/usr/local/bin/perl
$ENV{'ORACLE_HOME'} = "/oracle/app/oracle/product/7.3.4";
$ENV{'NLS_LANG'} = "American_America.KO16KSC5601";
require "cgi-lib.pl";
require "teria-lib.pl";
&ReadParse;
#$memnum = $in{'memnum'};
#$insSQL = "insert into ROLLBOOK_TBL
(memnum,nhanja,nhangu,curjob,curoll,prejob,prroll,birthd,birthp,memadd,memte
l,offtel,cacade,carrel,memcert,membook)
values(".$memnum,$nhanja,$nhangu,$curjob,$curoll,$prejob,$prroll,$birthd,$bi
rthp,$memadd,$memtel,$offtel,$cacade,$carrel,$memcert,$membook .")";
#DB Connection
use DBI;
use CGI;
$new=new CGI;
$drh = DBI->install_driver('Oracle');
die unless $drh;
$dbh = $drh->connect('DB','user','passwd');
die unless $dbh;
$dbh->{LongReadLen} = 16384;
#$cursor = $dbh->prepare($insSQL);
#$cursor->execute;
$memnum=$new->param('memnum');
$nhanja=$new->param('nhanja');
$nhangu=$new->param('nhangu');
$curjob=$new->param('curjob');
$curoll=$new->param('curoll');
$prejob=$new->param('prejob');
$prroll=$new->param('prroll');
$birthd=$new->param('birthd');
$birthp=$new->param('birthp');
$memadd=$new->param('memadd');
$memtel=$new->param('memtel');
$offtel=$new->param('offtel');
$cacade=$new->param('cacade');
$carrel=$new->param('carrel');
$memcert=$new->param('memcert');
$membook=$new->param('membook');
#Form action
$actInput = $in{'actInput'};
if($actInput eq
bmit"){
$insSQL = "insert into ROLLBOOK_TBL (memnum,nhanja,nhangu,curjob,curoll,prejob,prroll,birthd,birthp,memadd,memtel,offtel,cacade,carrel,memcert,membook) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$cursor = $dbh->prepare($insSQL);
$cursor->execute($memnum,$nhanja,$nhangu,$curjob,$curoll,$prejob,$prroll,$birthd,$birthp,$memadd,$memtel,$offtel,$cacade,$carrel,$memcert,$membook);
#$memnum=$cursor->fetchrow_array;
#$cursor->fetch;
#$memnum++;
$db
h->disconnect;
}
------------------------------
Date: Fri, 23 Jun 2000 23:30:06 -0500
From: Nnickee <nnickee@nnickee.com>
Subject: Re: oracle DB connection
Message-Id: <6E93F280FE8BD91B.F543B3704AA728FD.14AADFF6506D1C22@lp.airnews.net>
On Sat, 24 Jun 2000 12:29:31 +0900, someone claiming to be "¾ÈÅ¿í"
<hanbit@tng.co.kr> said:
>I want a data insert into oracle DB using perl.
>There was no error message but it couldn't inserted into DB
>here is source code. I want a reply.
I want a new car and a pony :)
>Have a nice day
You too :)
------------------------------
Date: Fri, 23 Jun 2000 21:30:07 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Quick "Perl Way" solution needed
Message-Id: <3954394F.6C40A2EA@stomp.stomp.tokyo>
J Church wrote:
(rand snippage)
> From the Block below , I was wondering if anyone wants
> to take a shot at a quick "Perl Way" solution:
> I want to print the numbers in the last field in such a way
> that each sequence of consecutive numbers are considered
> seperate ranges, and are the only values extracted.
> The output would be something like:
> Bad Scan Ranges: Low High
> 688 692
> 1039 1042
> 1635 1638
> -W- getl0scene_nav.c: bad navigation at scan 688 <-----low
> -W- getl0scene_nav.c: bad navigation at scan 692 <-----high
(...etc data block)
I like doing things differently and truly
enjoy raising eyebrows. This method keeps
things to a minimum although first glance
indicates a very busy routine. It does
run rather fast, less than a blink of
an eye, by my eyeblink benchmark method.
Rather than use any sorting, comparison
operators, and rather than run from zero
to your highest number, this routine creates
a range based solely on your input numbers,
in increments of one-hundred. For the data
you provided, this routine will _only_ look
at these ranges:
600 to 700
1000 to 1100
1600 to 1700
...and no other ranges of numbers. This
cuts down on a need to start at zero
and run upward. Eyebrows raised yet?
My script will adjust ranges according
to your input, automatically, and leave
out those ranges not needed. I like this.
This is setup to run from 100 to 100000
in ranges. Easy to modify to range from
zero to whatever upper limit you set. If
your data is not organized in numerical
order as you show, a 'sort array' would
take care of this, no problem.
If you are going to work with a significantly
large data base, a while type loop method
would be a little more efficient but very
dangerous IF you are going to rewrite your
data base for some reason. For just a read,
a while would work fine, maybe a little faster.
This is a test script intended to display some
logic on how to approach this challenge. It is
not intended for direct copy, paste and use.
Primary intent here to display an alternative
method rather than the usual whatever method.
If this suits your needs, use a bit of my
logic displayed and write your own custom
code to meet your needs. Bugs? I dunno. I made
no effort to break this code. Test it well and,
I do mean, test it well. It's a freebie afterall.
Godzilla!
PRINTED RESULTS:
________________
Low: 688 High: 692
Low: 1039 High: 1042
Low: 1635 High: 1638
Done! Godzilla Rocks!
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$pretend_input = "-W- getl0scene_nav.c: bad navigation at scan 688
-W- getl0scene_nav.c: bad navigation at scan 689
-W- getl0scene_nav.c: bad navigation at scan 690
-W- getl0scene_nav.c: bad navigation at scan 691
-W- getl0scene_nav.c: bad navigation at scan 692
-W- getl0scene_nav.c: bad navigation at scan 1039
-W- getl0scene_nav.c: bad navigation at scan 1040
-W- getl0scene_nav.c: bad navigation at scan 1041
-W- getl0scene_nav.c: bad navigation at scan 1042
-W- getl0scene_nav.c: bad navigation at scan 1635
-W- getl0scene_nav.c: bad navigation at scan 1636
-W- getl0scene_nav.c: bad navigation at scan 1637
-W- getl0scene_nav.c: bad navigation at scan 1638";
$pretend_input =~ s/-(.*)scan //g;
local (@Array) = split (/\n/, $pretend_input);
local (@Temp_Array) = ();
local ($digits_check, $lo_limit, $hi_limit, $low, $high);
foreach $line (@Array)
{
if (!($lo_limit))
{
$digits_check = $line =~ tr/0-9/0-9/;
if ($digits_check eq 3)
{ $lo_limit = ((substr ($line, -3, 1) * 100)); }
elsif ($digits_check eq 4)
{ $lo_limit = ((substr ($line, -4, 2) * 100)); }
elsif ($digits_check eq 5)
{ $lo_limit = ((substr ($line, -5, 3) * 100)); }
else
{ print "Range Is Not 100 To 100000"; exit; }
$hi_limit = ($lo_limit + 100);
}
if (($line >= $lo_limit) & ($line < $hi_limit))
{ push (@Temp_Array, $line); }
else
{
$lo_limit = "";
$low = $Temp_Array[0];
$high = $Temp_Array[$#Temp_Array];
print "Low: $low High: $high\n";
@Temp_Array = ();
push (@Temp_Array, $line);
}
}
$low = $Temp_Array[0];
$high = $Temp_Array[$#Temp_Array];
print "Low: $low High: $high\n\n";
print "Done! Godzilla Rocks!";
exit;
------------------------------
Date: Sat, 24 Jun 2000 10:10:06 GMT
From: "Eelke Kleijn" <six4eight@NOSPAMhotmail.com>
Subject: Redirecting
Message-Id: <2O%45.1575$T3.11636@Typhoon.bART.nl>
Hi All,
I have a question. I am writing a script for the following setup:
User ======> Webserver =======> Firewall ========> Server
What I am trying to do is the following:
I want to run a database on the server (I think ASP). I want to the user to
fill in a form, then submit that. The webserver will have to forward the
request to the firewall (I think I can handle this part). The difficult part
is the firewall I think. The firewall has to forward the request to the
server, and receive the servers output. Now the firewall will have to
forward the information back to the webserver, and the webserver has to show
the output to the user.
My question is, can this be done?? And if so how? I have tried messing
around a bit using squid, but I don't really know where to start building
the script. If anywould could give me a suggestion, or an example script
that does more or less the same, I would greatly appreciate it.
Thanx in advance,
Eelke Kleijn
------------------------------
Date: Fri, 23 Jun 2000 23:25:32 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reg Expression Question
Message-Id: <slrn8l8e1s.tq.tadmc@maxim.metronet.com>
On Fri, 23 Jun 2000 16:30:02 GMT, Joel <jllawhead@sunherald.com> wrote:
>Of course there are lots of ways to do that. Here's one way (and I'm not an
>expert so this may not be the best/shortest way):
^^^^ ^^^^^^^^
It is neither.
In fact, it is a Very Bad Way!
>$MyString='<img src="http://www.myhouse.com.au/house.gif">'; #your variable
>$MyString =~ m/<img src="http:\/\/www.myhouse.com.au\/(.*)">/i; #do a match
^ ^ ^
^ ^ ^
Use an alternate delimiter, and avoid backslashes:
$MyString =~ m!<img src="http://www.myhouse.com.au/(.*)">!i;
>$image = $1; #assign what we found in () to variable "$image"
There is the Very Bad part.
You should never use the dollar-digit variables without first
checking if the pattern match succeeded.
If the match fails, the variables remain unchanged.
if ( $MyString =~ m!<img src="http://www.myhouse.com.au/(.*)">!i ) {
$image = $1;
}
(of course it _will_ match here, since the value of $MyString
is hard coded, but nobody would do a pattern match against
a hard coded string in a real program.
)
>## $image variable is now house.gif
Maybe it is, and maybe it isn't...
[ snip Jeopardy quoted text ]
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 23 Jun 2000 22:45:57 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: regex engin's undocumented behaviour?
Message-Id: <slrn8l8bnl.tq.tadmc@maxim.metronet.com>
On Fri, 23 Jun 2000 09:46:18 -0400, Drew Simonis <care227@attglobal.net> wrote:
>Tad McClellan wrote:
>>
>> On Thu, 22 Jun 2000 10:29:25 -0400, Drew Simonis <care227@attglobal.net> wrote:
>> >Tad McClellan wrote:
>>
>> >>> /^(aa(bb)?)+$/;
>>
>> >> aabbaa
>> >> ^^^^
>> >>
>> >> That much matches
>> >> aabbaa
>> >> ^^
>> >>
>> >> That matches the second time around (allowed by the +).
>> Backtracking only happens when the engine cannot match.
>
>So the engine used by perl does not require the longest _leftmost_
>match? (but does support some _other_ POSIX type stuff, like
>[[.lower.]]?)
perldoc -q POSIX
"Are Perl regexes DFAs or NFAs? Are they POSIX compliant?"
>> You misunderstand backtracking, I think.
>
>Amen to that.
Backtracking only happens when the engine cannot match.
>I hate these darn things called regular expressions.
That's strange.
I love them.
Because they are powerful.
I like to have power.
We should use this power only for good.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 24 Jun 2000 13:41:24 +0100
From: "Miles Davenport" <miles@explorer.demon.co.uk>
Subject: Re: Running Perl CGI Scripts
Message-Id: <961850352.26771.0.nnrp-01.d4e4dc01@news.demon.co.uk>
Check your process table, and see what apache is running as:
ps -ef |grep http
You'll see what the returned processes are running as.
Go to the directory you are trying to write to:
Use chmod to change the permissions for the directory.
chmod a+wr directoryName will allow read/write to all (a) users.
If you set the sticky bit on the directory, the permissions will be
retained for any files that are created within that directory.
MD.
mike <mikes@escape.com> wrote in message
news:39541F2D.27995169@escape.com...
>
> Hi,
> I am trying to learn CGI scripting and Perl and using Apache
> on a Slackware 7.0 Linux box. The scripts that I am having
> trouble with are the ones that create or write to files. The
> scripts seem to run through, but no file is created or written
> to. In the error_log file, I get the message: cannot create
> regular file /path/filename Permission denied. Do I have
> to in some way tell Apache to allow creation and writing to
> files in its config file?
> Thanks
> Mike
>
------------------------------
Date: 24 Jun 2000 10:59:27 +0100
From: nobull@mail.com
Subject: Re: sending emails from perl script
Message-Id: <u9lmzvtn5s.fsf@wcl-l.bham.ac.uk>
stolkd@my-deja.com writes...
...a lot of stuff that boils down to:
"My system admin won't let me set the envelope-from address in
sendmail. I want to set the envelope-from address. Will I have to
use something other than sendmail?"
Eh.... yes.
Do you have a Perl question?
Have you looked at the various Mail modules on CPAN?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3471
**************************************