--RIYY1s2vRbPFwWeW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Alas! Dan Boger spake thus:
> On Thu, Jun 20, 2002 at 02:49:37PM -0600, Rob 'Feztaa' Park wrote:
> > This is trivial to do in perl:
> >=20
> > open "FILE", "<file.txt";
> >=20
> > while (<FILE>)
> > {
> >   push @lines, $_;
> > }
> >=20
> > print $lines[int(rand(@lines))];
>=20
> or, the more efficient way:
>=20
>     open "FILE", "<file.txt" or die "$!";
>     rand($.) < 1 && ($line =3D $_) while <FILE>;
>     close FILE;
>     print $line;
>=20
> from "perldoc -q random"

Sure, that works; but you can't repeat it without rewinding to the
beginning of the file. With mine, you can call that print statement as
many times as you want ;)

--=20
Rob 'Feztaa' Park
http://members.shaw.ca/feztaa/
--
Q:      What's the difference between a Mac and an Etch-a-Sketch?
A:      You don't have to shake the Mac to clear the screen.

--RIYY1s2vRbPFwWeW
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9EmQXPTh2iSBKeccRAhDfAJ9jd9Vaiz1rizAPjDfFPAhthsEM1wCfSRLi
rLLEqUvoqxSzDSo2Erpdxog=
=y5Ly
-----END PGP SIGNATURE-----

--RIYY1s2vRbPFwWeW--

Reply via email to