"Sputnik" help  
Sputnik Help
BinaryShrink(<binary>, <size>, [<fromLeft>])

Description

Shrinks a binary string by the specified size, removing the specified number of bytes from either the end or the beginning of the string.

Parameters

<binary> The binary string to be shrunk.
<size> The size by which the binary string should be shrunk. This indicates the number of bytes to be removed.
<fromLeft> Optional boolean value indicating whether the shrinkage should occur from the left side. If set to true, the bytes will be removed from the beginning of the binary string. If not provided or set to false, the bytes will be removed from the end of the binary string.

Return Value

Success: Returns the new size of the binary string after shrinking.
Failure: Returns current size (means no change).

Remarks

The BinaryShrink function allows you to reduce the size of a binary string by removing a specified number of bytes. It takes a binary string, the size to shrink by, and an optional flag to indicate the shrinkage direction. By default, if the shrinkage direction is not provided or set to false, the bytes will be removed from the end of the binary string. If the shrinkage direction is set to true, the bytes will be removed from the beginning of the binary string. This function is useful when you need to decrease the size of a binary string by a specific amount.

Related

BinaryGrow, BinarySize

Example

Example of usage:

my $a = Bin("HelloWorld!");
BinaryShrink($a, 4);
say BinaryExpand($a, false);

my $a = Bin("HelloWorld!");
BinaryShrink($a, 4, true);
say BinaryExpand($a, false);

// PRINTS
// 48 65 6C 6C 6F 57 6F -- -- -- -- -- -- -- -- -- HelloWo
// 6F 57 6F 72 6C 64 21 -- -- -- -- -- -- -- -- -- oWorld!

 


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