Perl Push Function - Exercise Result
You Said:
Here is a program that I wrote that
- uses the array from the lesson,
- prompts the user to add a new movie title,
- adds that title to the array, and
- prints the resulting array:
Perl 6
#!/usr/bin/perl -w
@bestpix = ( "Ordinary People",
"Chariots of Fire",
"Gandhi",
"Terms of Endearment",
"Amadeus",
"Out of Africa",
"Platoon",
"The Last Emperor",
"Rain Man",
"Driving Miss Daisy",
"Dances with Wolves",
"The Silence of the Lambs",
"Unforgiven",
"Schindler's List",
"Forrest Gump",
"Braveheart",
"The English Patient" );
print "Add a film: ";
$newfilm = <>;
push @bestpix, $newfilm;
print join("\n", @bestpix);