Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How to use fseek in perl ??

by mwah (Hermit)
on Oct 24, 2007 at 11:53 UTC ( #646873=note: print w/replies, xml ) Need Help??


in reply to How to use fseek in perl ??

Your request would be solved formally by

for Unix: perl -i.bak -0777 -lpe 's/\nef\n/\nef\na test content\n<blank line>\n +/' a.txt for Windows: perl -i.bak -0777 -lpe "s/\nef\n/\nef\na test content\n<blank line>\n +/" a.txt

Addendum: If you only want to insert sth. after a specified line, then you may get along by doing this:

Unix: perl -i.bak -pe 'print "a test content\n<blank line>\n" if $.==4' a.t +xt Windows: perl -i.bak -pe "print qq{a test content\n<blank line>\n} if $.==4" a +.txt

So here we count on $. (line number) and the line after #3 is #4.

Maybe you meant something else by your term "fseek in perl". Better you'd give a small hint what exactly you are trying to solve by that?

Regards

mwa

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2023-06-03 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (14 votes). Check out past polls.

    Notices?