Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: need help in writing aperl script

by Anonymous Monk
on May 27, 2015 at 03:03 UTC ( [id://1127924]=note: print w/replies, xml ) Need Help??


in reply to need help in writing aperl script

see get n lines before or after a pattern, Re: modifying a file with regex!, perlintro, open, readline, rename, Re^5: Remove a Line, perlintro, open, close, readline, rename, Re: Rewriting into file, @ARGV, Getopt::Long, Re^2: Write to existing file with character insert

Modifying an existing file is three steps :)

  1. read old file
  2. create a new file
  3. rename new file to name of old file

perlintro covers all three steps, as does Modern Perl and http://learn.perl.org/books/beginning-perl/

Path::Tiny makes it even easier to work with paths

Replies are listed 'Best First'.
Re^2: need help in writing aperl script
by jag194u (Initiate) on May 27, 2015 at 03:15 UTC
    I have started writing the script to open a file and parse through the lines.but iam troubling with pattern matching and insert the words in the resulting line.
    open my $file ,"+<","reg" or die $!; while (my $line = <$file>) { chomp $line; print "$line\n" }

      I have started writing the script to open a file and parse through the lines.but iam troubling with pattern matching and insert the words in the resulting line.

      Ok then, then look here :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-24 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found