Re: [PBML] end-of-line buffer character
- --- In firstname.lastname@example.org, "lgl12356" <lamb@M...> wrote:
>One thing you don't mention is whether you've tried the code you list
> I need to add a space or character at the end of each line
> in a file. From a couple of books (and jumping on another
> thread) I've come up with...
> perl -p -i -e "s/[$]/ [$]/;" file.dat
> ideas? will the second [$] do an infinite loop?
> whuttabout "..../g" ?
> (guess I need to do something like a -p [$] to
> see what the actual last character is?)
> I need to load Perl up on the machine in question, but
> on another MS2000 machine, the -i whines about not
> working without a backup file, and if I -i .bak (as
> in book), it bitches even more. ???
> Thanks for any help,
and what results you got.
The '$' is for matching, not replacing. It is redundant on the second
half of the 's///' construct.
If you put the code in single quotes the '$' should not be modified
and you'd remove the need for the square brackets - haven't tried this.
perl -p -i -e 's/$/ /;' file.dat
You don't need the 'g' modifier because on each line there is only one
occurance of the end of the line.
Does it make any difference if you remove the space after '-i'?
In 'perl --help' there is no space after any option except '-e'