Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: subroutine arguments

by murugu (Curate)
on Oct 25, 2005 at 12:13 UTC ( [id://502684]=note: print w/replies, xml ) Need Help??


in reply to subroutine arguments

The problem here is the array @c1_uniq_cog_ids and the scalar variable $name1 have got flattened and will be stored in the variable @c1_uniq_cog_ids inside your subroutine. So inorder to retain the values you need to pass the array as reference.

cog_class(\@c1_uniq_cog_ids, $name1); sub cog_class { + my ($c1_uniq_cog_ids, $name) = @_; ### you can use @$c1_uniq_cog_ids to get the contents array }

In your case even you can reverse the way in which your parameters are passed.

cog_class($name1,@c1_uniq_cog_ids); sub cog_class { my ($name,@c1_uniq_cog_ids)=@_; }

Hope this may shed some light....

Regards,
Murugesan Kandasamy
use perl (;;);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-23 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found