Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Playing with heredocs & conditionals in Perl
#!/usr/bin/perl
use strict;
use warnings;
my $books = <<'END_OF_REPORT';
1 The Well-Grounded Rubyist
2 Pragmatic Thinking & Learning
3 Programming Ruby 1.9
4 Learning Perl
END_OF_REPORT
#I know I need a loop, just not there yet in my course
my ($line1, $line2, $line3, $line4) = split "\n", $books;
print "Here is a list of my programming books\n";
my ($rank, $topic) = split " ", $line1, 2;
print "$rank $topic", "\n";
($rank, $topic) = split " ", $line2, 2;
print "$rank $topic", "\n";
($rank, $topic) = split " ", $line3, 2;
print "$rank $topic", "\n";
($rank, $topic) = split " ", $line4, 2;
print "$rank $topic", "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment