"Sputnik" help  
Sputnik Help
BinNew([<size>], [<filler>])

Description

Creates a new binary string of the specified size with an optional filler value. The BinNew function is useful for initializing binary strings with a specific size and optional default content.

Parameters

<size> Optional size of the binary string to create. If not provided, an empty binary string is returned.
<filler> Optional value to fill the binary string with. If not provided, the binary string is filled with null bytes (0x00).

Return Value

Success: Returns a new binary string of the specified size with the optional filler value.
Failure: Returns an empty binary string.

Remarks

The <size> parameter determines the size of the binary string to create. It should be a non-negative integer value. If not provided, the resulting binary string will be empty.
The <filler> parameter specifies the value to fill the binary string with. It can be any valid byte value (0-255). If not provided, the binary string will be filled with null bytes (0x00).
The resulting binary string will have the specified size and contain the filler value repeated throughout its content.

Related

Example

Example of usage:

my $emptyString = BinNew();
say BinaryExpand($emptyString, false);
my $filledString = BinNew(8, 0xFF);
say BinaryExpand($filledString, false);
my $customString = BinNew(5, 0x55);
say BinaryExpand($customString, false);

// PRINTS
// FF FF FF FF FF FF FF FF -- -- -- -- -- -- -- -- ÿÿÿÿÿÿÿÿ
// 55 55 55 55 55 -- -- -- -- -- -- -- -- -- -- -- UUUUU

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org