Question

for future views please dont use it for spring 2020 Write a Perl program to accomplish...

for future views please dont use it for spring 2020

Write a Perl program to accomplish each of the following on the file solar.txt (see link at the class homepage)

1. Print all records that do not list a discoverer in the eighth field.

2. Print every record after erasing the second field. Note: It would be better to say "print every record" omitting the second field

. 3. Print the records for satellites that have negative orbital periods. (A negative orbital period simply means that the satellite orbits in a counterclockwise direction.)

4. Print the data for the objects discovered by the Voyager2 space probe.

5. Print each record with the orbital period given in seconds rather than days.

About solar.txt file:

This file contains lines of 9 items, the first being: Adrastea XV Jupiter 129000 0.30 0.00 0.00 Jewitt 1979 in alphabetical order by the name of the planet or moon (first field). The text in [] is the corresponding field from the line above. The fields in this file are

: 1. Name of planet or moon [Adrastea]

2. Number of moon or planet (roman numerals) [XV]

3. Name of the abject around which the satellite orbits [Jupiter]

4. Orbital radius (semimajor axis) in kilometers [129000]

5. Orbital period in days [0.30]

6. Orbital inclination in degrees [0.00]

7. Orbital eccentricity [0.00] 8. Discoverer [Jewitt]

9. Year of discovery [1979]

Adrastea XV Jupiter 129000 0.30 0.00 0.00 Jewitt 1979
Amalthea V Jupiter 181000 0.50 0.40 0.00 Barnard 1892
Ananke XII Jupiter 21200000 -631 147.00 0.17 Nicholson 1951
Ariel I Uranus 191000 2.52 0.00 0.00 Lassell 1851
Atlas XV Saturn 138000 0.60 0.00 0.00 Terrile 1980
Belinda XIV Uranus 75000 0.62 0.03 0.00 Voyager2 1986
Bianca VIII Uranus 59000 0.43 0.16 0.00 Voyager2 1986
Caliban XVI Uranus 7169000 -580 140. 0.08 Gladman 1997
Callirrhoe XVII Jupiter 24100000 ? ? ? Sheppard 2000
Callisto IV Jupiter 1883000 16.69 0.28 0.01 Galileo 1610
Calypso XIV Saturn 295000 1.89 0.00 0.00 Pascu 1980
Carme XI Jupiter 22600000 -692 163.00 0.21 Nicholson 1938
Chaldene XXI Jupiter 23387000  -733.7 165.2 0.238 Sheppard 2000
Charon I Pluto 20000 6.39 98.80 0.00 Christy 1978
Cordelia VI Uranus 50000 0.34 0.14 0.00 Voyager2 1986
Cressida IX Uranus 62000 0.46 0.04 0.00 Voyager2 1986
Deimos II Mars 23000 1.26 1.80 0.00 Hall 1877
Desdemona X Uranus 63000 0.47 0.16 0.00 Voyager2 1986
Despina V Neptune 53000 0.33 0.00 0.00 Voyager2 1989
Dione IV Saturn 377000 2.74 0.02 0.00 Cassini 1684
Earth III Sun 149600000 365.26 0.00 0.02 - -
Elara VII Jupiter 11737000 259.65 28.00 0.21 Perrine 1905
Enceladus II Saturn 238000 1.37 0.02 0.00 Herschel 1789
Epimetheus XI Saturn 151000 0.69 0.34 0.01 Walker 1980
Erinome XXV Jupiter 23279000 728 164.9 0.266 Sheppard 2000
Europa II Jupiter 671000 3.55 0.47 0.01 Galileo 1610
Galatea VI Neptune 62000 0.43 0.00 0.00 Voyager2 1989
Ganymede III Jupiter 1070000 7.15 0.19 0.00 Galileo 1610
Harpalyke XXII Jupiter 21132000 623.3 148.6 0.226 Sheppard 2000
Helene XII Saturn 377000 2.74 0.20 0.01 Laques 1980
Himalia VI Jupiter 11480000 250.57 28.00 0.16 Perrine 1904
Hyperion VII Saturn 1481000 21.28 0.43 0.10 Bond 1848
Iapetus VIII Saturn 3561000 79.33 14.72 0.03 Cassini 1671
Io I Jupiter 422000 1.77 0.04 0.00 Galileo 1610
Iocaste XXIV Jupiter 20216000 ? ? ? Sheppard 2000
Isonoe XXVI Jupiter 23078000 ? ? ? Sheppard 2000
Janus X Saturn 151000 0.69 0.14 0.01 Dollfus 1966
Juliet XI Uranus 64000 0.49 0.06 0.00 Voyager2 1986
Jupiter V Sun 778330000 4332.71 1.31 0.05 - -
Kalyke XXIII Jupiter 23745000 ? ? ? Sheppard 2000
Larissa VII Neptune 74000 0.55 0.00 0.00 Reitsema 1989
Leda XIII Jupiter 11094000 238.72 27.00 0.15 Kowal 1974
Lysithea X Jupiter 11720000 259.22 29.00 0.11 Nicholson 1938
Mars IV Sun 227940000 686.98 1.85 0.09 - -
Megaclite XIX Jupiter 23911000 ? ? ? Sheppard 2000
Mercury I Sun 57910000 87.97 7.00 0.21 - -
Metis XVI Jupiter 128000 0.29 0.00 0.00 Synnott 1979
Mimas I Saturn 186000 0.94 1.53 0.02 Herschel 1789
Miranda V Uranus 130000 1.41 4.22 0.00 Kuiper 1948
Moon I Earth 384000 27.32 5.14 0.05 - -
Naiad III Neptune 48000 0.29 0.00 0.00 Voyager2 1989
Neptune VIII Sun 4504300000 60190.00 1.77 0.01 Adams 1846
Nereid II Neptune 5513000 360.13 29.00 0.75 Kuiper 1949
Oberon IV Uranus 583000 13.46 0.00 0.00 Herschel 1787
Ophelia VII Uranus 54000 0.38 0.09 0.00 Voyager2 1986
Pan XVIII Saturn 134000 0.58 0.00 0.00 Showalter 1990
Pandora XVII Saturn 142000 0.63 0.00 0.00 Collins 1980
Pasiphae VIII Jupiter 23500000 -735 147.00 0.38 Melotte 1908
Phobos I Mars 9000 0.32 1.00 0.02 Hall 1877
Phoebe IX Saturn 12952000 -550.48 175.30 0.16 Pickering 1898
Pluto IX Sun 5913520000 90550 17.15 0.25 Tombaugh 1930
Portia XII Uranus 66000 0.51 0.09 0.00 Voyager2 1986
Praxidike XXVII Jupiter 20964000 ? ? ? Sheppard 2000
Prometheus XVI Saturn 139000 0.61 0.00 0.00 Collins 1980
Prospero XVIII Uranus 16568000 -2019 152. 0.44 Holman 1999
Proteus VIII Neptune 118000 1.12 0.00 0.00 Voyager2 1989
Puck XV Uranus 86000 0.76 0.31 0.00 Voyager2 1985
Rhea V Saturn 527000 4.52 0.35 0.00 Cassini 1672
Rosalind XIII Uranus 70000 0.56 0.28 0.00 Voyager2 1986
Saturn VI Sun 1429400000 10759.50 2.49 0.06 - -
Setebos XIX Uranus 17681000 -2239 158. 0.57 Kavelaars 1999
Sinope IX Jupiter 23700000 -758 153.00 0.28 Nicholson 1914
Stephano XX Uranus 7948000 -674 143. 0.24 Gladman 1999
Sun - - - - - - - -
Sycorax XVII Uranus 12213000 -1289 153. 0.51 Nicholson 1997
Taygete XX Jupiter 23312000 ? ? ? Sheppard 2000
Telesto XIII Saturn 295000 1.89 0.00 0.00 Smith 1980
Tethys III Saturn 295000 1.89 1.09 0.00 Cassini 1684
Thalassa IV Neptune 50000 0.31 4.50 0.00 Voyager2 1989
Thebe XIV Jupiter 222000 0.67 0.80 0.02 Synnott 1979
Themisto XVIII Jupiter 7507000 ? ? ? Sheppard 2000
Titan VI Saturn 1222000 15.95 0.33 0.03 Huygens 1655
Titania III Uranus 436000 8.71 0.00 0.00 Herschel 1787
Trinculo XXI Uranus 8578000 -759 167.0 0.208 Gladman 2001
Triton I Neptune 355000 -5.88 157.00 0.00 Lassell 1846
Umbriel II Uranus 266000 4.14 0.00 0.00 Lassell 1851
Uranus VII Sun 2870990000 30685.00 0.77 0.05 Herschel 1781
Venus II Sun 108200000 224.70 3.39 0.01 - -
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the code for above question:

use warnings;
use strict;


open (ABC, "/home/trimurthulu/abc.txt") or die "Could not open the file!";
my @array = (<ABC>);
close (ABC);
#question 1
for my $record (@array) {
my @tempArray = split(/ /, $record);
if ($tempArray[7] eq "-")   
{
print "@tempArray";
}
}
#question 2
for my $record (@array) {
my @tempArray = split(/ /, $record);
   my @x=splice(@tempArray, 1,1);
{
print "@tempArray";
}
}
#question 3
for my $record (@array) {
my @tempArray = split(/ /, $record);
if ($tempArray[4] < 0.0)   
{
print "@tempArray";
}
}
#question 4
for my $record (@array) {
my @tempArray = split(/ /, $record);
if ($tempArray[7] eq 'Voyager2')   
{
print "@tempArray";
}
}
#question 5
for my $record (@array) {
my @tempArray = split(/ /, $record);
my $a=86400;
if ($tempArray[4]*$a)   
{
print "@tempArray";
}
}

output:

Activities Terminal - Sat 2:04 PM trimurthulu@jack-sparrow: - File Edit View Search Terminal Help trimurthulu@jack-sparrow: $

output is too long, so provided only 1 image.

Add a comment
Know the answer?
Add Answer to:
for future views please dont use it for spring 2020 Write a Perl program to accomplish...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT