Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: How to get array elements from reference ?

by manishrathi (Beadle)
on Jun 08, 2011 at 07:00 UTC ( [id://908631]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to get array elements from reference ?
in thread How to get array elements from reference ?

I want to print content of the array. I have used following code for that

use TeamSite::WFsystem ;

$system = new TeamSite::WFsystem() ;

@jobs = $system->GetActiveWorkflows();

foreach $job (@jobs){

print "$job \n" ;

}

why am I still getting reference to array printed out ?

  • Comment on Re^4: How to get array elements from reference ?

Replies are listed 'Best First'.
Re^5: How to get array elements from reference ?
by Neighbour (Friar) on Jun 08, 2011 at 11:40 UTC
    Since numerous people have told you already that ->GetActiveWorkflows() returns an arrayref instead of an array, here's the code that does something useful with that:
    use TeamSite::WFsystem ; $system = new TeamSite::WFsystem() ; my $ar_jobs = $system->GetActiveWorkflows(); foreach my $job (@{$ar_jobs}){ print "$job \n" ; }
    Assuming that $job will contain something printable, of course.
    @{$ar_jobs} dereferences the arrayreference, which gives you the array that $ar_jobs references to. I usually prefix my arrayref and hashref variables with ar_ and hr_ respectively, so I can easily see what kind of reference I'm dealing with. This is not required, but imo easier to spot.
Re^5: How to get array elements from reference ?
by Corion (Patriarch) on Jun 08, 2011 at 07:07 UTC

    Because it seems that ->GetActiveWorkflows returns an array reference and not an array. Simply assigning to an array does not make the function return an array.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-24 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found