Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: splitting pipe into new line

by toolic (Bishop)
on Jun 14, 2013 at 17:23 UTC ( #1039007=note: print w/replies, xml ) Need Help??


in reply to splitting pipe into new line

It's not clear to me what you want. If you want to replace all pipes with a newline, you can use s///:
use warnings; use strict; my $description = 'a|b|c|d|e'; $description =~ s/\|/\n/g; print "$description\n"; __END__ a b c d e

Or, if you really want an array, you can add newlines using map

my $description = 'a|b|c|d|e'; print "$description\n"; my (@new) = map {"$_\n"} split (/\|/, $description); print @new;

Replies are listed 'Best First'.
Re^2: splitting pipe into new line
by PerlSufi (Friar) on Jun 14, 2013 at 17:27 UTC
    Ah, silly me- thanks toolic. s/// is what I needed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1039007]
help
Chatterbox?
[Corion]: A good weekstart to everybody. I hope you had a good Pentecost
marto was working yesterday
[Corion]: marto: Ow :(
[marto]: Corion, not to worry, it was ok :)
[Corion]: I "just" had a call from a friend whom I host the website for, and they were quite hectic yet uninformed about what they'd have to change for GDPR... This felt like work to me, but at least I got that call in a café, not in the office

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-05-22 07:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?