On Wed, Apr 22, 2009 at 6:12 PM, Chas. Owens <[email protected]> wrote: > On Wed, Apr 22, 2009 at 17:54, Gunnar Hjalmarsson <[email protected]> wrote: >> Chas. Owens wrote: >>> >>> On Wed, Apr 22, 2009 at 15:25, Gunnar Hjalmarsson <[email protected]> >>> wrote: >>> snip
>>> The utf8 pragma affects the whole file, >> >> Well, only the part of the file that is parsed after the >> >> use utf8; >> >> statement, right? > snip > > Hmm, I don't think it would reparse the whole file, but > it does run in a BEGIN block...hmm, I must test it. > It runs in a begin block, but it is still lexically scoped. Pragmata are very special cases of modules that provide modifications of compile-time behavior, and many of them perform sleight of hand behind the scenes. Here, the sleight of hand is using utf8 to simply add a bit mask to $^H and relying on the the behavior of the compiler hints. The important thing to remember about a BEGIN block that it is run as soon as it is defined, where it is defined. Just because it is executed early in the compile->optimize->run cycle does not mean that it is magically transported to an earlier position in the file. Generally, you want to apply the behavior introduced by a module to have file scope, which is why use statements normally appear early in the file. See perlpragma and the description of $^H in perlrun for details. HTH -- j -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom! -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
