[16328] in Perl-Users-Digest
Perl-Users Digest, Issue: 3740 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 21:10:23 2000
Date: Tue, 18 Jul 2000 18:10:14 -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: <963969014-v9-i3740@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 18 Jul 2000 Volume: 9 Number: 3740
Today's topics:
Re: NEW: AI::NeuralNetwork - idea, comments <sumus@aut.dk>
Re: NEW: AI::NeuralNetwork - idea, comments <godzilla@stomp.stomp.tokyo>
Re: Non-printed characters (Abigail)
Novice needs help with CGI script <bo@bo.com>
Re: Numerical evaluation in string (Matthew Zimmerman)
Re: Passing command line regexp into perl program <bwalton@rochester.rr.com>
Re: Perl job offered San Mateo Perm (Andrew J. Perrin)
Re: Perl job offered San Mateo Perm <?@?.?>
Re: re problem (Neil Kandalgaonkar)
Re: re problem (Abigail)
Re: Sorting multidimensional arrays <makarand_kulkarni@my-deja.com>
Re: Suggestion for syntax change (jason)
Re: Suggestion for syntax change (jason)
Re: Suggestion for syntax change <bart.lateur@skynet.be>
Taint mode question <jondunn@speakeasy.org>
weird eval problem <jasonb885@my-deja.com>
Re: Yet another string manipulation question - (jason)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Jul 2000 00:25:06 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: NEW: AI::NeuralNetwork - idea, comments
Message-Id: <wvijdqkd.fsf@macforce.sumus.dk>
logan@cs.utexas.edu (Logan Shaw) writes:
> I do agree that AI is a bit of a misnomer, but so are many other things
> in computer science which are named by analogy.
But there's still the matter of convention.
I'm a complete novice with regards to AI and neural networks but if I'm not
wrong the network model described in the original post is of the
feedforward backpropagation type. If this is the only type of neural network
the module is able to simulate perhaps the name should be more specific.
After all there are numerous other types op neural networks.
Without aligning myself with Godzilla I'd also like to question the use of
AI.
I believe that AI by convention is based on symbol manipulation. Neural
networks provide one way of implementing such. But the pattern classification
achieved by the network model described in the OP is not actually an example
of AI as far as I know.
Generally speaking, neural networks are not an AI concept though they may be
used in AI. Therefore placing them hierarchically under AI in the name space
might be misleading.
I don't hope I'm all wrong here?
--
Jakob
------------------------------
Date: Tue, 18 Jul 2000 17:33:58 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: NEW: AI::NeuralNetwork - idea, comments
Message-Id: <3974F776.991A457C@stomp.stomp.tokyo>
Jakob Schmidt wrote:
> logan@cs.utexas.edu (Logan Shaw) writes:
(snippage here and there, context retained)
> > I do agree that AI is a bit of a misnomer, but
> > so are many other things in computer science
> > which are named by analogy.
> But there's still the matter of convention.
As to be expected with society, convention
within this field, Artificial Intelligence,
is no more standardized than our computer
technology as a collective whole. Convention,
as a term, is more applicable to a passed hotel
key and c-notes in a lounge bar than it is
as a meaningful word of our language.
Yossi Mamroud of Tel-Aviv University maintains
a decent a site page with an excellent list of
sites related to this thread topic. You will
find some links for neural networking.
http://spinoza.tau.ac.il/hci/dep/philos/ai/links.html
> I'm a complete novice with regards to AI and neural
> networks but if I'm not wrong the network model
> described in the original post is of the feedforward
> backpropagation type. If this is the only type of
> neural network the module is able to simulate perhaps
> the name should be more specific.
Neural networking, in a classic conventional sense,
is a system, not always computational, which mimics
or is modeled after the nervous system of a brain,
be it a human brain or a slug's brain. An accepted
given with this term, is parallel processing by
two or more microprocessors, as this applies to
our specific interest, computers, However, in
reality, this parallel processing usually takes
place with hundreds, even thousands of unique
microprocessors such as today's super computers
employ. Perhaps a practical example would our
new dual processor computers often used for
internet service providers. Still, this is
not a classic example of parallel processing
but rather simply a computer with two CPUs.
For a module to exhibit parallel processing,
especially with Perl, this is quite the coding
challenge and most would agree, impossible.
Perl is inherently linear in nature. I would
suppose a complex looping nest, might be a
construed parallel process, yet it is still
linear in nature regardless of iteration; it
has a definitive begin and end point with
singularity processing taking place.
After reviewing links at Mamroud's site, after
a bit of research, most would find supporting
a debate our Perl language can be non-linear
parallel processing in behavior, most would
find this a dubious debate position.
This claim by the author of this module, his
programming is based upon neural networking,
causes me to raise a Vulcan skeptical eyebrow.
> I believe that AI by convention is based on
> symbol manipulation. Neural networks provide
> one way of implementing such. But the pattern
> classification achieved by the network model
> described in the OP is not actually an example
> of AI as far as I know.
You have touch upon an infinitely large can of
worms which AI specialists and experts feast upon
daily. Symbology and pattern recognition are amongst
the crux premises of Artificial Intelligence. This
can be well exemplified with a peach.
Now ain't that a peach!
She's a real peach alright!
This is a right fuzzy peach.
Oh what seductive peach fuzz.
There's a juicy peach I would love to eat.
Talk about a Georgia Peach!
This is just peachy keen.
Delicate peach fuzz outside, sweet pink meat inside.
That creep is a real peach. Shoot him.
He is a nark, a real peach. Shoot him as well.
Heidi is a famous peach providing tasty delights.
Goodness, this Heidi is hard bargining peach.
You and myself could sit for hours on my veranda
sipping chilled champagne, nibbling ever so sweet
strawberries, debating for hours when a peach
is and when a peach isn't. In the end, we would
be mildly tipsy, red lipped and no more in any
aggreement than when we initially popped a cork.
I do believe even Mr. Wall himself would be
challenged beyond his skills to develop a
module which could distinquish when a peach
is and, when a peach is not, based on this
small handful of example sentences I have
provided, hinting at a peach of a subject.
There is absolutely no doubt, there will be
more, a lot more, symbolic interpretations
of those sentences than there are lame AOL
people posting "me too" across USENET since
an Abigail peach of a September, so long ago.
This author of this module under discussion,
has made a formal claim his technique will
be able to categorize those sentences and
formulate a correct response or, at least
learn to provide a correct response. Spock
would respond, "Fascinating." Kirk, well you
know he would demand resolution answers and,
eat an exotic green peach while awaiting.
> Generally speaking, neural networks are not
> an AI concept though they may be used in AI.
> Therefore placing them hierarchically under
> AI in the name space might be misleading.
Well, yes, sorta. Neural networking is a major
foundation of AI; the hardwiring, or I should
say one type of potential hardwiring. For AI
and neural networking, an analogy of the type
of processing taking place, would be liken to
all the world's roller coasters, multiplied
by a Sagan Billion, collected together and
all running, in Sting's Synchronicity and,
at an appropriate moment, colliding together
into a coherent jumble of thoughts, with a
subdued utterance, "What a peach of a Ride."
Which reminds me, a single capital letter
completely changes context, in this case,
my final quoted utterance, a reference to
feminine beauty, feminine intellect and
one heck of a ride, off planet.
> I don't hope I'm all wrong here?
Enlightened, sound thinking people ask
this question of yours, constantly. This
leads to better critical thinking.
I am, of course, scientifically skeptical
this module's author is presenting his
creation for what it truly is. Sound thinking,
sound logic, both suggest some exaggeration.
My stance on using a name for this module which
suggests Artificial Intelligence, remains; it
is inappropriate and a slap across the faces of
those thousands of people dedicated to true
AI research and development.
Nonetheless, a final decision on this alleged
module's name, is the author's sole propriety.
It's his peach to eat.
As for this ignorant jerk who suggested I need
to medicate myself with prozac, I would politely
suggest you visit with the Wiz for enlightenment
and a brain, lest next time, I intellectually come
down on you so hard, you will need to unzip your
pants to see where you are going.
Godzilla!
------------------------------
Date: 18 Jul 2000 18:32:00 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Non-printed characters
Message-Id: <slrn8n9no7.3do.abigail@alexandra.delanet.com>
Kevin Hannbih Wong (gte097p@prism.gatech.edu) wrote on MMDXIII September
MCMXCIII in <URL:news:8l2fdj$2rv$1@news-int.gatech.edu>:
__ I'm writing a simple script that simply prompts the user for his/her and
__ phone number and stores it into a file. The thing is when the user hits
__ the backspace key it will go back and let you type over the character, but
__ when you go back and examine the output file you will see all those
__ backspace characters entered.
__ Is there anyway I can get around this?
Maybe, but that isn't a Perl issue. That has to do with the terminal the
user is using. You might want to read up on stty.
However, it seems like you need to do some testing before saving to
file. You seem to blindly accept non digits as phone numbers.
Abigail
--
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
${qq$\x5F$} = q 97265646f9 and s g..g;
qq e\x63\x68\x72\x20\x30\x78$&eggee;
{eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'
------------------------------
Date: Tue, 18 Jul 2000 20:54:55 -0400
From: "Bo" <bo@bo.com>
Subject: Novice needs help with CGI script
Message-Id: <8l2u1c$30i$1@slb7.atl.mindspring.net>
I've only started learning Perl a few days ago, and I would like
to ask for some guidance (or even outright help! 8-) if possible.
I'm trying to modify a pre-existing script (not mine -it appears
below)
that culls input data off an HTML page and sends plain-text email to
a number of people on a list (all stored on a network UNIX server).
What I'd like to do is be able to send .gif and .jpeg file attachments
along with the plain-text file attachment. This would require changes
to the MIME headers in the script as well as some other slight
modifications.
Since I'm not completely up to speed with Perl yet {not enough
hours in the day for that, and the books are bulky and tedious ;-( }
i'm hoping some good folk on this ng would reply and show me
a couple of things. (btw -I've checked out the MIME-lite page
but it may be too much to absorb at this point)
Thanks a lot. Please reply here or to hawk128@hotmail.com
=========================================
#!/usr/bin/perl
use MIME::Lite;
print "Content-type:text/html\n\n";
print "<html>";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@section = split(/-----------------------------/, $buffer);
shift(@section);
pop(@section);
foreach $section (@section) {
chop($section);
}
$serial = substr($section[0],0,index($section[0],"\n"));
chop($serial);
$email = substr($section[0],rindex($section[0],"\n"));
$email = substr($email,1);
chop($email);
$subject = substr($section[1],rindex($section[1],"\n"));
$subject = substr($subject,1);
chop($subject);
for($i = 0; $i < 4; $i ++) {
my $subsection = substr($section[2],index($section[2],"\n"));
$section[2] = substr($subsection,1);
}
$distribution_list = ">/tmp/be_dist." . $serial;
open(distribution_list);
print distribution_list $email,"\n";
print distribution_list $section[2];
close(distribution_list);
$distribution_list = substr($distribution_list,1);
$section[3] = substr($section[3],index($section[3],"text/"));
$type = substr($section[3],0,index($section[3],"\n"));
chop($type);
for($i = 0; $i < 2; $i ++) {
my $subsection = substr($section[3],index($section[3],"\n"));
$section[3] = substr($subsection,1);
}
$message = new MIME::Lite
Subject =>$subject,
Type =>$type,
Data =>$section[3];
$command = substr($section[4],rindex($section[4],"\n"));
$command = substr($command,1);
chop($command);
if($command eq "SEND") {
print "<i>Sending message...</i> ";
$output = "/tmp/be_out." . $serial;
open(BE,"|bulk_mailer > $output $email $distribution_list");
$message->print(\*BE);
close(BE);
print "<h1>Message Sumbitted</h1><br>";
print "<p><h3><i><a href=\"/bulk_email.html\">Click here ";
print "to return to bulk e-mailing page.</a></i></h3></html>";
unlink $output;
}
else {
print "From: ",$email,"<br>";
print "Subject: ",$subject;
print "<p>";
if($type eq "text/plain") {
print "<pre>";
}
print $section[3];
}
unlink $distribution_list;
============================================
------------------------------
Date: 18 Jul 2000 23:18:34 GMT
From: mdz4c@node1.unix.Virginia.EDU (Matthew Zimmerman)
Subject: Re: Numerical evaluation in string
Message-Id: <8l2oka$rcm$1@murdoch.acc.Virginia.EDU>
In article <8l25kp$2gp$1@nnrp1.deja.com>,
Vinod K. Menon <anuragmenon@my-deja.com> wrote:
>Hey guys..
>
>yet another question..how do I make a calculation inside a double
>quoted string?
You can play tricks with references to do this, e.g.:
print "@{ [ 133/100-1 ] } is the answer.\n";
How does this work? The inner square brackets take the code inside them,
put them into list context (in this case, a single scalar with the value
0.33), and returns a reference to the list. Then the surrounding @{ ... }
dereferences the reference and interpolates the results into
the string. See
perldoc perlref
for more info on this. This is a useful thing to do in heredocs, but
AFAIK, not so much anywhere else.
HTH!
Matt
--
--
|Matthew Zimmerman http://www.people.virginia.edu/~mdz4c |
|Interdisciplinary Biophysics Program |"I AM serious. |
|University of Virginia | And stop calling me Shirley."|
------------------------------
Date: Tue, 18 Jul 2000 22:03:44 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Passing command line regexp into perl program
Message-Id: <3974D47F.65C7B82E@rochester.rr.com>
Don McCorvey wrote:
>
> I'm tweaking a program which reads in two fields out of a text file,
> pattern matches on one field, and prints out any records which match.
> One version of the program works but matches against the entire printed
> record which I run through perl's grep function to select out the
> matching ones.
>
> The version which doesn't work attempts to look at the fields as the
> text file is read in and matches it:
I agree it doesn't work -- it doesn't even compile! (*please*
copy/paste your code rather than retyping it)
>
> if (field2 =~ eval($regexp) {
$-------------^
>
> print field1, "\t", field2, "\n";
$-------------------^-------------^
>
> }
>
> Where $regexp is a parameter provided in quotes on the command line.
> ($regexp = $ARGV[0])
>
> Whenever I run this particular variation of the program, it returns ALL
> of the records in the file, even when the other version, using the
> identical regexp returns the correct result - but cannot be used with a
> "^" pattern match operator since field1 is already prepended to each
> record in the array.
>
> Can someone please explain what I'm doing wrong ?
...
> Don McCorvey
> Houston, Tx
Why are you eval'ing the argument? That will treat the argument as a
Perl program, and, assuming it compiles and executes (which is unlikely
if it is a regex), will return the results of the last statement in it
which was executed. That is almost certainly not what you want.
Chances are it didn't compile, returned an undef which compiled into a
null regex, which always matches. How about:
if($field2 =~ /$regexp/) {
...
--
Bob Walton
------------------------------
Date: 18 Jul 2000 19:32:01 -0400
From: aperrin@socrates.berkeley.edu (Andrew J. Perrin)
Subject: Re: Perl job offered San Mateo Perm
Message-Id: <uwvij2exa.fsf@socrates.berkeley.edu>
ebohlman@netcom.com (Eric Bohlman) writes:
> zack3011@my-deja.com wrote:
> : Zack Network is the Internet's leading server-side infomediary. Using its
> : unique ability to sit between users and the Web, the company has introduced a
> : new paradigm of online content or functionality delivery: a next generation
> : enabling technology. Zack's server-side application platform, the Zack
> : Engine, is designed exclusively for Internet Service Providers and content
> : providers. The technology can deliver any type of content or functionality to
> : users in real time anywhere on the Internet.
>
> Was this the output of an AS (Artificial Stupidity) program?
It really does sound like comedy - every meaningless buzzword of the
computer industry, strung together.
ap
--
--------------------------------------------------------------
Andrew J. Perrin, Ph.D. Candidate, Sociology, UC Berkeley
Consulting: Solaris-Linux-NT-Samba-Perl-MS Access-Postgres
aperrin@socs.berkeley.edu - http://demog.berkeley.edu/~aperrin
--------------------------------------------------------------
------------------------------
Date: Wed, 19 Jul 2000 00:07:43 GMT
From: "Kliffoth" <?@?.?>
Subject: Re: Perl job offered San Mateo Perm
Message-Id: <jj6d5.412162$k22.1840878@flipper>
> Otherwise I am sorry to take up your time.
That;s allright, I don't mind a good laugh!
> Cheers!
What the hell, lets open another cold-one! CHEERS!!!
------------------------------
Date: Tue, 18 Jul 2000 23:48:58 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: re problem
Message-Id: <8l2q0d$1n5$1@localhost.localdomain>
In article <slrn8n9gf2.3do.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
>Here's a generic solution.
>
> my $text = "cows";
> my $new = "sheep";
> my $occur = 2; # Replace second "cows" with "sheep".
> s{^((?:(?:(?!$text).)*$text){${\($occur - 1)}}(?:(?!$text).)*)$text}
> {${1}$new}s;
If you are not worried about efficiency:
my $count;
$string =~ s/$text/++$count == $occur ? $new : $text/eg;
You can use this to match stuff like every third occurrence.
s/$text/++$count % 3 ? $text : $new/eg;
BTW, if $text might contain regex metacharacters, like ".", use
quotemeta() to escape them, or use \Q within the regex.
--
Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: 18 Jul 2000 20:09:06 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: re problem
Message-Id: <slrn8n9te8.3do.abigail@alexandra.delanet.com>
Neil Kandalgaonkar (neil@brevity.org) wrote on MMDXIII September MCMXCIII
in <URL:news:8l2q0d$1n5$1@localhost.localdomain>:
%% In article <slrn8n9gf2.3do.abigail@alexandra.delanet.com>,
%% Abigail <abigail@delanet.com> wrote:
%%
%% >Here's a generic solution.
%% >
%% > my $text = "cows";
%% > my $new = "sheep";
%% > my $occur = 2; # Replace second "cows" with "sheep".
%% > s{^((?:(?:(?!$text).)*$text){${\($occur - 1)}}(?:(?!$text).)*)$text}
%% > {${1}$new}s;
%%
%%
%% If you are not worried about efficiency:
%%
%% my $count;
%% $string =~ s/$text/++$count == $occur ? $new : $text/eg;
%%
%% You can use this to match stuff like every third occurrence.
%%
%% s/$text/++$count % 3 ? $text : $new/eg;
%%
%% BTW, if $text might contain regex metacharacters, like ".", use
%% quotemeta() to escape them, or use \Q within the regex.
Unless of course you *want* $text to contain regex metacharacters.
Abigail
--
$" = "/"; split $, => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
------------------------------
Date: Tue, 18 Jul 2000 16:27:18 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: yfan1@nortelnetworks.com
Subject: Re: Sorting multidimensional arrays
Message-Id: <3974E7D6.20FED985@my-deja.com>
Young wrote:
>
> Hi,
>
> Can you tell me how to sort a multidimensional array?
> How do I do this?
check the Schwartzian transform
http://www.5sigma.com/perl/schwtr.html
for more sorting power.
-
------------------------------
Date: Tue, 18 Jul 2000 23:27:17 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Suggestion for syntax change
Message-Id: <MPG.13df8526412466589896ea@news>
Keith G. Murphy wrote ..
>Jakob Schmidt wrote:
>>
>> Bart Lateur <bart.lateur@skynet.be> writes:
>>
>> > Jakob Schmidt wrote:
>> >
>> > >Your wish would require that the .. operator behaved in a different manner
>> > >when it finds itself used in array indexing than in other contexts. Isn't
>> > >that a bit... erm... ugly?
>> >
>> > You mean, like context sensitive? Gee, there's a novel idea. No, in Perl
>> > there's absolutely nothing that is context sensitive.
>>
>> I deliberately didn't say that. I just asked if this specific example wouldn't
>> be ugly.
>>
>> Well, wouldn't it?
>>
>It could get quite interesting, if it were context-sensitive, and could
>also count down as well as up.
>
>For instance:
>
>@list = (apple boy cow dog);
>
>@list[1..-1] would be qw(boy, cow, dog)
>
>@list[1..-4] would be qw(boy apple)
no no no .. I would imagine it as being perfectly universal through all
it's use .. the '..' operator would just be able to count down as well
as up .. so
1..-1 would be equivalent to (1, 0, -1)
that already has meaning in list context .. with your qw(apple boy cow
dog) list above @list[1,0,-1] produces the list qw(boy apple dog) .. and
@list[1..-1] should do the same .. ditto @list[1, 0, -1, -2, -3, -4]
produces the list qw(boy apple dog cow boy apple) .. so @list[1..-4]
should do the same
if you really want a reverse list then it's easy enough to get by using
$#list .. so I don't know what the point would be in providing the same
functionality through a special context-sensitive version of the new
decrementing '..' when you get much better functionality by keeping it
universal and non-context-sensitive
>I think I like it. Remember, this would only obtain in list subscript
>context. Outside that context, '1..-1', for instance, doing '1, 0, -1'
>would also be a nice addition.
would be a nice addition in list context as well .. saves having to
reverse the list if you want it reversed .. perfect for localtime()
calls amongst hundreds of others
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Tue, 18 Jul 2000 23:46:44 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Suggestion for syntax change
Message-Id: <MPG.13df89bbdd9462ad9896eb@news>
jason wrote ..
>if you really want a reverse list then it's easy enough to get by using
>$#list
that's a little vague .. of course my proposed decrementing behaviour of
'..' would produce the 'reverse list' .. I really meant "if you really
want to index elements from the end of the list then it's easy enough to
do using $#list"
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 19 Jul 2000 01:56:40 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Suggestion for syntax change
Message-Id: <tjr9nssjtk4345i5uqhmj6ohe2sphqgj37@4ax.com>
jason wrote:
>if you really
>want to index elements from the end of the list then it's easy enough to
>do using $#list
Won't do if you don't know beforehand how many items there are, for
example, if you're talking about an actual list, not an array.
--
Bart.
------------------------------
Date: Tue, 18 Jul 2000 16:47:15 -0700
From: "Jonathan C. Dunn" <jondunn@speakeasy.org>
Subject: Taint mode question
Message-Id: <Pine.LNX.4.21.0007181643400.26360-100000@grace.speakeasy.org>
I've created the "safe backticks" construction from the perlsec man page.
1) Why can I pass in all of @ARGV to exec with no problem, but when I pass
$ARGV[0] I get "insecure dependency..." ?
2) What alternatives are there (to the exec construction)? I can stick an
"undef" onto the array, but that louses up some functions...
Thanks.
Jonathan Dunn
jondunn@speakeasy.org
http://www.speakeasy.org/~jondunn/
------------------------------
Date: Wed, 19 Jul 2000 00:08:32 GMT
From: |Odo| <jasonb885@my-deja.com>
Subject: weird eval problem
Message-Id: <8l2rhm$jls$1@nnrp1.deja.com>
I have a subroutine which I use to call token parsing routines, like so:
sub parse {
my ($self,$line,$h) = @_;
my ($value,$token) = undef;
my @tlist = ($line =~ m/\${(.*?)}/gis);
foreach $token (@tlist) {
my($func,$opts) = $self->parse_token($token);
$value = eval '$self->'.${ $func }.'($h,$opts)';
$token = quotemeta($token);
$line =~ s/\${$token}/${ $value }/g;
undef $value, $func, $opts;
}
return $line;
}
Some of the token handlers (called by way of the eval '' above) also
call parse() to handle additional tokens. For some reason, when these
handlers call parse() (after being called from within parse()), the $h
hash ref is clobbered in the eval ''. Outside the eval, $h refs the
correct hash. The result is tokens called from within the eval no
longer have the correct $h passed to them. eval '' seems to be keeping
the original, first 'copy' of $h and it continues to eval
'$self->token_handler($h,$opts)' using that $h.
I only get this behavior with Perl 5.005_02 on a BSD box. Under Perl
5.005_03 on Debian GNU/Linux it works as I expect. $h isn't clobbered
in the eval '' call and all token handlers get the correct copy of $h.
Anyone have any ideas? I'm pretty lost.
I'd just remove the eval, but all of the token handlers called are
autoloaded by SelfLoader, so I can't create a bunch of sub refs keyed to
token handler names or anything like that to take eval '' out of the
equation.
Thanks all!
--
Sincerely,
Jason Boxman
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 18 Jul 2000 23:04:05 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Yet another string manipulation question -
Message-Id: <MPG.13df7faddc6b16b79896e9@news>
Vinod K. Menon wrote ..
[ always post your reply below the quoted text ]
>In article <397d6026.50089106@news.newsguy.com>,
> kcivey@cpcug.org (Keith Calvert Ivey) wrote:
>> elephant@squirrelgroup.com (jason) wrote:
>>
>> > my %rules = ( a => 'be', c => 'd', e => 'kl' );
>> > my $char = 'X';
>> >
>> > for my $key (keys %rules)
>> > {
>> > $String1 =~ s/$key([^$rules{$key}])/$key$char$1/g;
>> > }
>>
>> Consider what happens if $String1 is 'aacd'. The second 'a'
>> gets captured and ignored while the first 'a' is being
>> processed, and you get 'aXacd' instead of 'aXaXcd'. Change the
>> substitution line to
>>
>> $String1 =~ s/$key(?=[^$rules{$key}])/$key$char/g;
>
>The whole rule system is working perfectly except for one rule that I
>am not sure how to write up..
>
>v can be followed ONLY by a
>if any other character follows v, then an X has to be inserted between
>v and that character.
>How do I do that?
>
>adding v => 'a' into the %rules hash is not working right..
no .. Keith is right (I kept looking at the lookaheads but couldn't work
out a test case to show why to use them - thanks Keith)
Vinod .. adding the v => 'a' into your hash should work just fine .. of
course - if you hadn't made the changes that Keith is showing above -
then your 'v' could easily have been missed by the regex (if it was
following an 'a', 'c' or 'e' for instance)
change your code to this for flawless operation (thanks to Keith)
my %rules = ( a => 'be', c => 'd', e => 'kl', v => 'a' );
my $char = 'X';
for my $key (keys %rules)
{
$String1 =~ s/$key(?=[^$rules{$key}])/$key$char/g;
}
my apologies for giving you a bum steer earlier on
--
jason -- elephant@squirrelgroup.com --
------------------------------
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 3740
**************************************