Skip to content

Instantly share code, notes, and snippets.

@christo
Created February 22, 2011 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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