Problems? Is your data what you think it is? | |
PerlMonks |
Lexical %+ %- and more?by blazar (Canon) |
on Oct 22, 2008 at 10:35 UTC ( [id://718691]=perlmeditation: print w/replies, xml ) | Need Help?? |
This is basically a repost of the last part of a reply of mine which appearently went unnoticed and anyway didn't get any answer: indeed it went slightly OT WRT the main thread. So we have named captures and it's not much time since we do, but I already ask for them not to be read-only: what people tell me basically is that there are implementation details that force them to be instead. Now I go one step further so this may well be taken as sci-fi, but nevertheless I think it exposes an interesting idea: from 5.10 onward we have a lexical $_ so I wonder whether we could have lexical %+ and %- such that:
Thus one may have the following example (which explains the whole thing better than many abstract descriptions...) working as naively expected:
Assuming e.g.: at the end of the scope, if I printed Data::Dumper's Dumper \%+ I would get
Please don't point out that wrt the example above there are tons of other WTDI: it's obvious that there are - we're talking about Perl anyway! I just think we could have one more, and with a very clear syntax too. Also, the idea sprang in the context of that other thread dealing with %+ and %- but there may be other special variables that may allow a lexical incarnation with a modified semantics associated to to it.
--
Back to
Meditations
|
|