Question: Please help me on my perl script and explain to me about it.....Thank you ################################# print Sales Figures ; $sum = 0; $highSales= 0; while
Please help me on my perl script and explain to me about it.....Thank you ################################# print "Sales Figures"; $sum = 0; $highSales= 0; while (<>){ # Split the line into fields ':' as a delimiter @EmpRecord = split(/:/, $_); $sum += @EmpRecord[4]; if( @EmpRecord[4] > $highSales ){ $highName = @EmpRecord[0]; $highSales = @EmpRecord[4]; } @Name = split(/ /, @EmpRecord[0]); $pName = @Name[1].", ".@Name[0]; # Add $ to the sales using ' ' as the delimiter $sales = "\$ " . @EmpRecord[4]; printf("%-17s %10s %10s", $pName, @EmpRecord[3], $salas); } $avgSales = $sum / $.; print " "; print "Number of Sales Persons: " . $. . " "; print "Average sales of the sales persons" . $. ." " ; printf("Average Sales Each Quarter: \$ %.2f ", $avgSales); print "Highest Paid Employee : " . $highName . " Total: " .$sum; #############################Sales.txt###################################
Steve Blenheim:238-923-7366:20300:21320:22390:21500 Betty Boop:245-836-8357:14500:14070:14360:15370 Igor Chevsky:385-375-8395:23400:24340:25320:24820 Norma Corder:397-857-2735:24570:25070:24320:28700 Jennifer Cowan:548-834-2348:58900:53010:55670:52330 Jon DeLoach:408-253-3122:85100:95320:92470:94320 Karen Evich:284-758-2857:85100:97870:101790:101790 Fred Fardbarkle:674-843-1385:78090:84340:86030:92060 Lori Gortz:327-832-5728:35200:36260:32640:31670 Paco Gutierrez:835-365-1284:12350:11860:13290:13690 Ephram Hardy:293-259-5395:56700:60670:69780:68390 James Ikeda:834-938-8376:45000:44100:47630:50020 Barbara Kertz:385-573-8326:26850:31690:32650:33310 Lesley Kirstin:408-456-1234:52600:49450:47480:49380 William Kopf:846-836-2837:43500:44370:47480:46060 Sir Lancelot:837-835-8257:24500:24500:24010:25220 Jesse Neal:408-233-8971:25000:26750:31570:30630 Zippy Pinhead:834-823-8319:89500:86820:81620:84890 Arthur Putie:923-835-8745:12600:12980:13240:13510 Popeye Sailor:156-454-3322:22350:21910:21910:19720 Jose Santiago:385-898-8357:95600:100380:107410:120300 Tommy Savage:408-724-0140:34200:34890:33850:38930 Yukio Takeshida:387-827-1095:57000:59280:61060:65950 Vinh Tranh:438-910-7449:68900:66840:65510:67480
####################################################################################
Write a perl script that does all of the following: The file Sales.txt holds the name, telephone number, and quarterly sales totals, separated by :, for a list of salespersons for a certain company
b)Print the names of all salespersons in the form LastName, FirstName, their total sales for all four quarters, and their average quarterly sales.
c)Prints a summary at the end of the list that gives the number of salespersons, the average sales of the salespersons, the average sales for each quarter, and the name and total sales of the salesperson with the highest total sales.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
