[16556] in Perl-Users-Digest
Perl-Users Digest, Issue: 3968 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 9 18:15:55 2000
Date: Wed, 9 Aug 2000 15:15:32 -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: <965859331-v9-i3968@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 9 Aug 2000 Volume: 9 Number: 3968
Today's topics:
Re: Overriding Builtin Functions <bkennedy@hmsonline.com>
Re: Overriding Builtin Functions (Greg Bacon)
parsing Finger replies with perl <nospam@nospam.com>
Perl mods for MySQL <((>< <yamar420@my-deja.com>
Perl on NT <chris.gifford@virgin.net>
Re: Perl script? <memmett@fraser.sfu.ca>
Re: reg expressions - protect html <elijah@workspot.net>
Re: Regular expression to check for non-alphanumeric? <tim@ipac.caltech.edu>
Re: Regular expression to check for non-alphanumeric? <lr@hpl.hp.com>
Re: Regular expression to check for non-alphanumeric? <lr@hpl.hp.com>
Re: returning error message <tim@ipac.caltech.edu>
Re: Set cookie from SSI (Tony L. Svanstrom)
Re: Set cookie from SSI <bean@agentkhaki.com>
Re: Set cookie from SSI <bean@agentkhaki.com>
Re: Set cookie from SSI <flavell@mail.cern.ch>
Re: Set cookie from SSI <bean@agentkhaki.com>
Re: Simple reg expression question <kennylim@techie.com>
Re: Simple regular Expression Question <kennylim@techie.com>
URL change <alesr@siol.net>
Re: URL change (Greg Bacon)
variable in sql array not parsed steve_shriver@my-deja.com
Re: What to do with 1A(hex) in a file? <hartmut.wind@t-online.de>
Re: When does it pay to presize an array? (Andrew J. Perrin)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 09 Aug 2000 18:50:53 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Overriding Builtin Functions
Message-Id: <hKhk5.88629$A%3.1220283@news1.rdc2.pa.home.com>
"Garrett Rolfs" <stage3@us.ibm.com> wrote in message
news:399182E1.D67EB8FF@us.ibm.com...
In general, most people will seriously frown on attempts to override builtin
functions and otherwise mucking around with the symbol table, but learning
how to do it and actually understanding how it works really you understand a
lot about whats going on. I would definitely recommend though making a
proper module to do what you need.
> 1. Can print and printf be overridden? In my prototype I added print
> and printf to my module's @EXPORT list. I understand the ramifications
> of using @EXPORT, this is just a prototype at this point. When I "use"
> my module in a script, the print and printf functions in my module are
> not called. In the perlsub manpage I noticed that it said "most"
> builtin functions can be overridden. Are print and printf not included
> in most?
I don't think so, but you can tie packages to file handles to get a similar
effect. For example, if you wanted to trap STDOUT, you can add something
like:
tie(*STDOUT, 'modulename');
sub TIEHANDLE {
my($package) = @_;
*MYSTDOUT = *STDOUT; # this allows us to print without retriggering the
tied subroutine
return bless { }, $package;
}
sub PRINT {
my($ref,@data) = @_;
print MYSTDOUT "Overridden print: ", @data; # use our alias for STDOUT
}
you would also need a PRINTF sub to catch printf output - the tie
documentation will explain this. So, when you opened a file handle via some
overridden sub, you would tie it behind the scenes to trap writes and reads
to it.
> 2. I have run into the problem with the open function in the form of:
>
> open FH, "</tmp/somefile" or die "$!\n";
>
> My open functions receives FH has a string. How can I take that string
> and set FH to be an open filehandle in my caller's package?
One way to do this (which may be done better I imagine) is to alias the
calling packages symbol table entry to the modules one for the file handle
name in question.
sub open {
my($fhname,$filename) = @_;
print "Overridden open: $fhname - $filename\n";
open($fhname,$filename) or die "Cannot open: $!";
*{(caller())[0] . "::$fhname"} = *{$fhname}; # alias local package to
calling package name
}
so if you open(HANDLE,"some_file"), the calling packages *HANDLE will be
aliased to *modulename:HANDLE, so file handle operations will work.
Unfortunately, you $HANDLE will also change, but this is probably not going
to affect most scripts
> 3. I have also run into problems with read and sysread. They both take
> a scalar to hold the results of the read. My functions receive the
> value of the scalar, not a reference to the scalar. I assume the
> builtin functions use some "magic" to treat the scalar as a reference.
> I changed my functions to croak if they don't receive a reference to a
> scalar, but that makes it hard to give existing scripts distributed file
> system tolerance by adding a simple "use mymodule qw(funcs..)"
> statement.
You can simulate builtin functions with prototypes -
sub sysread (*\$$) {
my($handle,$bufref,$len) = @_;
sysread($handle,$$bufref,$len);
}
perldoc perlsub explains this well in the 5.6 documentation. Hope this
helps--
--Ben Kennedy
------------------------------
Date: Wed, 09 Aug 2000 19:21:00 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Overriding Builtin Functions
Message-Id: <sp3bosr5n4t141@corp.supernews.com>
In article <399182E1.D67EB8FF@us.ibm.com>,
Garrett Rolfs <stage3@us.ibm.com> wrote:
: I am attempting to create a module, written entirely in perl, that will
: override builtin IO functions such as open, close, read, sysopen, etc.
: [...]
:
: 1. Can print and printf be overridden? [...]
Not directly. You can get at them by tie()ing a filehandle. See the
perltie manpage for details on that. You could tie the handle in your
overridden open().
: 2. I have run into the problem with the open function in the form of:
:
: open FH, "</tmp/somefile" or die "$!\n";
:
: My open functions receives FH has a string. How can I take that string
: and set FH to be an open filehandle in my caller's package?
You have to do some symbol table fiddling:
sub open(*;$) {
my $sym = shift;
my $arg = shift;
if (ref $sym) {
warn "MyOpen: handling reference...\n";
return CORE::open $sym, $arg;
}
else {
no strict 'refs';
my $pkg = caller;
warn "MyOpen: handling non-reference...\n";
return CORE::open *{ $pkg . '::' . $sym }, $arg;
}
}
The new autovivifying filehandles, e.g., open my $fh, $file, confuse
this version of open, and I don't know how to handle that case.
: 3. I have also run into problems with read and sysread. [...]
tie()ing the handle in your open will let you trap read()s and
sysread()s too. See the perltie manpage.
Hope this helps,
Greg
--
OK, I can't play against a program that has four invisible phantom knights
on f4. No wonder it has a 2050 rating.
-- mjd
------------------------------
Date: 9 Aug 2000 18:53:59 GMT
From: The WebDragon <nospam@nospam.com>
Subject: parsing Finger replies with perl
Message-Id: <8ms9c7$3f1$1@216.155.33.80>
Does anyone have either a short bit of business they coded and would be
willing to share regarding parsing the components of Finger replies (for
date last updated, .plan information, etc.) or have a URL link to the
RFC for finger formats that I could study in my efforts to do the same?
any and all assistance appreciated, as always :)
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Wed, 09 Aug 2000 20:30:54 GMT
From: <((>< <yamar420@my-deja.com>
Subject: Perl mods for MySQL
Message-Id: <8msf1v$8i7$1@nnrp1.deja.com>
Can someone tell me the correct mod to load for Solaris and MySQL ;perl;
there seems to be a few ;
DBI-1.13.tar.gz
Perl DBI module.
Msql-Mysql-modules-1.2209.tar.gz
Perl DBD module to access mSQL and MySQL databases.
Data-Dumper-2.101.tar.gz
Perl Data-Dumper module. Useful with DBI DBD support for older perl
installations.
KAMXbase1.0.tar.gz
Convert between '.dbf' files and MySQL tables. Perl module written by
Pratap Pereira
(pereira@ee.eng.ohio-state.edu), extened by Kevin A. McGrail
(kmcgrail@digital1.peregrinehw.com). This converter can handle MEMO
fields.
Data-ShowTable-3.3.tar.gz
Perl Data-ShowTable module. Useful with DBI/DBD support.
thanks... I want to run Apache and MySQL , and use a perl and CGI script
to access my DB..
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 9 Aug 2000 22:34:41 +0100
From: "Chris Gifford" <chris.gifford@virgin.net>
Subject: Perl on NT
Message-Id: <Aakk5.10335$VO3.177586@news6-win.server.ntlworld.com>
I have a NT4 Server running Apache Web Server and I cant seem to get and
forms with cgi/perl scripts working. Does anyone know of any scripts that
work on NT servers for sending forms and does not require downloading extra
software?
Chris
------------------------------
Date: 09 Aug 2000 11:14:54 -0700
From: Matthew Emmett <memmett@fraser.sfu.ca>
Subject: Re: Perl script?
Message-Id: <yvw9r97ywbc1.fsf@fraser.sfu.ca>
Lovena Harwood <lharwoodNOlhSPAM@lucent.com.invalid> writes:
> There is a wonderful site I just found today called "Aloha, write
> you message in the Hawaiian sand". There are fields for entering
> text and the resulting image with your message is emailed to a
> recipient of your choice.
>
> I am trying to locate a script that does this (I'd be using a
> different background and have it hosted) and would like to know if
> anyone may know of a source.
You could use the GIMP (http://www.gimp.org). You can use perl (or
guile) to get the GIMP to draw things for you.
Take a look at http://www.cooltext.com for an example.
Matt
------------------------------
Date: 9 Aug 2000 20:59:42 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: reg expressions - protect html
Message-Id: <eli$0008091643@qz.little-neck.ny.us>
In comp.lang.perl.misc, Larry Rosler <lr@hpl.hp.com> wrote in
response to the Godzilla:
> Indeed. I accept that the limited set of data shows no significant
> correlation between the runtime performance of the code and the use of
> '-w' or 'use strict;'. You hide the absence of significance behind
> words.
I use perl Benchmark-ing frequently to figure out what speeds things
up and what slows them down. For any particular situation, the version
of perl, the platform, and other things in the code can change things.
Therefore benchmarking should be done frequently and with real code
whenever possible.
The code I used for that post was the code I had left over from
my last benchmark experiment, anonymous subs versus evaled code
for in timethese(). In perl5.00503 there is a noticible difference
for those, but perl5.6.0 fixes that:
Perl 5.005_03
Benchmark: timing 10000000 iterations of AnonSub, EvalCode...
AnonSub: 35 wallclock secs (33.52 usr + 0.00 sys = 33.52 CPU)
EvalCode: 15 wallclock secs (14.79 usr + 0.00 sys = 14.79 CPU)
Perl 5.6.0
Benchmark: timing 10000000 iterations of AnonSub, EvalCode...
AnonSub: 17 wallclock secs (16.29 usr + 0.43 sys = 16.72 CPU)
@ 598086.12/s (n=10000000)
EvalCode: 18 wallclock secs (18.09 usr + 0.42 sys = 18.51 CPU)
@ 540248.51/s (n=10000000)
#!/usr/bin/perl -w
use strict;
use Benchmark;
use vars qw( $a $b );
timethese(10_000_000, {
EvalCode => q!
$a = 1;
$b = 10;
$a += $b;
!,
AnonSub => sub {
$a = 1;
$b = 10;
$a += $b;
},
});
__END__
I find it difficult to make categorical statements about how to
optimize things in perl, since different versions have different
bug-fixes (which sometimes slow things down, by doing them right)
and optimizations in effect.
Elijah
------
shies away from excessive use of functions when writing for speed, though
------------------------------
Date: Wed, 09 Aug 2000 11:08:14 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Regular expression to check for non-alphanumeric?
Message-Id: <39919E0E.147C3FCC@ipac.caltech.edu>
Troy Rasiah wrote:
>
> if ($variablename=~/\W+/) {
> print "there is an alphanumeric character in the string";
^ non-
--
-- Tim Conrow tim@ipac.caltech.edu 626-395-8435
------------------------------
Date: Wed, 9 Aug 2000 11:06:07 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regular expression to check for non-alphanumeric?
Message-Id: <MPG.13fb3d66151327fd98ac51@nntp.hpl.hp.com>
[Rearranged ror logical flow. Please respond after, not before!]
In article <ke3k5.79791$N4.2008046@ozemail.com.au> on Wed, 9 Aug 2000
12:19:10 +1000, Troy Rasiah <troyr@vicnet.net.au> says...
> "Robert Brooks" <studentfl@hotmail.com> wrote in message
> news:cm2k5.31328$eS6.644697@news1.rdc1.md.home.com...
...
> > I need a regular expression that will allow me to set up a if statement
> > that goes like:
> >
> > if this string contains something other then alphanumeric characters,
> > periods, or commas do this
...
> if ($variablename=~/\W+/) {
> print "there is an alphanumeric character in the string";
> }
The '+' in the regex is superfluous, as '1' is a special case of '1 or
more'. The print statement has it backwards -- 'non-alphanumeric'.
> modify it a bit
By including \W in a character class with the other characters.
perldoc -f perlre
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 9 Aug 2000 11:37:21 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regular expression to check for non-alphanumeric?
Message-Id: <MPG.13fb44ba1d99784e98ac54@nntp.hpl.hp.com>
In article <mfgk5.31622$0W4.827331@newsread2.prod.itd.earthlink.net> on
Wed, 09 Aug 2000 17:09:38 GMT, Earthlink News
<rickysregistration@hotmail.com> says...
...
> You could also use alternation, a la:
>
> @list = qw/some Word32 83f.doc kd*a i92)#7.2dk 23/;
>
> foreach (@list) {
> unless (m%^(\w|,|\.)+$%) {
> print "$_ ain't alphanumeric,.\n";
> }
> }
>
> Hope that helps,
Not really. Alternation is considerably slower than using a character
class, so shouldn't be used for matching single characters against a set
of alternatives.
Use Benchmark.pm for quantitative comparisons.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 09 Aug 2000 11:19:08 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: returning error message
Message-Id: <3991A09C.92AFCD04@ipac.caltech.edu>
daemon wrote:
> I'm writting a module and need to be able to return an error string
> in the event of a problem. I can't just set $! because perl
> expects that to be a numeric value. So far the best I could come
> up with is to use a global variable $errmsg and set that when
> needed.
I note that some module authors have used the global $@ for passing error
messages around. This seems safe as long as you're sure you're not stepping on
the result of an "eval" (see perlval about $@).
--
-- Tim Conrow tim@ipac.caltech.edu 626-395-8435
------------------------------
Date: Wed, 9 Aug 2000 20:58:55 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Set cookie from SSI
Message-Id: <1ef47l4.1yczwyq1lve5qoN%tony@svanstrom.com>
Michael Winter <michaelw@gmx.at> wrote:
> is it possible to set a cookie from a SSI?
No; and that's not a perl-question...
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
DSS: 0x9363F1DB, Fp: 6EA2 618F 6D21 91D3 2D82 78A6 647F F247 9363 F1DB
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©1999 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: 09 Aug 2000 19:58:05 GMT
From: bean <bean@agentkhaki.com>
Subject: Re: Set cookie from SSI
Message-Id: <MPG.13fb7f927d98f2ce989692@news.concentric.net>
I have a similar question, so if someone could answer this, I'd be
greatful.
I realize it's more of an SSI question, but since we're using Perl to do
all of the information handling/processing, it really is a Perl
question.
What I really need to know how I would use the print function to do
something other than print directly the the calling shtml page.
Basically, I want to do a
print "Location:../error_page.shtml";
from a script called through SSI. But all that happens is that
information gets printing onto the calling page. Is there a way around
this?
bean
------------------------------
Date: 09 Aug 2000 20:00:36 GMT
From: bean <bean@agentkhaki.com>
Subject: Re: Set cookie from SSI
Message-Id: <MPG.13fb802af1c97937989693@news.concentric.net>
> I realize it's more of an SSI question, but since we're using Perl to do
> all of the information handling/processing, it really is a Perl
> question.
This isn't too clear. What I meant was Perl is being used here, the only
thing that makes it an SSI question is the way it is being called and
where the data goes when it is put out...
bean
------------------------------
Date: Wed, 9 Aug 2000 22:30:51 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Set cookie from SSI
Message-Id: <Pine.GHP.4.21.0008092210360.27444-100000@hpplus03.cern.ch>
On 9 Aug 2000, bean wrote:
> > I realize it's more of an SSI question, but since we're using Perl to do
> > all of the information handling/processing, it really is a Perl
> > question.
>
> This isn't too clear. What I meant was Perl is being used here, the only
> thing that makes it an SSI question is the way it is being called
[..]
The structure of usenet is based on the assumption that you understand
enough about your problem to be able to recognise for yourself whether
you are having trouble deciding how to code some Perl statements (for
whatever purpose), or whether you're trying to solve a WWW design
problem (in whatever programming language). If you can't do that,
then you need to settle down with some tutorials or FAQs and get
things a bit sorted out first, otherwise you're just going to find
yourself kicked from one usenet group to another and you won't
understand why.
There's a good reason why usenet is organised into groups;
understanding the scope of those groups will take you a good way along
the path to understand how to use them to your own advantage without
pissing everyone else off, or, as the new users FAQs express it, "how
to work together with the usenet community".
Remember, most of us use coffee to help in designing our applications,
but we don't post our SSI questions to usenet's rec.food.drink.coffee
group on that basis. As long as you hassle the regulars here with
that kind of argument "yes I know it's SSI but I'm programming it in
Perl so it has to be a Perl language question" they are going to
hassle you back; I'm just telling you this for your own good, so that
you can get moving more quickly.
This may very well seem irksome at first, until you come to terms with
it, but after a while you'll appreciate that it makes a lot of sense,
and starting a discussion in the right place really does give you a
better chance of finding a good answer.
(No, SSI cannot do anything exciting with HTTP transactions; it's
server-side Include, precisely for Including the output of something
or other into a document that the server is processing. You need to
use CGI programs directly, without the intermediary of SSI, if you
want the script to perform any interesting HTTP transactions; with SSI
you can just return some content for insertion into the server-parsed
document that you're sending to the client. But your question had
nothing at all to do with Perl; it would be exactly the same if you
tried to use SSI against a program written in COBOL. Tony already
said that, but you didn't want to listen. Well, do listen.)
------------------------------
Date: 09 Aug 2000 21:12:12 GMT
From: bean <bean@agentkhaki.com>
Subject: Re: Set cookie from SSI
Message-Id: <MPG.13fb90f6204f2093989694@news.concentric.net>
> tried to use SSI against a program written in COBOL. Tony already
> said that, but you didn't want to listen. Well, do listen.)
Agreed. I was being lazy. Sorry.
<sigh> My whole process has come crashing down around my ears.
bean
------------------------------
Date: Wed, 09 Aug 2000 19:52:56 GMT
From: "Kenny Lim" <kennylim@techie.com>
Subject: Re: Simple reg expression question
Message-Id: <sEik5.31982$0W4.838214@newsread2.prod.itd.earthlink.net>
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:0582ps8lhoc26j0ma9mpttuug4vgcadtb4@4ax.com...
> Kenny Lim wrote:
>
> >(b) The total given value to be incremented exceeded 9.
> >(ie. $2 = 9, current value is ETProj99, the outcome result would be 918
> >where it should be 108)
>
> Eh? So you jump from version 9.9 to 10.8?
>
> --
> Bart.
Yeah, this whole idea of incrementing the major version while
leaving the minor version alone seems screwy in the extreme.
Under what conditions would you want to go from, say, version
2.26 to 3.26? Shouldn't incrementing the major version reset
the minor version?
----------------------------------------------------------------------------
----------------------------------------
Hi Bart and Keith,
We usually won't have a drastic increment of the version mentioned
as above by Bart (ie. from 9.9 to 10.8) but the described problem seems to
be fairly fundamental
and it's necessary to get the version incremented correctly. For example :
(See scenario 1-3 below)
#The naming convention for the project-version does not include "." as a
separator
ie ETProj59 since part of the process included is to rename the dll files.
It will be
kinda screwy if it's ETProj5.9.dll, thus this is a limitation the project
version.
Scenario 1 :
Incrementing the minor version by +1,+2,+3 for ETProj59 will result in 510,
511, 512
rather than ETProj60, ETProj61, ETProj62. (That's a big jump from version
59 to 510,
5.9 to version 51.0)
Scenario 2 :
Incrementing the minor version by +1,+2, +3 and etc. for ETProj599 will
result in 5100 rather
than 600, 601, 602.
Scenario 3 :
Incrementing the minor version by +1,+2,+3 and etc. for ETProj999 will
result in 1099 rather
than 1000, 1001, 1002.
It seems like we will need to be able to collaborate both major and minor
version incremented
as a "whole value" instead incrementing the version as an individual entity
which results in incorrect
value when it pass the 9 value.
I was hoping if there is a very simple algorithim that I can add to my
current engine to enforce
the addition value when is being incremented.
Enclosed here is a snippet of the test code.
Thanks in advance and you have a pleasant day ahead of you.
Kenny-
use Getopt::Std;
getopts( 'a:b:' ); #a to increment major version and b to increment minor
version
$major = $opt_a ? $opt_a : 0;
$minor = $opt_b ? $opt_b : 0;
my $str = "ETProj59";
#my $str = "ETProj599";
#my $str = "ETProj999";
if($str =~/(\d{1})(\d+)$/) {
$new_ver = ($1 +$major).($2 +$minor);
print "Old Version = <$1$2>\n";
print "New Version = <$new_ver>\n";
$str =~s/$1$2/$new_ver/;
}
print $str;
Sample Results :
$ perl t5.pl -b 1
Old Version = <59>
New Version = <510>
$ perl t5.pl -b 1
Old Version = <599>
New Version = <5100>
$ perl t5.pl -b 1
Old Version = <999>
New Version = <9100>
------------------------------
Date: Wed, 09 Aug 2000 19:57:20 GMT
From: "Kenny Lim" <kennylim@techie.com>
Subject: Re: Simple regular Expression Question
Message-Id: <AIik5.31991$0W4.838155@newsread2.prod.itd.earthlink.net>
Hi Bart and Keith,
We usually won't have a drastic increment of the version mentioned
as above by Bart (ie. from 9.9 to 10.8) but the described problem seems to
be fairly fundamental
and it's necessary to get the version incremented correctly. For example :
(See scenario 1-3 below)
#The naming convention for the project-version does not include "." as a
separator
ie ETProj59 since part of the process included is to rename the dll files.
It will be
kinda screwy if it's ETProj5.9.dll, thus this is a limitation the project
version.
Scenario 1 :
Incrementing the minor version by +1,+2,+3 for ETProj59 will result in 510,
511, 512
rather than ETProj60, ETProj61, ETProj62. (That's a big jump from version
59 to 510,
5.9 to version 51.0)
Scenario 2 :
Incrementing the minor version by +1,+2, +3 and etc. for ETProj599 will
result in 5100 rather
than 600, 601, 602.
Scenario 3 :
Incrementing the minor version by +1,+2,+3 and etc. for ETProj999 will
result in 1099 rather
than 1000, 1001, 1002.
It seems like we will need to be able to collaborate both major and minor
version incremented
as a "whole value" instead incrementing the version as an individual entity
which results in incorrect
value when it pass the 9 value.
I was hoping if there is a very simple algorithim that I can add to my
current engine to enforce
the addition value when is being incremented.
Enclosed here is a snippet of the test code.
Thanks in advance and you have a pleasant day ahead of you.
Kenny-
use Getopt::Std;
getopts( 'a:b:' ); #a to increment major version and b to increment minor
version
$major = $opt_a ? $opt_a : 0;
$minor = $opt_b ? $opt_b : 0;
my $str = "ETProj59";
#my $str = "ETProj599";
#my $str = "ETProj999";
if($str =~/(\d{1})(\d+)$/) {
$new_ver = ($1 +$major).($2 +$minor);
print "Old Version = <$1$2>\n";
print "New Version = <$new_ver>\n";
$str =~s/$1$2/$new_ver/;
}
print $str;
Sample Results :
$ perl t5.pl -b 1
Old Version = <59>
New Version = <510>
$ perl t5.pl -b 1
Old Version = <599>
New Version = <5100>
$ perl t5.pl -b 1
Old Version = <999>
New Version = <9100>
"Kenny Lim" <kennylim@techie.com> wrote in message
news:YpHj5.26736$0W4.628139@newsread2.prod.itd.earthlink.net...
> Hi All,
>
> I would like to know if it's possible that to increment
> on a "specific number" on a given project name.
>
> Example.
>
> ETThread226
>
> Major Version = 2 (ie. increment to 3)
>
> or
>
> Minor Version = 26 (ie. increment to 27)
>
>
> Results :
>
> To have either
>
> ETThread326
>
> or
>
> ETThread 227
>
> What I am trying to achieve is to provide the flexibily to upgrade the
> version based on the release type. (major or minor release)
>
> Any advise would be great. Thanks in advance.
>
> Kenny-
>
>
>
>
>
>
------------------------------
Date: Wed, 09 Aug 2000 20:36:30 +0200
From: marvin <alesr@siol.net>
Subject: URL change
Message-Id: <3991A4AE.4F4A@siol.net>
Hi !
I know this is actually not a Perl question, but since I make CGI's in
Perl...
My script is doing some database management. Now the shell would
be something like this.
cmd=param('cmd');
name=param('name');
DoInsert() if ($cmd eq "INSERT");
DoShow() if ($cmd eq "SHOW");
sub DoShow
{
Here is all HTML stuff for showing a HTML document
puting a FORM in it and SUBMIT a form as
/cgi-bin/myscript.pl?cmd=INSERT&name=something
}
sub DoInsert
{
Here is all stuff for database inserting.
After that, I would like to see changes, so I redefines
cmd as SHOW
cmd="SHOW";
}
Now, the problem is in DoInsert routine, since the URL still
has an INSERT command, while in the client is HTML document from DoShow.
If user clicks on RELOAD button, the record is inserted again, what is
to be logically.
Is there any way, or practice how to change URL, so reload would not
do INSERT again ?
Notice also, that JAVASCRIPT must not be used in my example, so I think
I can not automaticly load another HTML ? or I can ?
Regards
------------------------------
Date: Wed, 09 Aug 2000 20:16:36 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: URL change
Message-Id: <sp3f14lmn4t184@corp.supernews.com>
In article <3991A4AE.4F4A@siol.net>,
marvin <alesr@siol.net> wrote:
: I know this is actually not a Perl question, but since I make CGI's in
: Perl...
That doesn't make it on-topic here. CGI is CGI regardless of whether
your CGI application is in Perl, FORTRAN, Eiffel, Scheme, or SNOBOL.
Followups set.
Greg
--
When the speaker and he to whom he speaks do not understand, that is
metaphysics.
-- Voltaire
------------------------------
Date: Wed, 09 Aug 2000 21:36:54 GMT
From: steve_shriver@my-deja.com
Subject: variable in sql array not parsed
Message-Id: <8msitm$bl9$1@nnrp1.deja.com>
My goal is to get a SQL statement to include a variable (as a string) that
PERL interprets at runtime.
Here's the SQL that is being processed by a subroutine against an Oracle
database, using DBI.pm: SELECT coeo, '$JIT_OrderStatus['||order_status||']',
TO_CHAR(doc_ordered, 'MM/DD/YYYY'), waybill, carrier FROM feeds WHERE coeo
like 'H2S65%' AND order_status is not null ORDER BY coeo DESC
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 09 Aug 2000 21:39:55 +0200
From: Hartmut Wind <hartmut.wind@t-online.de>
Subject: Re: What to do with 1A(hex) in a file?
Message-Id: <8msbuc$dmb$14$1@news.t-online.com>
Hartmut Wind schrieb:
> I get a file from another computer (via ftp in ASCII mode). A perl
> script running through all of the
> 43200 lines to pick up some parts. Sometimes, it happens that only the
> first part is processed,
> caused by an character, which is 1A(hex). perl assumes that the file is
> at the end (remaining
> appr. 8000 lines got ignored).
> Note: I use 'binmode(IN)' for the input stream, so that 0A(hex), 0D(hex)
> is not modified
> (Windows Environment)
>
> I'd like to adapt the script to replace 1A by e.g. a space (20(hex)),
> but..
> how could I read the bytes after the 'last line', which contains the
> "abort character" 1A(hex)?
>
> Regards
> Hartmut
Thanks to all of you. I detected the fault - it was my fault!
'binmode' allows to read the line with 1A(hex) and all the lines after,
if it used correctly.
I put 'open(IN,..' and 'binmode(IN)' and the lines around to pick up the
filename from the command line, but I forgot to enter 'IN' in the while-loop
'while(<IN>) {...' so the file was still read in 'ASCII mode'.
Hartmut
------------------------------
Date: 09 Aug 2000 14:07:42 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: When does it pay to presize an array?
Message-Id: <un1im48b5.fsf@demog.berkeley.edu>
Ren Maddox <ren.maddox@tivoli.com> writes:
> Perhaps the results can be explained by the fact that nothing else is
> going on between each time the array needs to grow. So the call to
> (presumably) realloc is able to simply increase the size of the
> existing chunk of memory. Or not....?
Okay, well, I tried to test this by changing the:
$array[$_] = $_;
to:
$array[$_] = rand 100;
Results:
aperrin@brass ~> cat presizetest.out
100 elements:
Benchmark: timing 1000 iterations of Presized, Pushed...
Presized: 1 wallclock secs ( 0.41 usr + 0.00 sys = 0.41 CPU)
Pushed: 0 wallclock secs ( 0.39 usr + 0.00 sys = 0.39 CPU)
(warning: too few iterations for a reliable count)
---*---
1000 elements:
Benchmark: timing 1000 iterations of Presized, Pushed...
Presized: 4 wallclock secs ( 3.88 usr + 0.00 sys = 3.88 CPU)
Pushed: 4 wallclock secs ( 3.70 usr + 0.00 sys = 3.70 CPU)
---*---
10000 elements:
Benchmark: timing 1000 iterations of Presized, Pushed...
Presized: 56 wallclock secs (39.41 usr + 0.00 sys = 39.41 CPU)
Pushed: 38 wallclock secs (37.26 usr + 0.00 sys = 37.26 CPU)
---*---
100000 elements:
Benchmark: timing 1000 iterations of Presized, Pushed...
Presized: 422 wallclock secs (388.55 usr + 0.02 sys = 388.57 CPU)
Pushed: 462 wallclock secs (377.07 usr + 0.00 sys = 377.07 CPU)
So at 100K, you pick up some advantages, but not on the cpu side -
interesting still. It sounds like, in any case, it's rarely useful to
presize since you end up with minor differences with major array
sizes.
ap
--
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------
------------------------------
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 3968
**************************************