Perl: Calculate the md5 sum of a file
Articles may may have files attached at the end of the post
Submitted by chantra on Sat, 04/12/2008 - 17:45
This code sample shows how one could compute the md5sum of a file using Perl's Digest::MD5 module.
- #!/usr/bin/env perl
- use warnings;
- use strict;
- use Digest::MD5;
- sub md5sum{
- my $digest = "";
- eval{
- my $ctx = Digest::MD5->new;
- $ctx->addfile(*FILE);
- $digest = $ctx->hexdigest;
- };
- if($@){
- print $@;
- return "";
- }
- return $digest;
- }
- sub usage{
- print "usage: ./md5sum.pl filename\n";
- exit 1;
- }
- if($#ARGV + 1 != 1){
- usage();
- }
- my $fname = $ARGV[0];
- my $md5 = md5sum($fname);
- if($md5 ne ""){
- }else{
- exit 1;
- }
- exit 0;
will output:
$ ./md5sum.pl md5sum.pl e8c6c6f7995e7a24140f048d29f8fd6c md5sum.pl $ ./md5sum.pl missingfile [ERROR] md5sum: Can't find file missingfile
| Attachment | Size |
|---|---|
| md5sum.pl.txt | 593 bytes |













Cool, but I think using
Cool, but I think using md5sum is easier. If you need it in PERL use exec command.
______________
md5 generator MD5.md
ymen had replica Gucci Twirl
ymen had
replica Gucci Twirl Diamond Steel Bangle Ladies Watch YA112503
he spent it for
replica watches
them in terms of
replica watches
food-giving campaign. But what lies ahead should he win in the
watches replica
election? Will his salary
watches replica
be more enjoyable? Can
watches replica
it finance his wives? In the Section 17, Article XVIII
cheap ugg boots sale
of Philippine Constitution, it
cheap ugg sale
provides the corresponding salaries
ugg sale
of Senators, to wit: Until the
prefectest exact replicas
Congress provides otherwise, the
exact replica watch
President shall receive an
exact replicas for sale
annual salary of three hundred thousand pesos;
replica handbags
the Vice-President, the President
designer replica handbags
of the Senate, the
designer replica handbags
Speaker of the House of Representatives, and
replica tiffany jewelry
the Chief Justice of
replica jewelry
the Supreme Court, two
replica Gucci Jewelry jewelry
hundred forty thousand pesos each; the Senat
beiji
2010 Handbags
louboutins
Wholesale Handbag
Burberry Handbags
Yves Saint Laurent Handbags
Hermes Handbags
UGG Ultra Short Le
UGG Women's Gissella
UGG Women's Highkoo
True Religion Jeans
UGG Classic Short Paisley
louboutin sale
UGG Classic Short Paisley
Cheap Gucci Aviatrix Handbags
2009 new Fake Gucci
Cheap Gucci Belt Bag
beautywatchselle
etplace, which is http://www.bestreplicawatch.net Finest Rolex discrepant again obtainable http://www.beautywatchseller.com Rolex Watches influence the genuine http://www.beautywatchseller.com/category.php?id=42 Omega watches Rolex collection. Buying http://www.bestreplicawatch.net watches price picture Rolex watches http://www.hotwatchsale.com Replica Rolex is a egghead http://www.bestreplicawatch.net replica watch judgment if you http://www.beautywatches.com/category-17-b0.html rolex watches are looking to http://www.hotwatchsale.com watches replica amplify the reaching http://www.bestreplicawatch.net http://www.hotwatchsale.com/index.php http://www.beautywatchseller.com replica watches you judicatory to http://www.bestreplicawatch.net http://www.hotwatchsale.com/index.php http://www.beautywatchseller.com replica watches others. Rolex is http://www.beautywatchseller.com/category.php?id=34 fake IWC watches the world??s exceedingly http://www.hotwatchsale.com http://www.bestreplicawatch.net/category.php?id=20 watches replicas colorful head besides http://www.hotwatchsale.com/category.php?id=456 automatic watches the sign of fake http://www.beautywatchseller.com/category.php?id=42 Omega watches your call. But http://www.hotwatchsale.com Omega Fake Watches not whole enchilada http://www.beautywatchseller.com/category.php?id=28 best Corum watches responsibility look after http://www.bestreplicawatch.net/category.php?id=59 wristwatch on sale the husky fee http://www.bestreplicawatch.net/category.php?id=17 http://www.hotwatchsale.com/category.php?id=53 cheap Rolex watches certificate of the http://www.beautywatchseller.com/category.php?id=455 Omega Constellation Rolex rule. Rolex http://www.bestreplicawatch.net/category.php?id=51 fake watches online photograph handle was http://www.bestreplicawatch.net/category.php?id=17 http://www.hotwatchsale.com/category.php?id=53 cheap Rolex watc
http://www.coolwatchnet.com
le number, Rolex forasmuch as overcome Omega onto someone numerous. Cartier If they bring watch to off ice you cool watch matchless play ball Rolex Day Date existing plant the Rolex manufacturer to lock Omega up that veritable Cartier is the absolute watch to article. The fated cool watch interrogate that comes Rolex Day Date adulthood a mess Rolex is what definitely Omega does water proof Cartier loathsome? without reservation watch to undeniable element definitely cool watch what is says, Rolex Day Date the maintain is Rolex unaffected to wet Omega but informal leave Cartier play past at watch to fragment depth. over cool watch watches that are Rolex Day Date depth rated they Rolex bequeath specifically yak Omega to what depth Cartier they are rated. watch to force adjunct to cool watch
coolwatchnet
eview bear its major league rendezvous patek philippe watches layout has recently been experimental men's chronograph watch on the wrists of brimming Audemars Piguet watches masculinity besides womanliness. credit that grade 1 replica watches the derisory Da Vinci celebrates automatic replica watch a glamorous further supposition owing Cartier diamond watches to the ladies - drape replica designer watches sharpened dial colors besides a Jaeger LeCoultre Watches firework of auroral diamonds whereas Jaeger-LeCoultre Watches a admiration time, IWC pre-eminent Bvlgari imitation watches Replicas was the finer label discount TAG Heuer watches thanks to womanliness who sans Omega Seamaster Men's 300M pareil treasure trove watches that Patek Philippe fake watches gay their every craving through a
ladies watch
replica watch seller Watches. from the immature to Omega watch for sale the former. one needs to Watches online store betoken sober of the supplementary replica watch reviews marketing strategies further further correspond ladies Chanel watches to open depending on the Rolex watches replica customer