Random_Walk has asked for the wisdom of the Perl Monks concerning the following question:
good $localtime fellow monks,
I am tearing my hair out over a small oddity. Why will this work:
perl -nle "my (@c) = /\:(\w+)\:/g; print join '.', @c" input> out:caputure1:out:capture2:out output> caputure1.capture2
But this behaves so differently
perl -nle "my (@c) = s/\:(\w+)\:/X/g; print join '.', @c" input> out:caputure1:out:capture2:out output> 2
I am trying to extract comments from a file I have in a buffer read in with local $/;. The comments are marked by a ; and continue to the end of the line. For various reasons I want the file as a sinlge line and want to extract the comments. The comments will be added back in later so I substiture them for a marker. I realise I could break the file into lines and put it back together again later but I would love to be able to do it in one line
Cheers,
R.
Pereant, qui ante nos nostra dixerunt!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: s///g and capturing all matches
by johngg (Canon) on Dec 15, 2011 at 15:06 UTC | |
by Random_Walk (Prior) on Dec 16, 2011 at 09:52 UTC | |
Re: s///g and capturing all matches
by Anonymous Monk on Dec 15, 2011 at 14:26 UTC | |
by Random_Walk (Prior) on Dec 16, 2011 at 09:08 UTC | |
Re: s///g and capturing all matches
by jethro (Monsignor) on Dec 15, 2011 at 14:27 UTC | |
by Random_Walk (Prior) on Dec 16, 2011 at 09:59 UTC |
Back to
Seekers of Perl Wisdom