Martin Tournoij wrote:

: I'm currently massivly confused by multidimensional arrays and
: passing arrays to subs.
: 
: Why is it that @_[1] isn't properly copied to @a?

    It is properly copied. Because @_[1] one is a scalar and
@a is an array the reference to the passed array in stored in
$a[0].


: Music($var1, [EMAIL PROTECTED]);
: 
: sub Music
: {
:    print $_[1][1];  # works
:    my @a = @_[1] # Gives warning, should be written as $_[1]

    So stop writing it as @_[1], silly. :)

    my $var = shift;
    my $array_ref = shift;


:    print $a[1]; # Outputs ARRAY(#memaddr)

    print @{ $array_ref };


:    print $a[1][1]; # Works
: 
:    for (@a)

    for ( @{ $array_ref } ) {



HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

Don't tread on my bandwidth. Trim your posts.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to