I'm trying to do this script on my own as suggested by someone in this group. I have the book "Teach yourself Perl in 21 days" So far I've been able to open the file and execute a grep to search for certain text and then display the hits.
I'm getting confused on the login. I need to open the orginal file (which I've done) and then do a grep to search and then replace some text but I need to output the results to the same file (can this be done). Do I need to open another file to write to or can everything be done in the same file? #!/usr/bin/perl -w use strict ; my $fn = "input.txt" ; open(INFILE, $fn) or die "Can't open input file: $fn ($!)" ; my @match_lines = grep /look for me /i, <INFILE> ; print @match_lines ; print scalar(@match_lines) ; print "Found it!\n" if @match_lines ; close INFILE ; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>