Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: insert into beginning of file

by Abigail-II (Bishop)
on Jul 22, 2002 at 13:41 UTC ( [id://184036]=note: print w/replies, xml ) Need Help??


in reply to insert into beginning of file

Use Tie::File.

Abigail

Replies are listed 'Best First'.
Re: Re: insert into beginning of file
by broquaint (Abbot) on Jul 22, 2002 at 13:56 UTC
    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

      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://184036]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-29 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found