Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub checksum
- {
- my ($dotsfv) = @_;
- my $error = 0;
- my $passed = 0;
- foreach my $sfvfile (@dotsfv)
- {
- #execdir sub uses return
- if ( execdir("cfv -f", $sfvfile) )
- {
- ++$error;
- }
- else
- {
- ++$passed;
- }
- }
- my $total = $error + $passed;
- if ( $error )
- {
- print colored "\n\t\t$error/$total", 'bold red';
- print colored " checksums failed\n", 'bold yellow';
- print "\nContinue Anyway ?\t\t\t\t\t\t[";
- print colored "y ", 'bold green';
- print "/";
- print colored " n", 'bold red';
- print "]\n";
- my $accept = <>;
- if ($accept =~ m/(N|n)/)
- {
- print colored "Aborting user chose no\n", 'bold yellow';
- exit 0;
- }
- }
- else
- {
- print colored "\n\t\t$passed/$total", 'bold green';
- print colored " checksums passed\n", 'bold yellow';
- }
- }
- sub execdir
- {
- my ($cmd, $filename) = @_;
- my (undef, $dir) = fileparse($filename);
- ($filename) = basename($filename);
- chdir $dir;
- system("$cmd '$filename'");
- my $exitvalue = $? >> 8;
- if ( $exitvalue )
- {
- return 1;
- }
- else
- {
- return 0;
- }
- } #to use do execdir(cmd, file);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement