Gossamer Forum
Home : General : Perl Programming :

Dividing up a text file into an array

Quote Reply
Dividing up a text file into an array
OK all you intelligent scripters ... I could use a little assistance if you please.

I would like to take the input from a form (type=TEXTAREA) and chop it into a length to be determined by a variable so that each line is placed into an array.

Example:

if $length=20

$message = "We the people of the United States, in order to form a more perfect Union, establish justice ..."

becomes ...

$msg[0] = "We the people of the"
$msg[1] = "United States, in"
$msg[2] = "order to form a more"
$msg[3] = "perfect Union"
$msg[4] = "establish justice..."

Line breaks would need to be converted to an empty variable, i.e. $msg[5] = ""

Any suggestions?

[This message has been edited by Lee (edited August 13, 1999).]
Quote Reply
Re: Dividing up a text file into an array In reply to
Never mind. I figured it out!