Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a PERL script to help users calculate compressed file size. NEED SCREENSHO

ID: 3798248 • Letter: W

Question

Write a PERL script to help users calculate compressed file size. NEED SCREENSHOTS

Prompt the user to enter the original size of a file (in bytes) from the keyboard. Then use the following rules for calculating the compressed file size.

Display the result on the screen. If the size is less than 5000 bytes, the compression ratio is 90%. If the size is between 5000 and 50000 bytes, the compression ratio is 70%.

If the size is more than 50000 bytes, the compression ratio is 40%.

2. Develop a small Perl console program driven by a text menu (see the sample screenshot below): It displays a simple menu with 4 items indicated by number 1-4. Users will enter number 1 to 4 to run some commands. Item #1 to #3 will run some shell commands (it’s your choice what to run, but do not use the same commands as in the example). When the command is finished, display the menu again. If 4 is entered, then quit the program.

Sample Screenshot

Welcome to Menu:

1.) ls

2.) ls -i

3.) ls -a

4.) Exit

Please enter a choice 1-4: 1

case.sh                   file-test.sh                      menu.sh                  script-args.sh              timer.sh

compund.sh           for.sh                          math.sh              pattern.sh                simple-script.sh              while.sh

Welcome to Menu:

1.) ls

2.) ls -i

3.) ls -a

4.) Exit

Please enter a choice 1-4: 4

Exit ...

root@ubuntu0:~/Documents/script#

Explanation / Answer

use strict;

use warnings

print "enter file size in bytes ";

my $filesize = <STDIN>;

chomp $filesize;

$ratio=0

$compressedfilesize=0;

if (filesize < 5000) {

ratio=90;

} elsif (filesize=>5000 && filesize<=50000) {

ratio=70;

} else {

ratio=40;

}

$compressedfilesize=(ratio/100 ) *filesize

print "Your compressed file size is '$compressedfilesize' ";


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote