Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Accessing an object in a sub-routine

Reply
Thread Tools

Accessing an object in a sub-routine

 
 
C GIllespie
Guest
Posts: n/a
 
      06-10-2004
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


 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      06-10-2004

Quoth "C GIllespie" <(E-Mail Removed)>:
>
> 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

--
Musica Dei donum optimi, trahit homines, trahit deos. |
Musica truces molit animos, tristesque mentes erigit. | http://www.velocityreviews.com/forums/(E-Mail Removed)
Musica vel ipsas arbores et horridas movet feras. |
 
Reply With Quote
 
 
 
 
gnari
Guest
Posts: n/a
 
      06-10-2004

"C GIllespie" <(E-Mail Removed)> wrote in message
news:ca96i4$eh9$(E-Mail Removed)...

> my $varA = $f->fault;
>
> How do I pass $f to a subountine, i.e.
>
> sub sub1(
> $_->fault; #This is wrong!
> )
> sub1($f);


$_[0]

gnari





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing a YAML loaded object without the object's definition? Steve Litt Ruby 2 09-29-2008 08:32 PM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
COM object accessing asp Application object mrrrk ASP .Net 1 12-19-2003 09:37 AM
Accessing DCOM components from the code behind pages and using sessions to store DCOM object handles Alex ASP .Net 3 12-02-2003 01:34 AM
Re: Accessing all properties of an object at Runtime Ilyas ASP .Net 1 07-04-2003 05:51 PM



Advertisments