Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] sed or perl script help please . . .
- Date: Tue, 6 Aug 2002 00:11:19 -0400
- From: Viktor Pavlenko <vvp@example.com>
- Subject: Re: [tlug] sed or perl script help please . . .
- References: <F132q9IcVux1Zcn8TtE000005b5@example.com><15694.43840.422094.372348@example.com><20020806123947.6b8a9907.jun@example.com>
>>>>> "SJ" == SAKUMA Junichi <jun@example.com> writes: >> >> perl -pe 's/\n(\D)/ $1/sg' < crs.txt >> or >> perl -pe 's/\n(?=\D)/ /sg' < crs.txt >> >> but they don't work. Any ideas why? >> SJ> The latter two, with the default record separator, SJ> read each line from crs.txt into "$_" one by one. SJ> Then, $_ is terminated with "\n" and never matches SJ> up with the regexes like /\n(\D)/ or /\n(?=\D)/. Did you notice the s modifier in the samples above? In the following example $_ is not terminated by the first \n and all replacements are made: $ perl -pe 's/\n/ /sg' < crs.txt This works too, through all lines: $ perl -pe 's/o/O/sg' < crs.txt So, s modifier means: you can treat it as a single line as long as you don't mess with the record separator... Viktor
- Follow-Ups:
- Re: [tlug] sed or perl script help please . . .
- From: Viktor Pavlenko
- Re: [tlug] sed or perl script help please . . .
- From: SAKUMA Junichi
- References:
- [tlug] sed or perl script help please . . .
- From: Jean-Christian Imbeault
- Re: [tlug] sed or perl script help please . . .
- From: Viktor Pavlenko
- Re: [tlug] sed or perl script help please . . .
- From: SAKUMA Junichi
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] sed or perl script help please . . .
- Next by Date: Re: [tlug] sed or perl script help please . . .
- Previous by thread: Re: [tlug] sed or perl script help please . . .
- Next by thread: Re: [tlug] sed or perl script help please . . .
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links