|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Hi,
I have a simple question: I need to enter some text in a text file at a certain place via perl. I would first need to find that specific text in the file and then I would like to insert a line after that particular line. Say I have this text file: I am a great Perl Programmer I would like to learn Perl Now I would like to insert a line called: "My Name is Som" between the two lines. So I would need a regex to search the line: "I am a great Perl Programmer" and then insert "My Name is Som" in the next line. What should be the command in perl? I know this is a dumb question. Can anyone help? Thanks ![]() Last edited by som.nitk; 03-20-2009 at 01:49 PM.. |
| Sponsored Links | ||
|
|
|
|||
|
You don't need a regexp you just need to find the first line using index() or "eq" then print the line you want to go after that line. When you post some code you have written to try and solve this requirement I will help you some more.
Two approaches are using the Tie::File module that comes with perl or perls inplace editor. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Best place on the net to get Perl tutorials ? | Browser_ice | Shell Programming and Scripting | 1 | 08-10-2006 02:43 AM |
| Perl text file | Sn33R | Shell Programming and Scripting | 5 | 10-31-2003 11:59 AM |
| Enter text and display on logo | perleo | Shell Programming and Scripting | 1 | 06-26-2003 11:42 AM |
| Can i ask the question of perl in the place? | ybz3721 | Programming | 2 | 04-17-2002 05:13 AM |
| Update text files in place (string substitution) ?? | kornshellmaven | UNIX for Dummies Questions & Answers | 1 | 07-17-2001 12:11 AM |