SPUG: perl one-liner help
jerry.gay at gmail.com
Wed Apr 4 15:19:57 PDT 2007
On 4/4/07, Chris Wilkes <cwilkes-spug at ladro.com> wrote:
> On Wed, Apr 04, 2007 at 03:08:47PM -0700, Duane Blanchard wrote:
> > I have a list of names in a file separated by a semicolon and a space:
> > Starr, Ringo; McCartney, Paul; Lennon, John; Harrison, George;
> > and I want to substitute each /; / with a /\n/.
> > I'm running WinXP.
> > perl -e "s/; /\n/" desktop/list.txt
> You're close:
> perldoc perlrun
> shows that you're looking for the -p switch:
> perl -pe "s/; /\n/g" desktop/list.txt
> throw in a "/g" in your regexp to say that you want to repeat the
> match on the same line.
ain't perl fun?
perl -F/;\s*/ -ane "print $_,$/ for @F" desktop/list.txt
More information about the spug-list