i have a folder called 'error' and in that, i have error log
files which are generated by the build,
now i want to findout the string 'error' from each log
file and that error has to be copied into the another file
called 'analysis'.
how do you do this in perl?
Answer Posted / prabhakaran m
## Go to that Directory
my $file_output = "output";
open(OUTFILEHANDLE,">$file_output") || die "Unable to open
the file : $file_output";
foreach my $input_file (`ls -1`) {
open(INFILEHANDLE,"$input_file") || die "Unable to
open the file : $input_file";
while (<INFILEHANDLE>) {
print OUTFILEHANDLE $_ if (/print header/);
}
}
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
what is Chop & Chomp function does?
Explain the difference between declarations of 'my' and 'local' variable scope in perl?
how to create a flat file database as shown below s.no name age city phone 0 hema 22 Calcutta 4312542 1 hema 21 Bangalore 2344345 2 ganesh 25 delhi 2445454 3 kartik 45 pune 4312121 4 santosh 25 Hyderabad 2254231 5 kumar 25 mysore 2344567 6 gita 34 mangalore 6532123 7 gita 32 pune 2213456 Q1.print the details of the person who r from bangalore q2.Replace the city name managlore to pune q3.prints no of person having name gita and hema q4.print how many are of age 25.
Explain chomp?
Why does Perl not have overloaded functions?
What does this symbol mean '->'?
how to get back up from private character editor which is saved in the format of .udf
How will you get the count of parameters passed to a perl subroutine?
How can information be put into hashes?
List the files in current directory sorted by size ?
what is the main function of fork() in cgi programming?
Explain grooving and shortening of arrays and splicing of arrays?
Why do you use Perl?
What happens when you return a reference to a private variable?
Can inheritance be used in perl? Explain with the help of an example.