"Sputnik" help  
Sputnik Help
BinaryAssign(<binary>, <binaryTo>, [<addAsRef>])

Description

The BinaryAssign function assigns the content of one binary to another binary. It can be used to copy the data from the source binary to the target binary. The assignment can be performed either by value or by reference, depending on the optional parameter <addAsRef>.

Parameters

<binary> The binary that will receive the assigned content.
<binaryTo> The source binary whose content will be assigned to <binary>
[<addAsRef>] Optional boolean value indicating whether the assignment should be performed by reference. If set to true, the assignment will be done by reference. (Default: false)

Return Value

Success: Returns true.
Failure: Returns false.

Remarks

When the <addAsRef> parameter is not provided or set to false, the assignment is performed by value, meaning that the content of <binaryTo> is copied to <binary>.
If the <addAsRef> parameter is set to true, the assignment is performed by reference. This means that <binary> becomes a reference to <binaryTo>, and any changes made to <binaryTo> will be reflected in <binary>.
Care should be taken when using references to avoid unintended modifications.

Related

Example

Basic example:

my $binaryTo = (binary)"Hello";
my $binary = (binary)"World";
BinaryAssign($binary, $binaryTo);
say $binary;
// PRINTS
// Hello

Example of using the addAsRef:

my $binaryTo = (binary)"Hello";
my $binary = (binary)"World";
BinaryAssign($binary, $binaryTo, true);
$binaryTo[0] = 'T';
say $binary;
// PRINTS
// Tello

 


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