[10521] in Perl-Users-Digest
Perl-Users Digest, Issue: 4113 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 30 16:07:03 1998
Date: Fri, 30 Oct 98 13:00:18 -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 Fri, 30 Oct 1998 Volume: 8 Number: 4113
Today's topics:
Re: a2p doesn't handle multiline record processing righ (Mark-Jason Dominus)
Re: Almost Newbie Question. Passing %x and @x to a sub <millman@interport.net>
Change UID during execution <hove@borre.phys.ntnu.no>
file sorting sar files in AIX jistdc1@mail.jbhunt.com
Re: How to run Perl/CGI under NT? <perlguy@technologist.com>
ISAPI Perl memory management questions webmuse@my-dejanews.com
Re: Need help with grep <r_larsen@image.dk>
need help with unbuffering w.wilson@mailexcite.com
Re: Not to start a language war but.. <d-edwards@uchicago.edu>
Re: Not to start a language war but.. <jorendorff@ixl.com>
Re: Not to start a language war but.. (Snowhare)
Re: Not to start a language war but.. <jdporter@min.net>
Re: Not to start a language war but.. <jdporter@min.net>
Re: Not to start a language war but.. <akuchlin@cnri.reston.va.us>
Re: Parsing large text file (TIA) (Bart Lateur)
Re: Perl DCOM Question -- setting property (Jan Dubois)
Re: Perl ODBC - SQL Functions RTRIM, LTRIM toffie@my-dejanews.com
Re: persistent variables ? <Paul.Coleman@CoSeCo.com>
Re: Regex Explaination... Ignore (Danny Groppo)
Regex Explaination... (Danny Groppo)
Re: Regex Problem (Brand Hilton)
system statistics from Perl <jeffk@synplicity.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Oct 1998 14:17:13 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: a2p doesn't handle multiline record processing right
Message-Id: <71d3bp$be8$1@monet.op.net>
In article <oM3_1.1161$4%.18367794@fozzy.nit.gwu.edu>,
Sweth Chandramouli <sweth+perl@astaroth.nit.gwu.edu> wrote:
> i just started playing with the a2p translator, and am
>having some problems getting it to respond well to awk scripts
>that use multiline records. the following two-line awk script,
>for example, doesn't work right when perl-ified:
>
>BEGIN { OFS = "\t"; ORS = "\n\n"; FS = "\n"; RS = "" }
>{ print NR, $1, $NF }
>
> the output variables seem to be getting set right, but
>the FS and RS vars (which tell awk that the record is actually
>composed of multiple lines, one per field) don't seem to be
>translated to anything in the perl version.
In my version, the output includes:
$FS = "\n";
$/ = "\n\n";
but the code includes some other bugs. For example, the `chop' should
be `chomp'. Depending on your awk, you may need to set $/ to ""
instead of "\n\n". To decide, look at this input:
a
b
c
d
e
f
Is this two records? Or is it three records where the secdond record
is empty? For the former behavior, use ""; for the latter, use "\n\n".
Also, if you want the extra newlines that some awks will emit, set
$\ = "\n\n";
instead of
$\ = "\n";
$\ is appended to the end of every string that is printed.
>is there an equivalent concept in perl?
$/ is the input record separator in Perl.
>[rewrite in perl] is this the right way to go?
Depends on how much time you have to write the program and how
maintainable you want the result to be. It is usually a good strategy
to running a2p to get a first approximation, and then tweak the
result.
------------------------------
Date: Fri, 30 Oct 1998 20:02:35 GMT
From: Phillip Millman <millman@interport.net>
Subject: Re: Almost Newbie Question. Passing %x and @x to a sub in a module.
Message-Id: <363A1B42.6531E9AF@interport.net>
Now I get it.
Matthew O. Persico wrote:
> Arguments are passed in the magic @_ array.
>
> sub myFunc {
> my($x, $refToArrayY, $refToHashZ) = @_;
>
Its this part that I missed.
> print "arg1 = $x\n";
> print "arg2 = (\n";
> foreach (@{$refToArrayY}) {
> print "$_\n";
> }
> print ")\n"
> print "arg3= (\n";
> foreach (keys %{$refToHashZ}) {
> print "$_ => $refToHashZ->{$_}\n";
> }
> print "_\n";
Very Humbly yours.
Just another Hacker Wanna be.
--
Phillip Millman millman@interport.net
There is a point at which comedy turns into
tragedy. That point has arrived. -Plato
------------------------------
Date: 29 Oct 1998 11:37:29 +0100
From: Joakim Hove <hove@borre.phys.ntnu.no>
Subject: Change UID during execution
Message-Id: <k0nzpafejrq.fsf@borre.phys.ntnu.no>
Hello,
my program needs to be run with root priveliges, as the sole purpose
of the program is to "delete other peoples files".
However, during program execution I would like to change UID to some
innocent unpriveliged user to do something on the net, and then
afterwards reassume the priveliged status.
If you have any suggestions on how to make my program "change
identity" during execution, I would be very grateful.
Joakim Hove
--
------------------------------
Date: Fri, 30 Oct 1998 20:32:23 GMT
From: jistdc1@mail.jbhunt.com
Subject: file sorting sar files in AIX
Message-Id: <71d7oo$kfl$1@nnrp1.dejanews.com>
I am using sar to create reports that are stored in /var/adm/sa:
-rw-r--r-- 1 adm adm 70768 Oct 22 23:00 sa22
-rw-r--r-- 1 adm adm 70768 Oct 23 23:00 sa23
-rw-r--r-- 1 adm adm 38608 Oct 24 23:00 sa24
These are binary files that have to be viewed using sar -f saxx.
I would like to create a script that runs on Fridays and uses sar -f on files
from Thursday to Thursday. If it were run today, it would do something like:
sar -f sa22 > sa1022
.
.
sar -f sa29 > sa1029
Once I have the saMMDD files, I will then ftp them to my PC. The ftp stuff I
can handle, it's the perl code I can't.
Thanks,
Daniel
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 30 Oct 1998 19:46:06 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: How to run Perl/CGI under NT?
Message-Id: <363A177E.356DF477@technologist.com>
"David J. Topper" wrote:
>
> Hey there folks,
>
> I'm a Unix Perl dude. But now I have to run some code off MSIS under
> NT. So I've set up things with the NT Explorer to associate all files
> with .pl and .cgi to launch perl. But unfortunately, I can't seem to
> get stuff to launch. Here's a test script that simply prompts my
...Snip...
Here is a good place to start:
http://reference.perl.com/query.cgi?windows
Good luck!
Brent
--
Java? I've heard of it, it is what I drink when I am hacking Perl. -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Fri, 30 Oct 1998 19:19:04 GMT
From: webmuse@my-dejanews.com
Subject: ISAPI Perl memory management questions
Message-Id: <71d3f7$d0d$1@nnrp1.dejanews.com>
Hello,
We're running into some snags with ISAPI Perl and memory usage.
We're running build 316 on NT 4 (SP3). We are starting to see
quite a few "out of memory!" errors in the PerlErr.log for one
of our more popular scripts, which is then getting stopped
prematurely.
How does ISAPI manage memory? How much does it set aside for each
script? Or does it have a chunk of memory set aside as a pool for
all the scripts it runs? If so, how much memory does it set aside
for that pool?
As most of you know, the source isn't provided for this version
of Perl, so there's no way for me to check this out for myself
even if I felt brave enough to read through it! :)
I have tried searching AltaVista, DejaNews, activestate.com, etc.
for information on this problem but to no avail...
Thanks for any help you can provide.
Regards,
Thomas
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 30 Oct 1998 20:13:29 +0100
From: R. A. Larsen <r_larsen@image.dk>
Subject: Re: Need help with grep
Message-Id: <VA.0000006f.0002bf60@octo>
Josh Feinblum <toto@javanet.net> wrote:
>
> I was having some difficulties with grep and was wondering if anyone
> could help.
>
> I have a grep expression that needs to search for a pattern in an array
> and contained in the pattern is a value for a future variable. The
> problem is that grep doen't seem to set $1 and I was wondering if anyone
> had any ideas.
> Here the small bit of code
>
> @lines = <FILE>;
> grep {/<!-- INSERT TYPE="ADV" Value="(.*)" -->/} @lines;
> $location=$1;
You would be better of making a loop and use m// inside that loop.
grep returns ALL the lines from @lines that matches the expression. The way
you normally would use it is:
@lines = grep /<!-- INSERT TYPE="ADV" Value="(.*)" -->/, <FILE>;
Now @lines only contains the matching lines.
Then make a loop and use m// inside that loop.
I hope this helps.
Reni
--
Using Virtual Access
http://www.vamail.com
------------------------------
Date: Fri, 30 Oct 1998 19:02:41 GMT
From: w.wilson@mailexcite.com
Subject: need help with unbuffering
Message-Id: <71d2gh$bem$1@nnrp1.dejanews.com>
ok, I think I've figured out how to unbuffer and now when I print a scalar to
a new file and vi that file, it's there!(yeah!), but there's ..well, take a
look at this, cuz I don't know what it is
here's the script portion
print "\nSelect an entry to edit: ";
chomp($choice = <STDIN>);
open(TMP, ">$tmpfile") or die "Couldn't open file: $!";
TMP -> autoflush(1);
$to_edit = $choice_array[--$choice];
print TMP $to_edit;
system "vi $tmpfile";
the file opens to vi exactly how I would want it to, but when it's saved,
more shows up...this is the tmp file that's used.
-----------------------------------------------------------------------------
--- howdy Fri Oct 30 08:31:41 1998
-----------------------------------------------------------------------------
--- what's up you? #this part is what is presented when the file is
opened to vi
--------------------------------------------------------------------------------
howdy Fri Oct 30 08:31:41 1998
--------------------------------------------------------------------------------
what's up youuu? #this is the above, before it was edited, both in the
#same file, along with the stuff below.
#What's happening here???
s{^\"my\"\ variable\ .*?\ masks\ earlier\ declaration\ in\ same\ scope}
{\"my\"\ variable\ \%s\ masks\ earlier\ declaration\ in\ same\ scope}s
&& return 1;
m{^\"no\"\ not\ allowed\ in\ expression} && return 1;
and so on and so on.
********** related question, does the below look like it will do what I want
it to (copy the contents found above the edited entry to the newfile from the
oldfile, copy the contents of the newly edited tmpfile to the newfile, copy
everything found in the oldfile that comes after the edited entry into the
newfile.)??
open(NEW, ">$newfile") or die "Couldn't open file: $!";
NEW -> autoflush(1);
while(<OLD>) {
print NEW $_ until /$to_edit/;
}
while(<TMP>) {
print NEW $_;
}
while(<OLD>) {
next if $_ =~ $to_edit;
print NEW $_;
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 30 Oct 1998 18:57:34 GMT
From: Darrin Edwards <d-edwards@uchicago.edu>
Subject: Re: Not to start a language war but..
Message-Id: <tgsog5andt.fsf@noise.bsd.uchicago.edu>
pj@sgi.com (Paul Jackson) writes:
>
> klassa@aur.alcatel.com (John Klassa) wrote:
> |> The $, @ and % tell you what you're getting when all the dereferencing is
> |> done... Thus, @a is an array and $a[0] is the 0th element of @a, which is
> |> a scalar.
>
> ah -- that's (part of) what bothers me about the $, @ and %.
>
> The precedence is visually misleading.
Well, it's a syntactic structure, and thus a bit arbitrary (like
the syntactic rules of natural languages). It becomes (hopefully :))
less misleading with usage.
> These 3 symbols look like they bind tightly - high precedence.
> So $a[0] looks like it binds "($a)([0])" or in Quine's dot
> notation, "$a.[0]". But actually they have low precedence, applying
> to "all the dereferencing" term, as in "$(a[0])", or "$.a[0]".
>
> Strange -- very strange.
Only if one feels that _all_ operators should behave like, say,
mathematical operators (unary minus, for example). But this particular
"morphememe" is more like, say, an English article: "this math teacher"
is not someone who teaches "this math," and saying "these maths teacher"
will draw just as many funny looks from English speakers as "@a[0]" will
draw from Perl speakers (more, since the former is syntactically
_forbidden_, while the latter is just semantically a tad silly). (The
perldata manpage provides this kind of analogy with English articles.)
If it makes me sound silly giving these natural language analogies,
then I would just argue that just about every computer language is
going to have its own precedence quirks, which should be weighed
against its other merits when judging the language as a whole. (Even
if I allow that the prefix syntax is "strange" -- I still disagree
with "misleading" :) -- I would argue that it is _consistent_ syntax.)
Cheers,
Darrin
------------------------------
Date: Fri, 30 Oct 1998 13:07:17 -0800
From: Jason Orendorff <jorendorff@ixl.com>
Subject: Re: Not to start a language war but..
Message-Id: <363A2A85.FEA9D18C@ixl.com>
> : Anyway, Perl allows a lot of silent errors throughout the
> : language and libraries that would subvert any exception system
> : you might claim exists.
> "Silent" errors?
Yes, things like chdir('x') failing silently instead of throwing
an exception. We could be here all day listing 'em.
> Perl has had exceptions since version 1 (see recent followup in
> this same thread).
Yes, if you actually consider that exception handling. ;-)
It's certainly not anything approaching what Python can do.
> Ya seen JPL yet? Forget dispatching anything, just code Java
> methods in pure Perl! :-)
Haven't had the pleasure, actually.
> Ok, you win there. -If you actually consider WinCE a platform. :-)
:-) Sounds like a hedge to me.
--
Jason
any color you want, so long as it's black
------------------------------
Date: 30 Oct 1998 19:32:10 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: Not to start a language war but..
Message-Id: <71d47q$9rh$1@nnrp4.snfc21.pbi.net>
Nothing above this line is part of the signed message.
In article <363A2A85.FEA9D18C@ixl.com>,
Jason Orendorff <jorendorff@ixl.com> wrote:
>> : Anyway, Perl allows a lot of silent errors throughout the
>> : language and libraries that would subvert any exception system
>> : you might claim exists.
>> "Silent" errors?
>
>Yes, things like chdir('x') failing silently instead of throwing
>an exception. We could be here all day listing 'em.
What, exactly, do you find objectionable about checking return codes? I
don't particularly see the advantage of going nuclear to tell me that
a chdir failed...but if you insist....
chdir('somedirectory') or die("Oops...\n$!");
That wasn't very painful, now was it?
Benjamin Franz
Version: 2.6.2
iQCVAwUBNjoVt+jpikN3V52xAQGzEwP/R/IbJDn0zTBYxSSy9YfEKZBcfbDTCG6U
RDfKcgSO5ByNCxXQ+LdzmIcMWF5rxZCrB6iailEjCQdo2xa6xbLCmdVDo89SCwEg
pgeW9fIauTsYZ+mYn27bQFML0TeXMu8PU/GGePbmEoWberF+y7WmlmL1qYKsdKHx
oT/s5lUBzwg=
=qBhN
-----END PGP SIGNATURE-----
------------------------------
Date: Fri, 30 Oct 1998 15:41:03 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Not to start a language war but..
Message-Id: <363A245F.2F552D73@min.net>
Dave Kirby wrote:
>
> Zenin <zenin@bawdycaste.org> wrote:
> >John Porter <jdporter@min.net> wrote:
> >: 'package' doesn't actually relate to Perl's OO in any special way;
> >: it just changes the default namespace for any following unqualified
> >: declarations.
> >
> > It also affects the single argument form of bless() in ways that
> > will make the above example fail:
>
> Doesnt the fact that two (presumably) experienced perl programmers can
> disagree on this blow the foot off your assertion that creating a
> class in perl is as easy as creating one in python?
Maybe it would, except for the fact that we don't disagree.
As I have already said, the point of my little code snippet
was to show that the 'package' word is not required to get
classes in Perl. I should have given some non-constructor
method, like
sub Widget::popup { my $self = shift; }
John Porter
------------------------------
Date: Fri, 30 Oct 1998 15:49:53 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Not to start a language war but..
Message-Id: <363A2671.7DB34B6D@min.net>
Dave Kirby wrote:
>
> I and many others have stated that they found python easier to learn
> than perl, but no-one who has learnt both languages has said they
> found perl easier to learn. As for not sacrificing any power, can you
> provide an example of something that can be done easily in perl that
> cannot be done easily in python?
Wow, like, deja news!
Btw, how's George Reese these days?
John Porter
------------------------------
Date: Fri, 30 Oct 1998 20:43:54 GMT
From: "Andrew M. Kuchling" <akuchlin@cnri.reston.va.us>
Subject: Re: Not to start a language war but..
Message-Id: <13882.9084.967572.851500@amarok.cnri.reston.va.us>
Snowhare writes:
>>Yes, things like chdir('x') failing silently instead of throwing
>>an exception. We could be here all day listing 'em.
>
>What, exactly, do you find objectionable about checking return codes? I
>don't particularly see the advantage of going nuclear to tell me that
>a chdir failed...but if you insist....
Because people don't always check them, which results in
programs that run merrily onward despite encountering a problem. For
example, see the "Fuzz Revisited" paper by Barton P. Miller et al,
which found that many Unix utilities crashed on random data, and most
of the errors were simple ones, like not checking the return value of
malloc().
For another example, the other day, I was uncompressing a file
with bzip2 and it kept producing a zero-length file. Turned out the
partition was full, and bzip2 didn't give me any warning that it
couldn't write its output. The problem would have been much clearer
if the language bzip2 was written in had raised a DiskFullException,
or even just a CantWriteOutputException.
--
A.M. Kuchling http://starship.skyport.net/crew/amk/
MAN: But I am a man.
WOMAN: Yes, to a degree. That is a trifle abnormal. But not insurmountable.
-- Myrna Lamb, "But What Have You Done For Me Lately"
------------------------------
Date: Fri, 30 Oct 1998 19:38:40 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Parsing large text file (TIA)
Message-Id: <363c0e3c.3240135@news.ping.be>
christian.aranda@iiginc.com wrote:
>I need to parse through a large text file, search for key words (static)
>and extract all the data until the next key word, put it into a variable
>(for later manipulation) and contine through all the records. Caveat:
>The data after the key word can span multiple (read 50-100) lines.
>Below is a sample of the data I need to parse:
>
>PersonId:802.111
>FirstName:Christian
>LastName:Aranda
>Description:This person needs to blah blah ....
>more text
>more text
>more text
>PersonId:803.000 <-----NOTE: New Record
>FirstName:
Here's my attempt:
while(<>) {
chomp;
if(s/^(\w+)://) {
$field = $1;
if($field eq 'PersonId') {
# new record
push @record,{};
}
# new field
$record[-1]{$field} = $_;
} else {
# append to field
$record[-1]{$field} .= "\n$_";
}
}
At least, I hope that your data lines never start with a word followed
by a colon. That would throw off my code.
You'll end up with an array of anonymous hashes, err... hashrefs.
Bart.
------------------------------
Date: Fri, 30 Oct 1998 21:16:49 +0100
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Perl DCOM Question -- setting property
Message-Id: <363d1e56.4236922@news3.ibm.net>
[mailed & posted]
caulds@mindspring.com (Charles Aulds) wrote:
>I can read the value of a property:
>
> $value=$ctrl->Count;
>
>Why can I not set the value of that same property, using either of the
>following?
>
> $ctrl->Count=5;
> or $ctrl->put_Count(5);
>
>What am I missing?? I trust you guys to know! ;-)
The correct syntax is:
$ctrl->{Count} = 5;
You need to read the Win32::OLE documentation some more. :-)
-Jan
------------------------------
Date: Fri, 30 Oct 1998 19:19:25 GMT
From: toffie@my-dejanews.com
Subject: Re: Perl ODBC - SQL Functions RTRIM, LTRIM
Message-Id: <71d3fs$d0j$1@nnrp1.dejanews.com>
In article <36374b75.25199906@news.demon.co.uk>,
max@virtualf.com wrote:
> Hi,
> has anybody experienced strange behaviour executing SQL statements
> using ODBC.pm with LTRIM & RTRIM functions?
>
> This statement:
>
> select question#, LTRIM(RTRIM(optionVal))), option_text,
> LTRIM(RTRIM(answer)))
> from wgp_quiz_answer where course#=3 and chapter#=1 and
> session#=1 and quiz#=1
> order by question#, optionVal
>
> returns the following results when executed in the SQL Server query
> tool:
>
> question# option_text
> --------------- --- ------------------------- ----------
> 6 1 Moves the b
>
> 6 10 Reverses the c
> 6 2 Moves the j
>
> 6 3 Deletes the f
> 6 4 Reverses the a
>
> This are correct. However, when executing using Perl ODBC, the
> following results are returned:
>
> question# option_text
> --------------- --- ------------------------- ----------
> 6 b Moves the b
>
> 6 c Reverses the c
> 6 j Moves the j
>
> 6 f Deletes the f
> 6 a Reverses the a
>
> As you can see, something strange has happened with the 2nd field. If
> I remove the LTRIM and RTRIM functions from the select field list,
> then the query executes correctly. Note that Microsoft documentation
> states that these functions are valid with ODBC versions 1.0 and
> greater.
>
> Therefore my hunch is that these functions are not fully supported by
> Perl ODBC.
>
> Does anyone have any insight into this one?
>
> Regds,
> Max.
>
I'd never believe that this could be caused by Perl (or the way he interfaces
to ODBC). First of all I would suggest to use the ODBC Escape syntax for
Scalar functions. This would make the SQL look like:
select question#, {fn LTRIM({fn RTRIM(optionVal)})}, option_text,
{fn LTRIM({fn RTRIM(answer)})} ...
This way the driver will convert these standarized functions to functions
that are understood by the database. If the problem stays then this certainly
looks like a good ol' ODBC driver bug. Maybe you can test this out via
another application like MSAccess or MSquery by submitting the same SQL via
the driver to the database. If the problem can be reproduced like that you
can be sure that it is something in the driver that is causing this. Now as
MS is offering the SQLServer driver for free you cannot request any bug-fixes
on this, but maybe the last version of the driver in the MSDAC 2.0 package
(downloadable from http://www.microsoft.com/data/download.htm) contains a fix
for this problem. Should this not help, you can always try it out with the
SQLServer driver from Intersolv (free download possible from
www.intersolv.com (I think)) Hope his helps, Toffie
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 30 Oct 1998 14:15:37 -0500
From: "_Paul Coleman" <Paul.Coleman@CoSeCo.com>
Subject: Re: persistent variables ?
Message-Id: <363a1412.0@news3.paonline.com>
Hi Bart,
Thank you. I will look at this solution in more detail, it sound as it will
work out. I was hoping for a module or package that was complete. I didn't
have the time to build this for my example at
http://www.coseco.com/serendipity. the first part is a catalog written in
ASP the second part is a search function written in Perl. Notice the long
URL when the next and previous link is selected on the Perl search function.
This is what I was trying to avoid. I will take your suggestion and polish
up this code in the future as I don't like displaying all of that data in
the URL to be seen.
Thanks,
Paul Coleman
Bart Lateur wrote in message <36399988.10920133@news.ping.be>...
>
>Now that all the commotion has settled down a bit, I'll take a stab at a
>possible solution. :-)
>
>I'll be brief on the CGI side.
>
>First, try adding some more data in the URL, as if the script's name was
>a mere directory. Try looking at your environment variables on the CGI
>side, and see if you can get it there. Especially watch out for
>$ENV{PATH_INFO}. If you're lucky, the extra data in the URL should be
>there.
>
>If that works, you must generate a unique session ID, and the first
>time, redirect the browser to the URL with this session ID appended.
>
>That's all for CGI. Now the Perl side.
>
>I wouyld stay away from "real" dB's, unless they can actually be kept
>running in the background. They'd take forever to start up.
>
>You can try out the Data::Dumper module, but I wouldn't use it for
>"real" work. It's not very fast for frequently run code, and it's not
>too taint safe. You're writing code in a *data* file, and execute it
>next time? ANY hacker can overwrite that data file -- it needs to be
>world writable -- with his own Perl code, and next time this code will
>be executed. Urgh.
>
>My solution is a simple text, tab delimited, data file, one per session.
------------------------------
Date: Fri, 30 Oct 1998 20:40:26 GMT
From: gosdpads@yahoo.com (Danny Groppo)
Subject: Re: Regex Explaination... Ignore
Message-Id: <363a2400.1395758244@nntp.cts.com>
On Fri, 30 Oct 1998 20:30:24 GMT, gosdpads@yahoo.com (Danny Groppo)
wrote:
DUH. I was working without the /g modifier. Lemme look at this
problem again with /g in place :)
>I was hoping you can try to explain this for me. When I run:
>
>$string = "12385";
>@zips = $string =~ m/(?:\d)(\d)/;
>print "Value of \$1: $1\n";
>for (@zips) { print "$_\n"; }
>
>I get:
>
>Value of $1:
>1
>
>Which is explainable, because I do not have any capturing parentheses.
>
>But if I change the regex to (?:\d)(\d) to capture "1" in $1 (which is
>$zip[0]) as follows:
>
>$string = "12385";
>@zips = $string =~ m/(?:\d)(\d)/;
>print "Value of \$1: $1\n";
>for (@zips) { print "$_\n"; }
>
>The ouput is:
>
>Value of $1: 2
>2
>
>Which I don't understand. I thought I am only using the parentheses
>for capturing, but it seems it is doing some grouping that effects my
>$1.
>
>My understanding of the lookahead is that it matches position in a
>string similar to the way a word boundary does. So since the engine
>begins at the nothingness right before the first character, shouldn't
>it the (?:\d) see that there is a number (1) and evaluate to true.
>Since lookaheads don't consume any of the target string, shouldn't the
>engine then look at the (1) and put it in $1?
>
>Why doesn't it? And more interestingly to me, why, when the
>parentheses are removed, is 1 put as $zips[0]?
>
>
>
>
>
>Danny Groppo
>gosdpads@yahoo.com
Danny Groppo
gosdpads@yahoo.com
------------------------------
Date: Fri, 30 Oct 1998 20:30:24 GMT
From: gosdpads@yahoo.com (Danny Groppo)
Subject: Regex Explaination...
Message-Id: <363a1ca3.1393873764@nntp.cts.com>
I was hoping you can try to explain this for me. When I run:
$string = "12385";
@zips = $string =~ m/(?:\d)(\d)/;
print "Value of \$1: $1\n";
for (@zips) { print "$_\n"; }
I get:
Value of $1:
1
Which is explainable, because I do not have any capturing parentheses.
But if I change the regex to (?:\d)(\d) to capture "1" in $1 (which is
$zip[0]) as follows:
$string = "12385";
@zips = $string =~ m/(?:\d)(\d)/;
print "Value of \$1: $1\n";
for (@zips) { print "$_\n"; }
The ouput is:
Value of $1: 2
2
Which I don't understand. I thought I am only using the parentheses
for capturing, but it seems it is doing some grouping that effects my
$1.
My understanding of the lookahead is that it matches position in a
string similar to the way a word boundary does. So since the engine
begins at the nothingness right before the first character, shouldn't
it the (?:\d) see that there is a number (1) and evaluate to true.
Since lookaheads don't consume any of the target string, shouldn't the
engine then look at the (1) and put it in $1?
Why doesn't it? And more interestingly to me, why, when the
parentheses are removed, is 1 put as $zips[0]?
Danny Groppo
gosdpads@yahoo.com
------------------------------
Date: 30 Oct 1998 20:33:09 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: Regex Problem
Message-Id: <71d7q5$bh16@mercury.adc.com>
In article <01be0421$5f45e2c0$6296cdcf@hp-customer>,
George H <george@tapestry.net> wrote:
>I am trying to remove chunks of a query string from the middle of
>QUERYSTRING for some regexp practice. The following works fine for
>removing '&movie=Star+Wars&' and replacing it with a '&' (yes, I know this
>misses items at the end or beginning of the query ... this is just an
>exercise). However, if the query string looks like '&movie=&' it doesn't
>work. I thought '*' would work because it is 0 or more ... but I am
>missing something.
>
>Any ideas?
Several. But I should start by saying that I don't see the problem
you're having. I tried your exact example with the same data and it
did the substitution just fine. However, maybe something in the rest
of my comments will help with what you're seeing.
First, you're backwhacking way too much stuff. "=" and "&" aren't
regex metachars.
Second, you're not accounting for the possibility of $remove
containing regex metachars. You can take care of this by either using
the quotemeta function on $remove, or by surrounding $remove with "\Q"
and "\E" in the regex.
Third... and this may fix your problem... you're not accounting for
two adjacent matches. So, if your string was, "&movie=foo&movie=bar&",
only the first one would be changed. You can fix this with a
zero-width lookahead, so that the trailing "&" doesn't get sucked into
the match. So, your match line should look like this:
$querystring =~ s/&\Q$remove\E=[^&]*(?=&)//g
>foreach $remove (@removals)
> {
> if($jobinfo{$remove})
> {
> $querystring =~ s/\&$remove\=[^\&]*\&/\&/g;
> }
>}
Enjoy!
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: Fri, 30 Oct 1998 12:11:44 +0000
From: Jeff Kiser <jeffk@synplicity.com>
Subject: system statistics from Perl
Message-Id: <3639AD00.655694D0@synplicity.com>
I was curious if there is a way (either with the standard distribution
or via modules on CPAN) that anyone knows to obtain system statistics
such as CPU utililization, available memory, etc. in a perl script.
Thanks
Jeff Kiser
jeffk@synplicity.com
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4113
**************************************