in reply to Perl memset equivalent?
You don't have direct memory access in Perl, so talking about an equivalent is a bit misleading.
If you want to set a range of array elements to zero, you can do that as
@array[0..4] = (0) x 5;
If you want to create a string of zero-bytes, you can write
my $s = "\0" x 5;
(Update: fixed off-by-one error noticed by martin++).
|
|---|