If you want to use md5sum, you should use Digest::MD5
module. If you insist on using the system's command, my $digest = `md5sum $file`;
will store the result into a variable.
How can I execute the md5sum command on the files stored in this array in Perl?
Question
I am running a perl script to calculate the md5sum of each file in a directory. So far, I have the filenames stored in a @files array. I want to call md5sum system command on each filename in the array and print the output to standard output?
Here is what i have so far:
#!/usr/bin/perl -w
@files = <*>;
foreach $file (@files) {
print $file . "\n";
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow