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
How to copy a file in perl?
Explain about the applications of perl?
Explain what is the scalar data and scalar variables in Perl?
How to read file into hash array ?
How to close a file in perl?
Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?
What is the use of -t?
Mention what is cpan?
What are the advantages of programming in perl?
How we can navigate the xml documents?
Explain the arguments for perl interpreter.
Who created perl?
What package you use to create a windows services?
How to renaming a file in perl programming?
What are the features of perl language?