Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Perl memset equivalent?

by moritz (Cardinal)
on Jun 26, 2012 at 18:37 UTC ( #978483=note: print w/replies, xml ) Need Help??

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++).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://978483]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2016-10-28 09:11 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (379 votes). Check out past polls.