use strict; use warnings; my $str = "Title: Learning Perl Author: Schwartz, Randal L. ISBN: xxxx"; if ($str =~ /^Title: (.*)\s+Author: (.*)\s+ISBN: (.*)/) { my ($title, $author, $isbn) = ($1, $2, $3); $author =~ s/\.//g; # Remove full stops (periods) print "<$title><$author><$isbn>"; }