Oh yes !
The magic Tie ...
Enjoy!
José.
-Original Message-
From: Janek Schleicher [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 09, 2002 5:45 PM
To: [EMAIL PROTECTED]
Subject: Re: printing to the top of a file
Stephen Redding wrote at Fri, 09 Aug 2002 10:54:01 +0200:
> I hav
Stephen Redding wrote at Fri, 09 Aug 2002 10:54:01 +0200:
> I have a text file that i want to insert two lines to the top of.
> how do i do this?
A solution where it's not necessary to think is to use the
Tie::File module.
use Tie::File;
tie my @line, 'Tie::File', 'filename.txt' or die "...";
u
Stephen Redding wrote:
>
> Hi
Hello,
> I have a text file that i want to insert two lines to the top of.
> how do i do this?
#!/usr/bin/perl -w
use strict;
use Fcntl ':seek';
my $file = 'text_file.txt';
open FILE, "+< $file" or die "Cannot open $file: $!";
my @lines = ;
seek FILE, 0, SEEK_
Stephen Redding wrote:
>
> Hi
Hello,
> I have a text file that i want to insert two lines to the top of.
> how do i do this?
perl -i~ -pe'$.==1 and s/^/new line one\nnew line two\n/' text_file
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additiona
On Fri, 9 Aug 2002 [EMAIL PROTECTED] wrote:
> Hi
>
> I have a text file that i want to insert two lines to the top of.
> how do i do this?
>From the command line you can do this, this will retain you original
file as filename~
perl -i~ -pe 'print "line1\nline2\n" if ($. == 1)'
If you want to
on Fri, 09 Aug 2002 08:54:01 GMT, [EMAIL PROTECTED] (Stephen
Redding) wrote:
> I have a text file that i want to insert two lines to the top of.
> how do i do this?
This is frequently asked question (FAQ).
You can look up the answer by typing the following at your command
prompt:
perldoc