Re: Anyone using Ruby for scripting?

On Mon, Sep 20, 2010 at 6:29 AM, Blanchard, William G <
William.Blanchard@xxxxxxxxxxxxx> wrote:

>   I can write a perl one-liner that edits a file but can’t, from within a
> perl script, directly edit a file.
>
>
Really?

I don't think you've tried hard enough.  :)

#!/usr/bin/perl

open TEST, ">test.txt";

print TEST "this is  a test\n";

open TEST, "test.txt";
my $l = <TEST>;
print "TEST before edit: $l";

open TEST, "+<test.txt";

seek TEST, 5, 0;

print TEST "was";

open TEST, "test.txt";
$l = <TEST>;
print "TEST after edit: $l";


Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist
Oracle Blog: http://jkstill.blogspot.com
Home Page: http://jaredstill.com

Other related posts: