Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] sed or perl script help please . . .



On Tue, 6 Aug 2002 00:11:19 -0400
Viktor Pavlenko <vvp@example.com> wrote:

> Did you notice the s modifier in the samples above?
> 
> So, s modifier means: you can treat it as a single line as long as you
> don't mess with the record separator...
>
The s modifier is evaluated *after* each line is
read into $_. So $_ *is* terminated with every \n
in the data source. The s modifier does nothing
in this situation. You would have seen that
the lines are read *before* the s modifier
if you had done this with a script file, not
with a one-liner.

> 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
> 
The examples above are just comping each line.
The chomped lines are printed because of the -p option
and look concatenated on the screen.
That's why the above one-liners didn't work with
the original question as expected.

-- 
SAKUMA Junichi <jun@example.com>
Key fingerprint = 199D 03E9 E7C0 CC66 E2D9  AD3F CB2E F76F 8AD9 FC62


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links