Created
February 27, 2015 19:16
-
-
Save beppu/715147f5aef0b8971b10 to your computer and use it in GitHub Desktop.
for educational purposes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
sub slurp { | |
my $file = shift; | |
open my $fh, '<', $file or die; | |
my @lines = <$fh>; | |
close $fh; | |
\@lines; | |
} | |
sub replace { | |
my $seed = shift; | |
my $lines = shift; | |
$lines->[int(rand(scalar @$lines))] = "$seed\n"; | |
$lines | |
} | |
my $seed = shift; | |
my $file = shift; | |
my $lines = replace $seed, slurp($file); | |
print @$lines; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment