Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #Lab 5: Master Boot Record
- #by Alex Reeder
- #
- #
- use File::Basename;
- use Term::Menu;
- use Term::Prompt;
- my $fileFull;
- my $fileName;
- #pull MBR.bin file from argument
- if (-e $ARGV[0]) {
- $fileFull = $ARGV[0];
- $fileName = basename($fileFull);
- if ($fileName eq "MBR.bin") {
- print "MBR.bin read succesfully.\n"
- }
- else {
- die "Improper file.\n";
- }
- }
- else {
- die "File not found.\n";
- }
- #open the MBR.bin file
- open(MBR, $fileFull);
- binmode MBR;
- my @MBR = <MBR>;
- my ($data, $n, $offset);
- while (($n = read MBR, $data, 4, $offset) != 0) {
- # print "$n bytes read\n";
- $offset += $n;
- }
- close(MBR);
- foreach $n (@MBR){
- print $n;
- print "\n";
- }
- #&mainMenu;
- sub mainMenu {
- my $prompt = new Term::Menu (
- tries => 1000,
- aftertext => "Please enter the number corresponding to the answer you want to choose: ",
- );
- my $answer = $prompt->menu(
- 1 => ["Disk signature", '1'],
- 2 => ["Partition Table Entry", '2'],
- 3 => ["MBR signature", '3'],
- 4 => ["Exit", '4'],
- );
- if ($answer == 1) {
- &diskSig;
- }
- elsif ($answer == 2){
- &partTable;
- }
- elsif ($answer == 3){
- &MBRSig;
- }
- elsif ($answer == 4){
- print ("\nExiting...\n");
- exit;
- }
- }
- sub diskSig {
- print "in DS!\n";
- &mainMenu;
- }
- sub partTable {
- print "in part!\n";
- &mainMenu;
- }
- sub MBRSig {
- print "in MBR!\n";
- &mainMenu;
- }
Advertisement
Add Comment
Please, Sign In to add comment