On 24 March 2010 00:56, Eric Veith1 <[email protected]> wrote:
> Sam <[email protected]> wrote on 03/23/2010 11:18:11 PM:
>> Could you use a file of random data? You can create one of those really
>> easy: dd if=/dev/urandom of=ranfile bs=9999
>
> Theoretically, yes, of course I could just try to create an arbitrary
> sized file from /dev/urandom via dd. I hoped there would be an equally
> both fast and elegant solution possible as with the C approach (malloc
> without init). Bob's idea of just reading and piping files from /bin or
> /usr/bin was also a good idea.
>
> Well, if there's no... "more elegant" solution, I'll happily go with what
> has been offered. (Note the " around "more elegant"!)

I would say both of the offered solutions are more elegant than using
uninitialised malloc()ed memory. You can't rely on malloc to offer you
known data, but you *also* can't rely on it to give you sufficiently
random data. The /bin option also has the advantage (or disadvantage,
depending on application) of being deterministic.

I note that a quick search on CPAN for "urandom" turns up
String::Urandom as a more Perlish way to access /dev/urandom. I'm not
sure how much it gains you: given that you still depend on
/dev/urandom being present, you might as well make it explicit.

Phil

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to