Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re: Re: using split on every element in an array

by BrowserUk (Pope)
on Jan 17, 2003 at 15:39 UTC ( #227700=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: using split on every element in an array
in thread using split on every element in an array

Every element of an array is a named scalar variable.

Eg. $array[3] = 'something';  $var = $array[4]; etc.

You can therefore use them directly with split.

Eg.

for my $element (@array) { my @bits = split "\t", $element; #do something with the bits. }

The contents of @array will remain unmodified for further use later unless you assign something to $element.

It might be clearer to you written this way.

for my $index (0 .. $#array) { # $#array is the numer of the highest e +lement. my @bits = split "\t", $array[$index]; }

The first version is usually considered better though.


Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.


Comment on Re: Re: Re: using split on every element in an array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2015-07-30 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls