fork(1) download
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. print "Enter first or last name of artist: ";
  5. chomp(my $input = <STDIN>); #Take input from user
  6. while(chomp(my $line = <DATA>)){
  7. if($line =~ /$input/){ #Check if input matches with line
  8. my @artist_info = split/:/,$line; #Split the data from line based on `:`
  9. print " Name: $artist_info[0]\n CD Title: $artist_info[1]\n Date: $artist_info[2]\n Price: $artist_info[3]\n";
  10. }
  11. }
  12.  
  13. __DATA__
  14. Seamus McGuire:The Wishing Tree:09-14-2000:14.95
  15. Pat Kilbride:Loose Cannon:07-02-2000:15.95
  16. Kevin Crawford:Seasons of Mists:06-23-2000:16.95
  17. Prince:Purple Rain:01-01-1995:3.95
  18. Meat Loaf:Bat out of Jell:03-03-1980:11.95
  19. Eddie Money:Two Tickets:09-04-1979:8.98
Success #stdin #stdout 0s 3740KB
stdin
Meat
stdout
Enter first or last name of artist:  Name: Meat Loaf
 CD Title: Bat out of Jell
 Date: 03-03-1980
 Price: 11.95