Accessing an object in a sub-routine

C

C GIllespie

Dear All,

I'm not too sure on the exact terminology, so I hope you will bare with me
:)

In my small script, I have:

my $varA = $f->fault;

How do I pass $f to a subountine, i.e.

sub sub1(
$_->fault; #This is wrong!
)
sub1($f);

Declaring $f as global variable is one way, but are there any others?

Thanks

Colin
 
B

Ben Morrow

Quoth "C GIllespie said:
In my small script, I have:

my $varA = $f->fault;

How do I pass $f to a subountine, i.e.

sub sub1(
$_->fault; #This is wrong!

Sub args come in in @_. Read perldoc perlsub.

sub sub1 {
$_[0]->fault;
}
)
sub1($f);

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top