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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiline string to array 1

Status
Not open for further replies.

eldeann

Programmer
Jun 17, 2005
2
SE
hello,
this may be easy but doesn't work for me.
I have a string that contains several lines (that's the ouput of a CVS update).
I'd like to transform it to an array of lines.

i'm using :
@myarray = split(/\n/, $output);

but that doesn't split anything...

any idea ?

thanks
Adrien
 
Ought to work. What output do you get if you print $output;?
 
the output is a multi-lines paragraph... so i needed the multiline options like this :

split(/\n/m, $output);

and that works.

 
How are you filling the string in the first place? If it's coming from using backticks to shell out to CVS, you can assign its lines into an array directly, rather than having to split them up afterwards.

I can't think of any change of behaviour that the /m introduces that would affect this particular regexp, as I thought /m only affects the `^', `$' and `.' characters. Maybe I need to read perlre again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top