in reply to Include Delimiter in Split Output
#!/usr/bin/perl use strict; use warnings; while (<DATA>) { my @line = split/(?<=x)/; print join "\n", @line; } __DATA__ 1234x456x789
However, this means that one of the records will be inconsistently formatted as compared to the others, which is generally something to be avoided. It usually makes a lot more sense to just append the new lines after the split (perhaps using .=) or include the formatting in your print statement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Include Delimiter in Split Output
by ssandv (Hermit) on Jul 30, 2009 at 16:25 UTC |