Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Mini-Tutorial: Working with Odd/Even Elements

by ikegami (Patriarch)
on Jul 10, 2009 at 20:14 UTC ( [id://779036]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Mini-Tutorial: Working with Odd/Even Elements
in thread Mini-Tutorial: Working with Odd/Even Elements

Too golfy or arcane?

All of these map_pairs implementations are in the red zone of the arcanometer.

The interesting thing to note is that I seem to get a magical localization of my variables.

Array elements aren't lexical variables, if that's what you're talking about.

As for using local on array elements, perlsub says

Some types of lvalues can be localized as well : hash and array elements and slices, conditionals (provided that their result is always localizable), and symbolic references. As for simple variables, this creates new, dynamically scoped values.

That means

my @a; local $a[0]; # Not a problem my %a; local $a{k}; # Not a problem

Replies are listed 'Best First'.
Re^5: Mini-Tutorial: Working with Odd/Even Elements
by Roy Johnson (Monsignor) on Jul 10, 2009 at 23:40 UTC
    Array elements aren't lexical variables, if that's what you're talking about.
    No, I was saying that my "orig value" came back without my making them local (see the other reply to my node), but apparently that's not a reliable feature. I was using ActivePerl, for the record.

    Caution: Contents may have been coded under pressure.
      Oh! I thought you were using
      local @{$pkg}{qw(a b)} = \(@_[0,1]);
      rather than
      @{$pkg}{qw(a b)} = \(@_[0,1]);

      I can reproduce that bug with

      This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 12 registered patches, see perl -V for more detail) Binary build 824 [287188] provided by ActiveState http://www.ActiveSta +te.com Built Sep 3 2008 11:14:55
      but not with
      This is perl, v5.8.0 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Binary build 806 provided by ActiveState Corp. http://www.ActiveState. +com Built 00:45:44 Mar 31 2003
      This is perl, v5.10.0 built for MSWin32-x86-multi-thread (with 5 registered patches, see perl -V for more detail) Binary build 1004 [287188] provided by ActiveState http://www.ActiveSt +ate.com Built Sep 3 2008 13:16:37
      or
      This is perl, v5.8.8 built for i486-linux-gnu-thread-multi

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://779036]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-03-29 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found