novice sed ?

Randal L. Schwartz merlyn at iwarp.intel.com
Tue May 7 02:06:14 AEST 1991


[I tried mailing.  It bounced.  Where the heck is carssdf?
And yes, further discussion to comp.lang.perl, please...]

In article <304 at carssdf.UUCP>, usenet at carssdf (John Watson) writes:
| > perl -pe 'while (/,\s*$/) {$_ .= <STDIN>; s/,\s*\n\s*/ /;}' <in >out
| 
| In this example, don't you have to set $* =1; to get the s/,\s*\n\s*/ to
| match.
| 
| John Watson

No.  $* is only for selecting whether ^ and $ match a
begin/end-of-line within the buffer.  \n will always match itself, as
will \s match newline (and the other whitespace).  The \n is in there
to ensure that I kill the *right* comma and whitespace (which the sed
solution doesn't guarantee).

Just another Perl hacker (but of course, you knew that),
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn at iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/



More information about the Comp.unix.questions mailing list