• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Perl help

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Fractal

Registered
Joined
Jul 27, 2004
Location
WA & ID
Hey,
I have a variable on @_ , I need to pull it off, set another variable equal to it and then shove it back onto @_ again. Can anyone help me out? Thanks
 

anon1

Member
Joined
Jun 8, 2005
If you can elaborate a bit more on what you want to do, and possibly give some information about it, I can probably help you. :cool:
 

funzie

Member
Joined
Oct 26, 2003
Well the @_ only has a scope of the subroutine you are using, so you can't use it anywhere else. Which makes changing the value of it kind of pointless. But I am pretty sure that you can change it. Just set the value of the element from the @_ array to the new value. For example of you want to change the 2nd element it would be $_[1] = "New Value";
 
OP
F

Fractal

Registered
Joined
Jul 27, 2004
Location
WA & ID
ok got that first question figured out...this next one is about scope
is there any way for me to reference a variable local to a subroutine?
For example:

sub {

my $foo;
}

can i reference $foo somewhere else somehow?
thanks