You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Elizabeth Mattijsen <li...@dijkmat.nl> on 2001/03/15 01:17:17 UTC
Re: Very[OT]:Technical query re: scratchpad lookups for my()
vars
At 03:52 PM 3/14/01 -0800, Paul wrote:
But nothing about the structural/algorithmic mechanics. :<
From the perlsub docs:
Variables declared with my are not part of any package and are therefore
never fully qualified with the package name. In particular, you're not
allowed to try to make a package variable (or other global) lexical:
my $pack::var; # ERROR! Illegal syntax
my $_; # also illegal (currently)
In fact, a dynamic variable (also known as package or global variables) are
still accessible using the fully qualified :: notation even while a lexical
of the same name is also visible:
package main;
local $x = 10;
my $x = 20;
print "$x and $::x\n";
That will print out 20 and 10.
There is _no_ stash of lexicals during execution, only during
compilation. I guess one of the reasons lexicals are faster.
Elizabeth Mattijsen
Re: Very[OT]:Technical query re: scratchpad lookups for my() vars
Posted by "Alexander Farber (EED)" <ee...@eed.ericsson.se>.
Paul wrote:
> None of this is critical for anything I'm doing right now, but I'm a
> detail hound. I want to *understand* it, so that in the future I can
> make intelligent decisions about what would be a "better" way to write
> any given algorithm, without just relying on popular wisdom and "urban
> legend". =o)
If you're a "detail hound", why don't you look into the perl source code?
Re: VeryOT: help needed
Posted by Matt Sergeant <ma...@sergeant.org>.
On Thu, 15 Mar 2001, Jauder Ho wrote:
> Alright, it's crunch time (trying to help a coworker out) and I need
> to pick up some XML parsing with perl fast. So if anyone here has some
> good resources, they can point me at, it would be much appreciated.
>
> The problem I am trying to solve is as follows: I have two XML files, one
> is encoded in UTF8 and the other is in ASCII7. I need to parse the ASCII7
> file first and if a tag exists in the UTF8 file replace the data in the
> ASCII7 file with the UTF8 info. Everything should then be output in a UTF8
> format.
>
> Pointers to manipulating XML needed but I would take any additional help.
> Thanks.
There is actually a list for perl and xml, for what it's worth, where this
would be on topic... Anyway, I'm going to be totally unbiased here and
suggest you look at XML::XPath. I'm not 100% certain what you're trying to
achieve, but most things are pretty simple with XPath. Contact me offline
if you have further questions.
--
<Matt/>
/|| ** Founder and CTO ** ** http://axkit.com/ **
//|| ** AxKit.com Ltd ** ** XML Application Serving **
// || ** http://axkit.org ** ** XSLT, XPathScript, XSP **
// \\| // ** mod_perl news and resources: http://take23.org **
\\//
//\\
// \\
VeryOT: help needed
Posted by Jauder Ho <ja...@carumba.com>.
Alright, it's crunch time (trying to help a coworker out) and I need to
pick up some XML parsing with perl fast. So if anyone here has some good
resources, they can point me at, it would be much appreciated.
The problem I am trying to solve is as follows: I have two XML files, one
is encoded in UTF8 and the other is in ASCII7. I need to parse the ASCII7
file first and if a tag exists in the UTF8 file replace the data in the
ASCII7 file with the UTF8 info. Everything should then be output in a UTF8
format.
Pointers to manipulating XML needed but I would take any additional help.
Thanks.
--Jauder
Re: Very[OT]:Technical query re: scratchpad lookups for my() vars
Posted by Paul <yd...@yahoo.com>.
--- Elizabeth Mattijsen <li...@dijkmat.nl> wrote:
> At 03:52 PM 3/14/01 -0800, Paul wrote:
> But nothing about the structural/algorithmic mechanics. :<
>
> From the perlsub docs:
>
> Variables declared with my are not part of any package and are
> therefore
> never fully qualified with the package name. In particular, you're
> not
> allowed to try to make a package variable (or other global) lexical:
>
> my $pack::var; # ERROR! Illegal syntax
> my $_; # also illegal (currently)
> In fact, a dynamic variable (also known as package or global
> variables) are
> still accessible using the fully qualified :: notation even while a
> lexical
> of the same name is also visible:
>
> package main;
> local $x = 10;
> my $x = 20;
> print "$x and $::x\n";
> That will print out 20 and 10.
>
> There is _no_ stash of lexicals during execution, only during
> compilation. I guess one of the reasons lexicals are faster.
>
>
> Elizabeth Mattijsen
An excellent example, all known and understood.
What I can't find is this:
I know that my($x) puts x on this scope's scratchpad (and not in any
package space), but rather than a hash named main:: with a key named x
(which is, as I understand it, an oversimplification perhaps, but
basically what Perl does internally for $main::x), exactly *how* does
Perl "put" x into the scratchpad AV*? and once it's there, what did it
store? How does it know that entry is 'x'? is it just a reference to
the actual value?
None of this is critical for anything I'm doing right now, but I'm a
detail hound. I want to *understand* it, so that in the future I can
make intelligent decisions about what would be a "better" way to write
any given algorithm, without just relying on popular wisdom and "urban
legend". =o)
(That's why I said it was Very[OT], lol....)
Paul
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/