Skip to content

Instantly share code, notes, and snippets.

@christo
Created February 22, 2011 22:02
Show Gist options
  • Save christo/839521 to your computer and use it in GitHub Desktop.
Save christo/839521 to your computer and use it in GitHub Desktop.
print a random line from a file
#!/usr/bin/perl
use warnings;
open FH, $ARGV[0] or die;
@lines = <FH>;
print @lines[int(rand(scalar @lines))] . "\n";
close FH;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment