Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Mad-Libs/Perl/mad-libs.pl
Normal file
19
Task/Mad-Libs/Perl/mad-libs.pl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
my $template = shift;
|
||||
open my $IN, '<', $template or die $!;
|
||||
my $story = do { local $/ ; <$IN> };
|
||||
|
||||
my %blanks;
|
||||
undef $blanks{$_} for $story =~ m/<(.*?)>/g;
|
||||
|
||||
for my $blank (sort keys %blanks) {
|
||||
print "$blank: ";
|
||||
chomp (my $replacement = <>);
|
||||
$blanks{$blank} = $replacement;
|
||||
}
|
||||
|
||||
$story =~ s/<(.*?)>/$blanks{$1}/g;
|
||||
print $story;
|
||||
Loading…
Add table
Add a link
Reference in a new issue