+ if ( $opt->write ) {
+ my $card = read_file $opt->write;
+ print STDERR "writing $uid block ";
+ foreach my $block ( 0 .. $tag->blocks ) {
+ my $offset = 0x10 * $block;
+ $tag->write_block( $block, substr($card,$offset,0x10) );
+ print STDERR "$block ";
+ }
+ print STDERR "done\n";
+ } else {
+ # view dump
+ my $txt_file = $out_file;
+ $txt_file =~ s/\.mfd/.txt/ || die "can't change extension to txt";
+ system "./mifare-mad.pl $out_file > $txt_file";
+ $ENV{MAD} && system "vi $txt_file";
+ }