"Sputnik" help  
Sputnik Help
BinaryReplaceByte(<binary>, <oldByte>, <newByte>, [<start>], [<max>], [<replacements>])


The BinaryReplaceByte function is used to replace occurrences of a specified byte within a binary string with a new byte. It returns a new binary string with the replacements made.


<binary> The original binary string in which replacements will be made.
<oldByte> The byte to be replaced.
<newByte> The byte to replace the occurrences of <oldByte>.
<start> Optional starting index from which to begin searching for occurrences of <oldByte> within <binary>. Defaults to 0 if not specified.
<max> Optional maximum number of replacements to make. If not specified or set to -1, all occurrences of <oldByte> within <binary> will be replaced.
<replacements> Optional variable that will be filled with the number of replacements made. This is an output parameter and should be provided as a variable reference.

Return Value

Success: Returns a new binary string with the specified replacements made.
Failure: Returns an empty binary string.


The BinaryReplaceByte function searches for occurrences of <oldByte> within <binary> starting from the specified <start> index, and replaces them with <newByte>.
By default, all occurrences of <oldByte> within <binary> are replaced. The <max> parameter allows you to limit the number of replacements made.
The original <binary> string remains unchanged; instead, a new binary string is created with the replacements made.
If the <replacements> variable is provided, it will be filled with the number of replacements made.




Example of usage:

my $bin = bin("Hello World");
say BinaryReplaceByte($bin, 'l', 'X');
// HeXXo WorXd


Cheryl (uberfox@hotmail.com)