Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: returning tied array

by nobull (Friar)
on Jan 07, 2007 at 13:54 UTC ( #593394=note: print w/replies, xml ) Need Help??

in reply to returning tied array

Another solution is to declare @array in the main program and pass a reference to &TieVariable.
TieVariable(\my @array); ### Pos1 print "### Initialization finished\n"; for (0..$#array) { print "$_: $array[$_]\n"; } # for $array[6] = 1000; untie @array; sub TieVariable { my $array = shift; tie @$array, 'Tie::Excel::Array'; $array->[$_] = 5 * $_ for 0..5; }

You can get rid of then need for the backlash at Pos1 by giving TieVariable a prototype, but I would not recommend it.

Replies are listed 'Best First'.
Re^2: returning tied array
by strat (Canon) on Jan 08, 2007 at 09:33 UTC

    nobull: Thank you very much. The current version uses the alias version, because I have been thinking in a much too complicated way. The "Call-by-Reference" does exactly what I was looking for, and I will use it for the next version.

    When it is finished, I'll post the script under Cool Uses For Perl ;-)

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8."

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2021-06-17 23:20 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (86 votes). Check out past polls.