Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arrays

Status
Not open for further replies.

skottieb

Programmer
Jun 26, 2002
118
AU
hello,
I am passing a scalar to a subroutine so it goes in as $_[0], lets say the scalar is a 5 digit number (12345), how do i split the scalar into a list, ie: $_[0] = 1, $_[1] = 2, $_[2] = 3, ect, ect..

ive been shown the code once before but i cant remembet it.

please help
skottieb:)
 


IF you used to do this:

&subroutine($scalar);

You can instead, do this:

&subroutine( split(//, $scalar) );

That would pass the sub the list. Or you could to the split after you passed it in:

sub subroutine {
my @numbers = split(//, shift);
# ... do yo thang!
}

Hope that helps.

--jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top