Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^2: Non-destructive array processing

by Aristotle (Chancellor)
on Jan 22, 2003 at 16:09 UTC ( #229064=note: print w/ replies, xml ) Need Help??

in reply to Re: Non-destructive array processing
in thread Non-destructive array processing


local *array = \@array;
This will work with lexically scoped variables too.

Makeshifts last the longest.

Comment on Re^2: Non-destructive array processing
Download Code
Replies are listed 'Best First'.
Re: Re^2: Non-destructive array processing
by ihb (Deacon) on Jan 22, 2003 at 19:09 UTC

    But what will simply alias the lexical @array with the dynamical @array. So I don't see what you've achieved by doing this.

    One problem with this that you probably didn't foresee is that lexicals are resolved before dynamic variables. Example:

    my @foo = 1..4; local *foo = ['a'..'d']; print @foo; # 1234
    The problem is solved through our() since that creates an aliased lexical:
    my @foo = 1..4; our @foo = 'a'..'d'; print @foo; # abcd


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2015-11-26 16:44 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (703 votes), past polls