Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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?
[1nickt]: ugh, buying a computer is hard for an old person
[stevieb]: How do you mean?
[1nickt]: They assume that I want things I don;t and don;t provide things I do want. Looking for a 17" laptop with 4k (even 3K display) and full numeric-pad keyboard.
[1nickt]: They assume that if I want a 17" monitor I could not possibly want 4k screen
[1nickt]: They assume I do not need a DVD drive
[1nickt]: Heh, or they assume that if I want all that I am a "gamer" and I must want red backlighting for the keyboards and that I will pay $3500 ...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2017-03-26 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (315 votes). Check out past polls.