Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: incrementing array name

by particle (Vicar)
on Jun 23, 2003 at 12:50 UTC ( [id://268138]=note: print w/replies, xml ) Need Help??


in reply to incrementing array name

since you're accessing a global variable in a subroutine, @a will be appended to each time. you need to create a lexical variable, and return it from the subroutine. something like:

sub separate_data { my( @important_data )= @_; my @important_results= split / /, @important_data; return @important_results; } ## call it like my @answer= separate_data( $data[$a] ); ## or in a loop as: for my $a ( 0..10 ) { my @answer= separate_data( $data[$a] ); }

~Particle *accelerates*

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-03-29 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found