Use Perl to program an array that holds three songs. Each song should have its title, artist, album, and year. Afterward, there should be a split function and a while loop to show the album followed by the song's title and album.
Use Perl to
Start by defining an empty array to store song information.
Add three songs to the array, with each song having four pieces of information: title, artist, album, and year. Separate these pieces of information using the pipe character ( | ) within each song entry.
Initialize a loop to iterate through each song in the array.
Inside the loop:
Take one song from the array.
Split the song information into its four parts (title, artist, album, and year) using the pipe character as the delimiter.
Store these four parts into separate variables for easy access.
Display the album, song title, artist, and year for the current song:
Print "Album: [album name]".
Print "Title: [song title]".
Print "Artist: [artist name]".
Print "Year: [release year]".
Add a blank line to separate this song's information from the next.
Continue the loop until all songs in the array have been processed.
End the program.
Step by step
Solved in 4 steps with 2 images