Tuesday, April 13, 2010

study notes

getopts for perl?
check out
my %options=();
getopts("a",\%options) or usage();

#HELP_MESSAGE();
addrule() if defined $options{"a"};
sub HELP_MESSAGE()
{
$Getopt::Std::STANDARD_HELP_VERSION=1;
usage;
}
sub VERSION_MESSAGE()
{
$Getopt::Std::STANDARD_HELP_VERSION=1;
#print `grep "^# VERSION" ./odssvn.pl`;
}

TEST;
perl t.pl --help
perl t.pl --version
perl t.pl -a

MD5 for perl

use Digest::MD5;

$ctx = Digest::MD5->new;
$ctx->add($data);
$ctx->addfile(*FILE);
$digest = $ctx->digest;
$digest = $ctx->hexdigest;
$digest = $ctx->b64digest;

No comments: