Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://21829]
Discipulus dscivered BASH supports also double quotes..
choroba recommends ABSG to Discipulus
[erix]: yes, very handy that. I always use the one-page html version (dumped a local copy of it)
[erix]: (easier for searching)
choroba tries to grep -i choroba absg.html

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-11-24 11:52 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (348 votes). Check out past polls.