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

Re: Weird array printing/passing to subroutine problem

by ahunter (Monk)
on Jul 10, 2000 at 21:37 UTC ( #21829=note: print w/ replies, xml ) Need Help??


in reply to Weird array printing/passing to subroutine problem

I'm surprised no-one has suggested it yet, but you can use prototyping to force things to happen the way you want:

sub my_sub (\@$) { my $array = shift; my $scalar = shift; # $array is a reference to the array # $scalar is the next argument } my_sub @array, "scalar";
Perl will automagically change @array into a reference for you. See perlsub for more information about prototyping.

Andrew.


Comment on Re: Weird array printing/passing to subroutine problem
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2015-07-06 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (69 votes), past polls