On 8/12/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
snip
> >> perl -pi -le '$_ = "something" if $. == 10' your_file
> >
> > So if this was in a script rather than a oneliner how would it work?
> > I was playing and can not get it to work in an actual test script.
>
> Not surprising since it's
-Original Message-
>From: [EMAIL PROTECTED]
>Sent: Aug 11, 2007 9:58 PM
>To: beginners@perl.org
>Subject: Re: Replacing the n'th line with the new line
>
>On Aug 9, 6:46 am, [EMAIL PROTECTED] (Chas Owens) wrote:
>> On 8/8/07, Jeff Pang <[EMAIL PROTECTED]&
[EMAIL PROTECTED] wrote:
On Aug 9, 6:46 am, [EMAIL PROTECTED] (Chas Owens) wrote:
On 8/8/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
snip> perl -pi -e '$i++;s/^.*$/something/ if $i==10' your_file
snip
There is no need to keep track of the number of lines with a separate
variable. Perl already do
On Aug 9, 6:46 am, [EMAIL PROTECTED] (Chas Owens) wrote:
> On 8/8/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
> snip> perl -pi -e '$i++;s/^.*$/something/ if $i==10' your_file
>
> snip
>
> There is no need to keep track of the number of lines with a separate
> variable. Perl already does this with the
On 8/8/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
snip
> perl -pi -e '$i++;s/^.*$/something/ if $i==10' your_file
snip
There is no need to keep track of the number of lines with a separate
variable. Perl already does this with the $. variable. Also, a regex
that replaces everything is pointless, j
-Original Message-
>From: Subhash <[EMAIL PROTECTED]>
>Sent: Aug 8, 2007 10:34 PM
>To: beginners@perl.org
>Subject: Replacing the n'th line with the new line
>
>Hi
>
>Is there any way to update the specified line in the file with the new
>line without having to copy the entire contents on
Subhash wrote:
Hi
Is there any way to update the specified line in the file with the new
line without having to copy the entire contents once again. Since the
file is huge, i dont want to re-write the file. Can anyone suggest me
how to do this
If the line you are replacing is the same size as