Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2016-06-26 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (328 votes). Check out past polls.