Question: Modify the following Perl script to output the matched text to a .txt file. This script should read through any files and output the text

Modify the following Perl script to output the matched text to a .txt file. This script should read through any files and output the text to a .txt files.

my $file = $ARGV[0]; print "Searching through [$file]... ";

$count = 0; open(my $in, '<:raw', $file) or die "Unable to open: $!"; while( read( $in, $b, 4 ) ) { if ( $b eq "\xde\xad\xbe\xef" ) { $count++; #print "Found "; } else { # backup 3 bytes and try again... since we don't know alignment seek($in,-3,SEEK_CUR); } } close($in);

print " TOTAL matches = $count ";

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!