Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: insert into beginning of file

by broquaint (Abbot)
on Jul 22, 2002 at 13:56 UTC ( [id://184044]=note: print w/replies, xml ) Need Help??


in reply to Re: insert into beginning of file
in thread insert into beginning of file

Supplementary to Abigail-II's advice here's example code of how you might insert a line into the beginning of a file using Tie::File
use strict; use Tie::File; tie(my @fl, 'Tie::File', 'somefile.txt') or die("ack - $!"); unshift @fl, 'a line of text here'; untie @fl;
If you're not doing line-based insertion into your file then your best choice is to open a new file and write to that.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Re: insert into beginning of file
by rchou2 (Novice) on Jul 22, 2002 at 14:11 UTC
    When using Tie::File, I get the following error: Can't locate Tie/File.pm Is this because I don't have the latest version of Perl?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://184044]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-19 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found