in reply to Inserting stuff into a filehandle.

I Think So.

Easiest way i can think of is to have a TEMPFILE filehandle,
and put the contents of "$stuff" and FILE to TEMPFILE,
and then copy TEMPFILE to FILE.
What might also work, but highly unlikely, is if you open a file handle for reading and writing,
and set the $. variable to a negative value and do a print.

I never tried this, and i'm not sure that $. can be set to a negative value.

$.
The current input line number for the last file handle from which you read (or performed a seek or tell on). An explicit close on a filehandle resets the line number. Because ``<>'' never does an explicit close, line numbers increase across ARGV files (but see examples under eof()). Localizing $. has the effect of also localizing Perl's notion of ``the last read filehandle''. (Mnemonic: many programs use ``.'' to mean the current line number.)

 ______________________________________________
|_____¸.·ooO--(> cRaZy is co01. <)--Ooo·.¸_____|
 ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
  • Comment on (crazyinsomniac) Re: Inserting stuff into a filehandle.

Replies are listed 'Best First'.
RE: Re: Inserting stuff into a filehandle.
by Adam (Vicar) on Aug 09, 2000 at 21:44 UTC
    Setting $. does not do anything. It just changes the number that will get incremented next time you read a line. Perl doesn't use this number for anything, its there for the programmer to read, and reset. But nothing you put in it will affect the read operation.